mu4e window shows strange behaviour on startup

51 views
Skip to first unread message

nils.s...@gmail.com

unread,
Feb 2, 2017, 7:48:43 AM2/2/17
to mu-discuss
Hi there,

I really appreciate the activity of this list. I find so many solutions to problems I discover. Thats great.
But unfortunately there is one more, which I cannot solve myself. I would love emacs to show the org mode agenda and the mu4e main buffer on startup.
To realise this I found the following function:

;; Show the org-mode agenda and when emacs starts
;; layout definition
(defun my-startup-layout ()
 
(interactive)
 
(delete-other-windows)
 
(split-window-horizontally) ;; -> |
 
(next-multiframe-window)
 
(org-agenda-list)
 
(mu4e)
)

;; execute the layout
(my-startup-layout )



So far, so well. This works perfectly. But I also would like the point to be in the org-agenda buffer. To do this i add at the end of the function "my-startup-layout"  the line "(next-multiframe-window)". But this causes a really strange and unexpected behaviour on startup. Emacs starts with two windows ( horizontally splitted), in the left one is the scratch buffer and the right one the mu4e main buffer.
And I do not understand why?
Can someone help fix this?
This would be great.

Thanks,
Nils

John Mastro

unread,
Mar 28, 2017, 7:48:55 PM3/28/17
to mu-discuss
Hi Nils,

> So far, so well. This works perfectly. But I also would like the point
> to be in the org-agenda buffer. To do this i add at the end of the
> function "my-startup-layout" the line "(next-multiframe-window)". But
> this causes a really strange and unexpected behaviour on
> startup. Emacs starts with two windows ( horizontally splitted), in
> the left one is the scratch buffer and the right one the mu4e main
> buffer.
> And I do not understand why?
> Can someone help fix this?
> This would be great.

I think this is because org-agenda-list has its own logic for splitting
the window.

There is probably a better way to do this, but something along these
lines should work, by being explicit about which window each of the
buffers is placed in:

(defun my-startup-layout ()
  (interactive)
  (org-agenda-list)
  (mu4e)
  (delete-other-windows)
  (set-window-buffer (selected-window)
    "*Org Agenda*")
  (set-window-buffer (split-window-horizontally)
    "*mu4e*"))

Hope that helps

        John

nils.s...@gmail.com

unread,
May 3, 2017, 11:20:52 AM5/3/17
to mu-discuss
Hi John,

I am really happy about your answer. I just tried it, but I have to admit, that it does not work.
I like the idea to use the function set-window-buffer very much, but unfortunately it cannot handle mu4e buffers.
Because mu4e buffers are not listed in the buffer list.
Consequently the debugger produces the following error messages:

Debugger entered--Lisp error: (wrong-type-argument bufferp nil)
  set-window-buffer(#<window 8 on *Backtrace*> "*mu4e*")
  my-startup-layout()
  eval-buffer(#<buffer  *load*> nil "/home/walt3rsalva/.emacs" nil t)  ; Reading at buffer position 21440
  load-with-code-conversion("/home/walt3rsalva/.emacs" "/home/walt3rsalva/.emacs" t t)
  load("~/.emacs" t t)
  #[0 " \205\266

I can change the buffer name *mu4e* to *mu4e-main*. But this does not help either, because there is mu4e at all on the buffer list.
I have to admit that I do not understand how mu4e handles its buffers. It seems to me  that they are no typical emacs buffers, which makes  thinks complicated.
Do you have any other idea?
Thanks a lot for your help,
Nils

nils.s...@gmail.com

unread,
May 9, 2017, 4:41:34 AM5/9/17
to mu-discuss
Hi everybody,

I finally found a solution to my problem.
First of all, John is completely right, when he says that the function "org-agenda-list" has its own logic to split the windows.
But not only "org-agenda-list", but also "mu4e" has its own logic, when it is called.
A call of "mu4e" sets the buffer " *mu4e-main*"  to be the current-buffer. And it does it probably not only once. ( Note the blank in front of the buffer-name, it 
hides the buffer.) Thus, calling "mu4e" and "org-agenda-list" plus the regular functions to control windows, like "switch-to-buffer", "set-window-buffer", "split-window-...", causes a mixture of window operation which is really hard to disentangle.
To avoid this trouble, I decided to use the following "startup"-function:
(defun my-startup-layout ()
 
(interactive)
 
(mu4e)
 
(sit-for 1)
 
(org-agenda-list))

A call of the function "sit-for" produces a short break after loading mu4e. This avoids the conflict with "mu4e" setting " *mu4e-main*" the current-buffer. After the short break I call the function "org-agenda-list" which splits the windows according to its own logic and then selects the *Org Agenda* buffer, which is exactly what I want.

Once more, thanks for your help.
Nils
Reply all
Reply to author
Forward
0 new messages