Org-roam-dailies: how to browse through previous days

I’m wondering what the best way is to look through previous days’ org-roam-dailies entries? I can call org-roam-dailies-date and it shows me a calendar, and dates with entries are highlighted. But, if I shift to a previous month, all the per-day highlighting vanishes.

Also, if I could, I’d love a kind of split-screen view where I could just navigate up and down the list on the left-hand side, and see the org-roam-dailies files on the right. Maybe there’s even a way to do that in Emacs already?

Hi,

For my part, I keep it simple. I put a “journal” folder in the “roam” folder that includes all journal entries. So I can search simply by the file name (which is the date) when I know the date. I use too org-roam-dailes-find-yesterday

If you don’t know the date, you can use deft or rg to search in the notes.

That makes sense. Is there a good way to have a split screen?

E.g. in using DevonThink, I could just use the arrow keys to scroll down the index on the left-hand-side of the screen, and the right-hand pane would show the contents of the current ite.

Something like this ?

1 Like

I have a very similar set up with the one @bepolymathe has

The very left is a simple Dired (with dired-hide-details-mode to show only the file names).
The middle is the note, and the right is the backlink buffer from org-roam.

I have the following in my init.el to define custom functions for me to navigate the Dired buffer up and down.

Basically, up or down to display the note, and update the backlink. You don’t go out of Dired, so you can skim throught the directory with backlinks (it also works in directories outside Org-roam without backlinks).

I don’t use dailies, but I believe you can use this way for the dailies directory (??)

I have to add, though, splitting the screen in this way is manually done – I don’t have a good way to set the sizes correctly and automatically.

;;; Edited 20201-02-08
;;; Dired
(defun my/check-org-roam-buffer-p (buf)
  "Return non-nil if BUF is org-roam-buffer that can be refleshed.
It also checks the following:
- `org-roam' is indeed loaded
- BUF is visiting an Org-roam file
- org-roam-buffer exists"
  (and (functionp #'org-roam--org-roam-file-p)
       (org-roam--org-roam-file-p (buffer-file-name buf))
       (not (eq (org-roam-buffer--visibility) 'none))))

;;;###autoload
(defun my/dired-display-next-file ()
  "In Dired directory, go to the next file, and open it.
            If `org-roam-mode' is active, update the org-roam-buffer."
  (interactive)
  (dired-next-line 1)
  (let ((buf (find-file-noselect (dired-get-file-for-visit))))
    (display-buffer buf t)
    (when (my/check-org-roam-buffer-p buf)
      (with-current-buffer buf
        (setq org-roam--current-buffer buf)
        (org-roam-buffer-update)))))

