emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#13251: closed (Wishlist: Add ability to set initia


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#13251: closed (Wishlist: Add ability to set initial buffer for new frames.)
Date: Wed, 02 Jan 2013 08:05:02 +0000

Your message dated Wed, 02 Jan 2013 09:03:18 +0100
with message-id <address@hidden>
and subject line Re: bug#13251: Wishlist: Add ability to set initial buffer for 
new frames.
has caused the debbugs.gnu.org bug report #13251,
regarding Wishlist: Add ability to set initial buffer for new frames.
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
13251: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13251
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Wishlist: Add ability to set initial buffer for new frames. Date: Sat, 22 Dec 2012 00:16:58 +0300
// 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.


--- End Message ---
--- Begin Message --- Subject: Re: bug#13251: Wishlist: Add ability to set initial buffer for new frames. Date: Wed, 02 Jan 2013 09:03:18 +0100
seems it works as I need. Thanks.

Bug closed.

Thanks, martin



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]