rougier / mu4e-dashboard

A dashboard for mu4e (mu for emacs)
GNU General Public License v3.0
467 stars 43 forks source link

open the [inbox,drafts...etc] in a splitted buffer on the right #15

Open kebairia opened 3 years ago

kebairia commented 3 years ago

actually this is a question and not an issue I'm using the sidebar dashboard now , but when i want to see the inbox for example, it appears in a whole buffer by itself. How can i make the result appears in a splitted buffer on the right like the image on the README?

rougier commented 3 years ago

I've the same problem and did not find a proper automatic solution. What I do is to first split the window, load the dashboard on the right and start mu4e on the left and open one bookmarks. The dashboard will then works accordingly and updare the left window. This can probably be automatized but I'm not sure of the best way to do that.

cmacrae commented 3 years ago

I've implemented a rough draft of what I think should fit the desired functionality here in #18 :)

titaniumbones commented 2 years ago

I'm not sure but I think my issue #36 is a duplicate, so I'll put my ad-hoc solution here. To fix this for myself -- that is, with no flexibility for other people's needs -- I just rewrote the :follow function, factoring out some otherwise-repeated code at the same time:

(defun mu4e-dashboard-open-query-to-side (query)
    "opinionated function that will open mu buffers to the side."
    (when (one-window-p)
      (split-window-horizontally 50))
    (other-window 1)
    (let ((mubuffer (or (get-buffer "*mu4e-headers*") (get-buffer "*mu4e-main*"))))
      (if mubuffer (switch-to-buffer mubuffer)
        (mu4e))
      (mu4e-headers-search query)))

(defun mwp/mu4e-dashboard-follow-mu4e-link (path)
  "Process a mu4e link with path PATH.

PATH shall be of the form [[mu4e:query|fmt|limit][(---------)]].
If FMT is not specified or is nil, clicking on the link calls
mu4e with the specified QUERY (with or without the given
LIMIT).  If FMT is specified, the description of the link is
updated with the QUERY count formatted using the provided
format (for example \"%4d\")."
  (let* ((link    (org-element-context))
         (query   (string-trim (nth 0 (split-string path "[]|]"))))
         (fmt     (nth 1 (split-string path "[]|]")))
         (count   (nth 2 (split-string path "[]|]"))))
    (cond
     ;; Regular query without limit
     ((and (not fmt) (not count))
      (mu4e-dashboard-open-query-to-side query))

     ;; Regular query with limit
     ((and count (> (length count) 0))
      (let ((mu4e-headers-results-limit (string-to-number count)))
        (mu4e-dashboard-open-query-to-side query)))

     ;; Query count and link description update
     ((and fmt (> (length fmt) 0))
      (mu4e-dashboard-update-link link)))))

(org-link-set-parameters
 mu4e-dashboard-link-name
 :follow #'mwp/mu4e-dashboard-follow-mu4e-link)

I don't know if that's helpful or not. I suppose something like org-sidebar or what @cmacrae has done would be better, in any case.

rougier commented 2 years ago

To do more or less the same effect, I open the dashboard on a side window and I make it dedicated such that when a link is followed, Emacs has no other choice but to use the other window. Might be a bit simpler, no?