Subject: bug#23509: 24.4; initial-buffer-choice bug with zero-argument lambda

From: John Mastro <[email-masked]>
Date: Tue, 10 May 2016 13:07:30 -0700

Alfonsogonzalez, Ernesto (GE Digital) <[email-masked]> wrote:

> 1. create file /tmp/emacs-bug.el with contents
>
> (setq initial-buffer-choice
>       ;"~/";;works
>       (lambda ()
>         '(call-interactively 'org-agenda-list)
>         "*Org Agenda*"
>         "~/");;doesn't work, opens scratch buffer
>       )
>
> 2. emacs -Q -l /tmp/emacs-bug.el
> 3. scratch buffer opens.
>
> According to docs,
>
> If the value is nil and `inhibit-startup-screen' is nil, show the
> startup screen.  If the value is a string, switch to a buffer
> visiting the file or directory that the string specifies.  If the
> value is a function, call it with no arguments and switch to the buffer
> that it returns.  If t, open the `*scratch*' buffer.
> If the value is nil and `inhibit-startup-screen' is nil, show the
> startup screen.  If the value is a string, switch to a buffer
> visiting the file or directory that the string specifies.  If the
> value is a function, call it with no arguments and switch to the buffer
> that it returns.  If t, open the `*scratch*' buffer.

The docs you quoted say "if the value is a function, call it with no
arguments and switch to the buffer that it returns", but your function
does not return a buffer (it returns the string "~/").

I'm not sure what your ultimate intent was. However, if you're trying to
run `org-agenda-list' but show a buffer visiting your home directory,
maybe this will help:

(setq initial-buffer-choice
      (lambda ()
        (org-agenda-list)
        (find-file "~/")))

The difference is that `find-file' visits "~/" and returns a buffer. I
omitted the "*Org Agenda*" line from your example because it has no
effect.

-- 
john