aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorConstantin Kulikov2012-12-24 18:49:19 +0100
committerMartin Rudalics2012-12-24 18:49:19 +0100
commitdc646358274fbfdab6ef3dfb7717bc4a52f607f3 (patch)
tree71e4f0d5881561ae18ee4a856ba8a2dd9d84f3a0 /lisp
parentc1860cdc02404d84e7f29d206b799031190a794e (diff)
downloademacs-dc646358274fbfdab6ef3dfb7717bc4a52f607f3.tar.gz
emacs-dc646358274fbfdab6ef3dfb7717bc4a52f607f3.zip
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')
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/server.el17
-rw-r--r--lisp/startup.el22
3 files changed, 34 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1438a230550..2181a6dde7e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12012-12-24 Constantin Kulikov <zxnotdead@gmail.com> (tiny change)
2
3 * startup.el (initial-buffer-choice): Allow function as value
4 (Bug#13251).
5 (command-line-1): Handle case where initial-buffer-choice
6 specifies a function.
7 * server.el (server-execute): Handle case where
8 initial-buffer-choice specifies a function.
9
12012-12-24 Lars Ingebrigtsen <larsi@gnus.org> 102012-12-24 Lars Ingebrigtsen <larsi@gnus.org>
2 11
3 * mail/smtpmail.el (smtpmail-try-auth-method): Refactored out into 12 * mail/smtpmail.el (smtpmail-try-auth-method): Refactored out into
diff --git a/lisp/server.el b/lisp/server.el
index c78e3e376aa..59f75722ccb 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1256,12 +1256,17 @@ The following commands are accepted by the client:
1256 (mapc 'funcall (nreverse commands)) 1256 (mapc 'funcall (nreverse commands))
1257 1257
1258 ;; If we were told only to open a new client, obey 1258 ;; If we were told only to open a new client, obey
1259 ;; `initial-buffer-choice' if it specifies a file. 1259 ;; `initial-buffer-choice' if it specifies a file
1260 (unless (or files commands) 1260 ;; or a function.
1261 (if (stringp initial-buffer-choice) 1261 (unless (or files commands)
1262 (find-file initial-buffer-choice) 1262 (let ((buf
1263 (switch-to-buffer (get-buffer-create "*scratch*") 1263 (cond ((stringp initial-buffer-choice)
1264 'norecord))) 1264 (find-file-noselect initial-buffer-choice))
1265 ((functionp initial-buffer-choice)
1266 (funcall initial-buffer-choice)))))
1267 (switch-to-buffer
1268 (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))
1269 'norecord)))
1265 1270
1266 ;; Delete the client if necessary. 1271 ;; Delete the client if necessary.
1267 (cond 1272 (cond
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 @@
41(defcustom initial-buffer-choice nil 41(defcustom initial-buffer-choice nil
42 "Buffer to show after starting Emacs. 42 "Buffer to show after starting Emacs.
43If the value is nil and `inhibit-startup-screen' is nil, show the 43If the value is nil and `inhibit-startup-screen' is nil, show the
44startup screen. If the value is a string, visit the specified file 44startup screen. If the value is a string, switch to a buffer
45or directory using `find-file'. If t, open the `*scratch*' 45visiting the file or directory specified by that string. If the
46buffer. 46value is a function, switch to the buffer returned by that
47function. If t, open the `*scratch*' buffer.
47 48
48A string value also causes emacsclient to open the specified file 49A string value also causes emacsclient to open the specified file
49or directory when no target file is specified." 50or directory when no target file is specified."
@@ -51,8 +52,9 @@ or directory when no target file is specified."
51 (const :tag "Startup screen" nil) 52 (const :tag "Startup screen" nil)
52 (directory :tag "Directory" :value "~/") 53 (directory :tag "Directory" :value "~/")
53 (file :tag "File" :value "~/.emacs") 54 (file :tag "File" :value "~/.emacs")
55 (function :tag "Function")
54 (const :tag "Lisp scratch buffer" t)) 56 (const :tag "Lisp scratch buffer" t))
55 :version "23.1" 57 :version "24.4"
56 :group 'initialization) 58 :group 'initialization)
57 59
58(defcustom inhibit-startup-screen nil 60(defcustom inhibit-startup-screen nil
@@ -2323,10 +2325,14 @@ A fancy display is used on graphic displays, normal otherwise."
2323 (set-buffer-modified-p nil)))) 2325 (set-buffer-modified-p nil))))
2324 2326
2325 (when initial-buffer-choice 2327 (when initial-buffer-choice
2326 (cond ((eq initial-buffer-choice t) 2328 (let ((buf
2327 (switch-to-buffer (get-buffer-create "*scratch*"))) 2329 (cond ((stringp initial-buffer-choice)
2328 ((stringp initial-buffer-choice) 2330 (find-file-noselect initial-buffer-choice))
2329 (find-file initial-buffer-choice)))) 2331 ((functionp initial-buffer-choice)
2332 (funcall initial-buffer-choice)))))
2333 (switch-to-buffer
2334 (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))
2335 'norecord)))
2330 2336
2331 (if (or inhibit-startup-screen 2337 (if (or inhibit-startup-screen
2332 initial-buffer-choice 2338 initial-buffer-choice