diff options
author | Constantin Kulikov <zxnotdead@gmail.com> | 2012-12-24 18:49:19 +0100 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2012-12-24 18:49:19 +0100 |
commit | dc646358274fbfdab6ef3dfb7717bc4a52f607f3 (patch) | |
tree | 71e4f0d5881561ae18ee4a856ba8a2dd9d84f3a0 /lisp/startup.el | |
parent | c1860cdc02404d84e7f29d206b799031190a794e (diff) | |
download | emacs-dc646358274fbfdab6ef3dfb7717bc4a52f607f3.tar.gz |
Allow function as value of initial-buffer-choice (Bug#13251).
* startup.el (initial-buffer-choice): Allow function as value
(Bug#13251).
(command-line-1): Handle case where initial-buffer-choice
specifies a function.
* server.el (server-execute): Handle case where
initial-buffer-choice specifies a function.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r-- | lisp/startup.el | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/startup.el b/lisp/startup.el index ec6d45a294d..6a207bab0bf 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -41,9 +41,10 @@ (defcustom initial-buffer-choice nil "Buffer to show after starting Emacs. If the value is nil and `inhibit-startup-screen' is nil, show the -startup screen. If the value is a string, visit the specified file -or directory using `find-file'. If t, open the `*scratch*' -buffer. +startup screen. If the value is a string, switch to a buffer +visiting the file or directory specified by that string. If the +value is a function, switch to the buffer returned by that +function. If t, open the `*scratch*' buffer. A string value also causes emacsclient to open the specified file or directory when no target file is specified." @@ -51,8 +52,9 @@ or directory when no target file is specified." (const :tag "Startup screen" nil) (directory :tag "Directory" :value "~/") (file :tag "File" :value "~/.emacs") + (function :tag "Function") (const :tag "Lisp scratch buffer" t)) - :version "23.1" + :version "24.4" :group 'initialization) (defcustom inhibit-startup-screen nil @@ -2323,10 +2325,14 @@ A fancy display is used on graphic displays, normal otherwise." (set-buffer-modified-p nil)))) (when initial-buffer-choice - (cond ((eq initial-buffer-choice t) - (switch-to-buffer (get-buffer-create "*scratch*"))) - ((stringp initial-buffer-choice) - (find-file initial-buffer-choice)))) + (let ((buf + (cond ((stringp initial-buffer-choice) + (find-file-noselect initial-buffer-choice)) + ((functionp initial-buffer-choice) + (funcall initial-buffer-choice))))) + (switch-to-buffer + (if (buffer-live-p buf) buf (get-buffer-create "*scratch*")) + 'norecord))) (if (or inhibit-startup-screen initial-buffer-choice |