;;;###autoload
(defun my/dired-display-prev-file ()
  "In Dired directory, go to the previous file, and open it.
            If `org-roam-mode' is active, update the org-roam-buffer."
  (interactive)
  (dired-previous-line 1)
  (let ((buf (find-file-noselect (dired-get-file-for-visit))))
    (display-buffer buf t)
    (when (my/check-org-roam-buffer-p buf)
      (with-current-buffer buf
        (setq org-roam--current-buffer buf)
        (org-roam-buffer-update)))))

(add-hook 'dired-mode-hook
          (lambda ()
            (dired-hide-details-mode 1)
            ;; I don't use dired-subtree at the moment
            ;;(define-key dired-mode-map (kbd "<tab>") #'dired-subtree-toggle)
            ;;(define-key dired-mode-map (kbd "<C-tab>") #'dired-subtree-cycle)
            (define-key dired-mode-map (kbd "<SPC>") #'my/dired-display-next-file)
            (define-key dired-mode-map (kbd "<down>") #'my/dired-display-next-file)
            (define-key dired-mode-map (kbd "<up>") #'my/dired-display-prev-file)))
2 Likes

That’s exactly what I’m after.

How do you trigger your Dired window to get into that mode? Apologies for what is probably a dumb question - still trying to figure out how Emacs works. Is that lambda mode-hook something that you trigger manually, or (as I think) it kicks in whenever you invoke Dired?

No worries.
Yes, (add-hook 'dired-mode-hook ...body...) makes the body to kick in when dired-mode is invoked. In my case, all the body is encapsulated within the lambda expression (you can use a named function, but I find lambda convenient).

The way I get into Dired is simple. In the note you are in, call C-x C-f; stock standard find-file and type a dot (".") and enter (to open the current directory, not a file). This opens a Dired buffer, and replaces the note buffer. If you had the backlink buffer open, it should be kept open (this might depend on Doom, etc. but my vanilla does not close it).

Call C-x 3 to split the window vertically. Then I manually drag the line to adjust the size… I am pretty sure there is more elegant way, but for me it’s enough. I also have a keybinding to adjust the size by a key stroke, but I rarely use it (the commands are shrink-window-horizontally and enlarge-window-horizontally).

Just as a side note, if you are still finding a way around Emacs… You might not like the esthetics of the menu bar, but I personally keep it on. It helps me discover and remind me of these “basic” navigation and functions, etc. – it might be helpful to keep it while until you are comfortable with Emacs. I would consider myself a confident Emacs user but I find it essential (It’s not distracting for me in most cases; I can easily turn it off temporarily if I want to focus on writing).

Thanks for this - super helpful.

What do you do if you want a “standard” Dired, where you can see more details and do more stuff to files?

@lyndondrake

Remove this part, or call it via M-x in Dired to tooggle it on/off (I think).

In fact, it’s this. I discovered something new with the menu bar, hey :wink:

Ha! perfect

The next thing I want to figure out is how to get a Helm buffer up with a list of the titles, working the same way… more for the main org-roam files, not the dailies

Sorry I can’t help you with that; I don’t use helm…

If you want to open a note, doesn’t org-roam-find-file (C-c n f) or org-roam-insert (C-c n i) work for you?

They do - it’s the quick browsing through of many notes that I’m after. Many GUI apps allow for fast/efficient browsing with a sidebar. Think of the Preview sidebar in the MacOS Finder, for example. I’m trying to recreate that experience.

I don’t use MacOS so I don’t know exactly what you are after. However, did you try the hover over the nodes in the graph with the preview enabled? :slight_smile:

I’m surprised that this isn’t a feature in Roam yet! I can’t imagine switching to a 1 entry per file for dailies and not be able to quickly scan up/down through the days. It’s the equivalent of flipping through pages in a journal. I thought I’d be able to use ranger with preview, but org-roam seems to break that feature somehow.

Just as a follow up.
I think I have managed to open a dired on the side in a side window with this function.
The size, which side (right, left, top, buttom), etc. etc. can be personalized.
If you don’t want to automatically move to the side window, you can remove (select-window) function.

(defun my/dired-in-side-buffer ()
  "Display Dired in a side window."
  (interactive)
  (let* ((dir (read-directory-name "Direcotry: "))
         (buf (dired-noselect dir)))
    (select-window
     (display-buffer-in-side-window buf
                                   '((side . left)
                                     (window-width . 30)
                                     (slot . -1)
                                     (window-parameters . ((mode-line-format . none))))))))

1 Like

Thanks very much. I think this can also be a general solution for browsing files in a directory via Emacs dired-mode. But when I tried this, especially when I put the dired buffer as a side buffer, Emacs always splits the window when I navigates via the my/dired-display-next-file and my/dired-display-prev-file functions. Is there any suggestion to prevent this behaviour?

This is from 2 years ago; I now use something different:

(defvar my/dired-preview-temp-buffer nil)

;;;###autoload
(defun my/dired-preview ()
  "Preview a file/directory at point in Dired.
It's similar to `dired-display-file' but it checks if a buffer
visiting a file is live.  If not, it will be put into a temp file
to be removed."
  (when my/dired-preview-temp-buffer (kill-buffer my/dired-preview-temp-buffer))
  (setq my/dired-preview-temp-buffer nil)
  (let* ((file (dired-get-file-for-visit))
         (buf (find-buffer-visiting file)))
    (unless buf
      (setq buf (find-file-noselect file))
      (setq my/dired-preview-temp-buffer buf))
    ;; Check if a buffer visiting file is live; if not it's a temp buffer to be
    ;; deleted.
    (display-buffer buf t)))

;;;###autoload
(defun my/dired-next-line-display ()
  (interactive)(dired-next-line 1)(my/dired-preview))

;;;###autoload
(defun my/dired-previous-line-display ()
  (interactive)(dired-previous-line 1)(my/dired-preview))

Where the buffer is displayed depends on your configuration. Mine is vanilla and these functions are designed for my setup. If you are using Doom, you are likely to have very different behaviour – I believe by default a module called popup controls “window management”.

1 Like