unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
@ 2012-12-21 21:16 Constantin Kulikov
  2012-12-21 21:30 ` Constantin Kulikov
  2012-12-22 15:42 ` martin rudalics
  0 siblings, 2 replies; 10+ messages in thread
From: Constantin Kulikov @ 2012-12-21 21:16 UTC (permalink / raw)
  To: 13251

[-- Attachment #1: Type: text/plain, Size: 2361 bytes --]

// Discussion in devel.
https://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00521.html
Short:
I want to be able to set buffer that will be displayed in window of newly
created frame.
I need it for my emacs package, that will save and restore some emacs state
including
last window configurations, opened and displayed buffers and such.
I tried this: add hook to `after-make-frame-functions'. Inside this hook I
do
`(switch-to-buffer <some-buffer>)' and frame is switched to that
<some-buffer> at first,
but after a short time it's switched to *scratch*.

The one way I found how to overcome this behaviour is by setting the
`initial-buffer-choice' in the `after-make-frame-functions' hook. One
drawback of this
approach is that it could only be set to name of file, t or nil and so
there is no way to
force switching to buffer without underlying file. This could be fixed int
server.el:1258
replacing

  (unless (or files commands)
        (if (stringp initial-buffer-choice)
        (find-file initial-buffer-choice)
          (switch-to-buffer (get-buffer-create "*scratch*")
                'norecord)))

to
          (unless (or files commands)
            (switch-to-buffer
             (get-buffer-create
              (or (cond
                   ((stringp initial-buffer-choice) (find-file-noselect
initial-buffer-choice))
                   ((functionp initial-buffer-choice) (funcall
initial-buffer-choice)))
                  "*scratch*"))
             'norecord))

and modified defcustom in in startup.el:41 would be:

(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. If function, switch to a buffer returned by this function.

A string value also causes emacsclient to open the specified file
or directory when no target file is specified."
  :type '(choice
      (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"
  :group 'initialization)

This code allows setting `initial-buffer-choice' to a function returning
needed buffer.

[-- Attachment #2: Type: text/html, Size: 3137 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  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
  1 sibling, 0 replies; 10+ messages in thread
From: Constantin Kulikov @ 2012-12-21 21:30 UTC (permalink / raw)
  To: 13251

[-- Attachment #1: Type: text/plain, Size: 2938 bytes --]

ah sorry, don't need that `or' in server.el:
          (unless (or files commands)
            (switch-to-buffer
             (get-buffer-create
              (cond
               ((stringp initial-buffer-choice) (find-file-noselect
initial-buffer-choice))
               ((functionp initial-buffer-choice) (funcall
initial-buffer-choice))
               (t "*scratch*")))
             'norecord))



2012/12/22 Constantin Kulikov <zxnotdead@gmail.com>

> // Discussion in devel.
> https://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00521.html
> Short:
> I want to be able to set buffer that will be displayed in window of newly
> created frame.
> I need it for my emacs package, that will save and restore some emacs
> state including
> last window configurations, opened and displayed buffers and such.
> I tried this: add hook to `after-make-frame-functions'. Inside this hook I
> do
> `(switch-to-buffer <some-buffer>)' and frame is switched to that
> <some-buffer> at first,
> but after a short time it's switched to *scratch*.
>
> The one way I found how to overcome this behaviour is by setting the
> `initial-buffer-choice' in the `after-make-frame-functions' hook. One
> drawback of this
> approach is that it could only be set to name of file, t or nil and so
> there is no way to
> force switching to buffer without underlying file. This could be fixed int
> server.el:1258
> replacing
>
>   (unless (or files commands)
>         (if (stringp initial-buffer-choice)
>         (find-file initial-buffer-choice)
>           (switch-to-buffer (get-buffer-create "*scratch*")
>                 'norecord)))
>
> to
>           (unless (or files commands)
>             (switch-to-buffer
>              (get-buffer-create
>               (or (cond
>                    ((stringp initial-buffer-choice) (find-file-noselect
> initial-buffer-choice))
>                    ((functionp initial-buffer-choice) (funcall
> initial-buffer-choice)))
>                   "*scratch*"))
>              'norecord))
>
> and modified defcustom in in startup.el:41 would be:
>
> (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. If function, switch to a buffer returned by this function.
>
> A string value also causes emacsclient to open the specified file
> or directory when no target file is specified."
>   :type '(choice
>       (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"
>   :group 'initialization)
>
> This code allows setting `initial-buffer-choice' to a function returning
> needed buffer.
>
>

[-- Attachment #2: Type: text/html, Size: 4068 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  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
  1 sibling, 1 reply; 10+ messages in thread
From: martin rudalics @ 2012-12-22 15:42 UTC (permalink / raw)
  To: Constantin Kulikov; +Cc: 13251

 > (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. If function, switch to a buffer returned by this function.

As for the last sentence I'd prefer "If it is a function, switch to the
buffer returned by that function."

 > A string value also causes emacsclient to open the specified file
 > or directory when no target file is specified."
 >   :type '(choice
 >       (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"

Too late for "23.1" use "24.4" instead.

 >   :group 'initialization)
 >
 > This code allows setting `initial-buffer-choice' to a function returning
 > needed buffer.

Could you please send us a patch based on these remarks (including the
change you sketched in your second mail)?

Thanks, martin





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  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
  0 siblings, 2 replies; 10+ messages in thread
From: Constantin Kulikov @ 2012-12-22 19:51 UTC (permalink / raw)
  To: martin rudalics; +Cc: 13251


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

Thanks for the tips.



2012/12/22 martin rudalics <rudalics@gmx.at>

> > (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. If function, switch to a buffer returned by this function.
>
> As for the last sentence I'd prefer "If it is a function, switch to the
> buffer returned by that function."
>
> > A string value also causes emacsclient to open the specified file
> > or directory when no target file is specified."
> >   :type '(choice
> >       (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"
>
> Too late for "23.1" use "24.4" instead.
>
> >   :group 'initialization)
> >
> > This code allows setting `initial-buffer-choice' to a function returning
> > needed buffer.
>
> Could you please send us a patch based on these remarks (including the
> change you sketched in your second mail)?
>
> Thanks, martin
>

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

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

=== modified file 'lisp/server.el'
--- lisp/server.el	2012-11-09 06:28:27 +0000
+++ lisp/server.el	2012-12-22 19:36:57 +0000
@@ -1256,12 +1256,18 @@
           (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)
+            (switch-to-buffer
+             (get-buffer-create
+              (cond
+               ((stringp initial-buffer-choice)
+                (find-file-noselect initial-buffer-choice))
+               ((functionp initial-buffer-choice)
+                (funcall initial-buffer-choice))
+               (t "*scratch*")))
+             'norecord))
 
           ;; 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-22 19:35:08 +0000
@@ -43,7 +43,7 @@
 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.
+buffer. If function, witch to a buffer returned by this function.
 
 A string value also causes emacsclient to open the specified file
 or directory when no target file is specified."
@@ -51,8 +51,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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  2012-12-22 19:51   ` Constantin Kulikov
@ 2012-12-22 20:18     ` Constantin Kulikov
  2012-12-23 10:14     ` martin rudalics
  1 sibling, 0 replies; 10+ messages in thread
From: Constantin Kulikov @ 2012-12-22 20:18 UTC (permalink / raw)
  To: martin rudalics; +Cc: 13251


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

argh. :( Sorry made a small typo in patch attached in previous message.



2012/12/22 Constantin Kulikov <zxnotdead@gmail.com>

> Thanks for the tips.
>
>
>
> 2012/12/22 martin rudalics <rudalics@gmx.at>
>
>> > (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. If function, switch to a buffer returned by this function.
>>
>> As for the last sentence I'd prefer "If it is a function, switch to the
>> buffer returned by that function."
>>
>> > A string value also causes emacsclient to open the specified file
>> > or directory when no target file is specified."
>> >   :type '(choice
>> >       (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"
>>
>> Too late for "23.1" use "24.4" instead.
>>
>> >   :group 'initialization)
>> >
>> > This code allows setting `initial-buffer-choice' to a function returning
>> > needed buffer.
>>
>> Could you please send us a patch based on these remarks (including the
>> change you sketched in your second mail)?
>>
>> Thanks, martin
>>
>
>

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

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

=== modified file 'lisp/server.el'
--- lisp/server.el	2012-11-09 06:28:27 +0000
+++ lisp/server.el	2012-12-22 19:36:57 +0000
@@ -1256,12 +1256,18 @@
           (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)
+            (switch-to-buffer
+             (get-buffer-create
+              (cond
+               ((stringp initial-buffer-choice)
+                (find-file-noselect initial-buffer-choice))
+               ((functionp initial-buffer-choice)
+                (funcall initial-buffer-choice))
+               (t "*scratch*")))
+             'norecord))
 
           ;; 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-22 20:09:27 +0000
@@ -43,7 +43,7 @@
 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.
+buffer. If function, switch to a buffer returned by this function.
 
 A string value also causes emacsclient to open the specified file
 or directory when no target file is specified."
@@ -51,8 +51,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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  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>
  1 sibling, 1 reply; 10+ messages in thread
From: martin rudalics @ 2012-12-23 10:14 UTC (permalink / raw)
  To: Constantin Kulikov; +Cc: 13251

 > Thanks for the tips.

Thanks for the patch.  Unfortunately, we are not yet done :-(

 > === modified file 'lisp/server.el'
 > --- lisp/server.el	2012-11-09 06:28:27 +0000
 > +++ lisp/server.el	2012-12-22 19:36:57 +0000
 > @@ -1256,12 +1256,18 @@
 >            (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)

Here we have to make sure that we do _not_ switch to *scratch* when
`initial-buffer-choice' is nil but show the initial start screen.

 > +            (switch-to-buffer
 > +             (get-buffer-create
 > +              (cond
 > +               ((stringp initial-buffer-choice)
 > +                (find-file-noselect initial-buffer-choice))
 > +               ((functionp initial-buffer-choice)
 > +                (funcall initial-buffer-choice))

Let's make sure that both `find-file-noselect' and the function called
via `initial-buffer-choice' really returned a live buffer.  So please
add a call to `buffer-live-p' for these cases.  Which also means that
Stefan's initial proposal for a let-bound `buf' is the better choice ;-)
(he's usually always right in these things).

 > +               (t "*scratch*")))
 > +             'norecord))
 >
 >            ;; 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-22 20:09:27 +0000
 > @@ -43,7 +43,7 @@
 >  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'.

I suppose this is no longer true.  Let's say "switch to a buffer
visiting the file or directory specified by the string" instead.

 >   If t, open the `*scratch*'
 > -buffer.

This should come after the function item.  Note that we are not overly
precise in the doc-string - any non-nil value of `initial-buffer-choice'
will show *scratch*.  But it's better to not tell that in the doc-string
so we have room for future changes - just like the one you proposed.

 > +buffer. If function, switch to a buffer returned by this function.

"If the value is a function, switch to the buffer returned by that
function." seems more precise here.

 >  A string value also causes emacsclient to open the specified file
 >  or directory when no target file is specified."
 > @@ -51,8 +51,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

And now comes the last problem.  The function `command-line-1' (in
startup.el) contains these lines:

     (when (eq initial-buffer-choice t)
       ;; When initial-buffer-choice equals t make sure that *scratch*
       ;; exists.
       (get-buffer-create "*scratch*"))

I'd remove them because we can handle them here:

     (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))))

If we allow `initial-buffer-choice' to specify a function, we have to
handle it here in the same way as in server.el.

martin





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Fwd: bug#13251: Wishlist: Add ability to set initial buffer for new frames.
       [not found]       ` <CAFkz2yrdFMbXSCknkhQZTmbMsYBWCAO9uOayun6BZT_LJdhrjw@mail.gmail.com>
@ 2012-12-23 17:04         ` Constantin Kulikov
  2012-12-24 18:05           ` martin rudalics
  0 siblings, 1 reply; 10+ messages in thread
From: Constantin Kulikov @ 2012-12-23 17:04 UTC (permalink / raw)
  To: 13251


[-- 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  2012-12-23 17:04         ` bug#13251: Fwd: " Constantin Kulikov
@ 2012-12-24 18:05           ` martin rudalics
  2012-12-24 19:37             ` Constantin Kulikov
  0 siblings, 1 reply; 10+ messages in thread
From: martin rudalics @ 2012-12-24 18:05 UTC (permalink / raw)
  To: Constantin Kulikov; +Cc: 13251

 > another attempt...

Committed as a combination of your previous and present patch.  Please
have a look.

Thanks, martin





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  2012-12-24 18:05           ` martin rudalics
@ 2012-12-24 19:37             ` Constantin Kulikov
  2013-01-02  8:03               ` martin rudalics
  0 siblings, 1 reply; 10+ messages in thread
From: Constantin Kulikov @ 2012-12-24 19:37 UTC (permalink / raw)
  To: martin rudalics; +Cc: 13251

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

seems it works as I need. Thanks.


2012/12/24 martin rudalics <rudalics@gmx.at>

> > another attempt...
>
> Committed as a combination of your previous and present patch.  Please
> have a look.
>
> Thanks, martin
>

[-- Attachment #2: Type: text/html, Size: 548 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#13251: Wishlist: Add ability to set initial buffer for new frames.
  2012-12-24 19:37             ` Constantin Kulikov
@ 2013-01-02  8:03               ` martin rudalics
  0 siblings, 0 replies; 10+ messages in thread
From: martin rudalics @ 2013-01-02  8:03 UTC (permalink / raw)
  To: Constantin Kulikov; +Cc: 13251-done

> seems it works as I need. Thanks.

Bug closed.

Thanks, martin






^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-01-02  8:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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         ` bug#13251: Fwd: " Constantin Kulikov
2012-12-24 18:05           ` martin rudalics
2012-12-24 19:37             ` Constantin Kulikov
2013-01-02  8:03               ` martin rudalics

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).