Commit dc646358 authored by Constantin Kulikov's avatar Constantin Kulikov Committed by Martin Rudalics
Browse files

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.
parent c1860cdc
......@@ -39,6 +39,9 @@ if there is one.
This unfinished feature was introduced by accident in Emacs 23.1;
simply disabling Transient Mark mode does the same thing.
** `initial-buffer-choice' can now specify a function to set up the
initial buffer.
** ACL support has been added.
+++
*** Emacs preserves the ACL entries of files when backing up.
......
2012-12-24 Constantin Kulikov <zxnotdead@gmail.com> (tiny change)
* 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.
2012-12-24 Lars Ingebrigtsen <larsi@gnus.org>
* mail/smtpmail.el (smtpmail-try-auth-method): Refactored out into
......
......@@ -1256,12 +1256,17 @@ The following commands are accepted by the client:
(mapc 'funcall (nreverse commands))
;; If we were told only to open a new client, obey
;; `initial-buffer-choice' if it specifies a file.
(unless (or files commands)
(if (stringp initial-buffer-choice)
(find-file initial-buffer-choice)
(switch-to-buffer (get-buffer-create "*scratch*")
'norecord)))
;; `initial-buffer-choice' if it specifies a file
;; or a function.
(unless (or files commands)
(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)))
;; Delete the client if necessary.
(cond
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment