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

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