all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Constantin Kulikov <zxnotdead@gmail.com>
To: 13251@debbugs.gnu.org
Subject: bug#13251: Fwd: bug#13251: Wishlist: Add ability to set initial buffer for new frames.
Date: Sun, 23 Dec 2012 20:04:24 +0300	[thread overview]
Message-ID: <CAFkz2yr-D2LmoKwD8KM+qPrZTw50bUvnv9+h5qtpsqSVrc21QA@mail.gmail.com> (raw)
In-Reply-To: <CAFkz2yrdFMbXSCknkhQZTmbMsYBWCAO9uOayun6BZT_LJdhrjw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 247 bytes --]

---------- Forwarded message ----------
From: Constantin Kulikov <zxnotdead@gmail.com>
Date: 2012/12/23
Subject: Re: bug#13251: Wishlist: Add ability to set initial buffer for new
frames.
To: martin rudalics <rudalics@gmx.at>


another attempt...

[-- Attachment #1.2: Type: text/html, Size: 504 bytes --]

[-- Attachment #2: initial-buffer-choice-as-function.patch --]
[-- Type: application/octet-stream, Size: 3633 bytes --]

=== modified file 'lisp/server.el'
--- lisp/server.el	2012-11-09 06:28:27 +0000
+++ lisp/server.el	2012-12-23 16:55:05 +0000
@@ -1256,12 +1256,21 @@
           (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)))))
+              (cond ((buffer-live-p buf)
+                     (switch-to-buffer buf 'norecord))
+                    ((and (eq nil buf) (eq nil inhibit-startup-screen))
+                     (display-startup-screen))
+                    (t (switch-to-buffer
+                        (get-buffer-create "*scratch*"))))))
 
           ;; Delete the client if necessary.
           (cond

=== modified file 'lisp/startup.el'
--- lisp/startup.el	2012-12-01 02:08:30 +0000
+++ lisp/startup.el	2012-12-23 15:16:26 +0000
@@ -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 @@
 	  (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
@@ -2308,11 +2310,6 @@
 	    ;; abort later.
 	    (unless (frame-live-p (selected-frame)) (kill-emacs nil))))))
 
-    (when (eq initial-buffer-choice t)
-      ;; When initial-buffer-choice equals t make sure that *scratch*
-      ;; exists.
-      (get-buffer-create "*scratch*"))
-
     ;; If *scratch* exists and is empty, insert initial-scratch-message.
     ;; Do this before switching to *scratch* below to handle bug#9605.
     (and initial-scratch-message
@@ -2323,10 +2320,15 @@
 	     (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)))))
+        (if (buffer-live-p buf)
+            (switch-to-buffer buf 'norecord)
+          (switch-to-buffer (get-buffer-create "*scratch*") 'norecord))))
 
     (if (or inhibit-startup-screen
 	    initial-buffer-choice


  parent reply	other threads:[~2012-12-23 17:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 21:16 bug#13251: Wishlist: Add ability to set initial buffer for new frames Constantin Kulikov
2012-12-21 21:30 ` Constantin Kulikov
2012-12-22 15:42 ` martin rudalics
2012-12-22 19:51   ` Constantin Kulikov
2012-12-22 20:18     ` Constantin Kulikov
2012-12-23 10:14     ` martin rudalics
     [not found]       ` <CAFkz2yrdFMbXSCknkhQZTmbMsYBWCAO9uOayun6BZT_LJdhrjw@mail.gmail.com>
2012-12-23 17:04         ` Constantin Kulikov [this message]
2012-12-24 18:05           ` martin rudalics
2012-12-24 19:37             ` Constantin Kulikov
2013-01-02  8:03               ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFkz2yr-D2LmoKwD8KM+qPrZTw50bUvnv9+h5qtpsqSVrc21QA@mail.gmail.com \
    --to=zxnotdead@gmail.com \
    --cc=13251@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.