2

I have emacs configured to start org-agenda automatically and show it instead of *scratch*. Like this:

(add-hook (quote after-init-hook)
              (lambda ()
              ;; ...
              (org-agenda-list 1)
              (delete-other-windows)))

However, the same trick don't works with emacsclient, the org-agenda buffer is there in the buffer list, but the *scratch* buffer is shown instead.

7

Check the manual for initial-buffer-choice

If non-nil, this variable is a string that specifies a file or directory for Emacs to display after starting up, instead of the startup screen. If its value is a function, Emacs calls that function which must return a buffer which is then displayed. If its value is t, Emacs displays the *scratch* buffer.

The web manual may not say it, but C-h v for me clarifies that this also affects emacsclient use with no target file.

So you can just set this to a function that returns the org agenda buffer.

(setq initial-buffer-choice '(lambda () (get-buffer org-agenda-buffer-name)))

Notice that, with this solution, you don't need the after-init-hook. Just call org-agenda-list sometime in your init file to ensure the buffer is available for the initial choice.

  • if no org-agenda-list buffer exists, it opens *scratch* anyway, so, this solution works well for me! – shackra Nov 29 '14 at 3:19
2

The simple solution I have, is calling emacsclient plus some lisp evaluation. For example: emacsclient -c -e '(switch-to-buffer "init.el")'

You'll have to replace init.el by the buffer you want to open. That one suppose the init.el buffer was already launched and exists with the emacs server.

EDIT

Now, if using emacsclient, you want to launch the org-agenda-list function: emacsclient -c -e '(org-agenda-list)'

  • This is good, but it creates the buffer if it doesn't exists, but just one *Org Agenda* buffer will be created don't matter how many times org-agenda-list is executed, so this may not be a big deal after all. – shackra Nov 13 '14 at 0:23
  • @JorgeArayaNavarro I thought the org-agenda-list buffer was already launched with the emacs server. Check my edits. – Nsukami _ Nov 13 '14 at 1:09
1

Try adding a function to the after-make-frame-functions variable.

after-make-frame-functions is a variable defined in `frame.el'.

Documentation:
Functions to run after a frame is created.
The functions are run with one arg, the newly created frame.
  • Does that variable affects the C-x 5 2 command too? I don't need to watch the org-agenda on those situations where I'm creating a new frame from another frame – shackra Nov 12 '14 at 22:40
  • I assume it does affect C-x 5 2 as well, yes. You may want to look for other options then. – nanny Nov 13 '14 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.