From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Constantin Kulikov Newsgroups: gmane.emacs.bugs Subject: bug#13251: Wishlist: Add ability to set initial buffer for new frames. Date: Sat, 22 Dec 2012 00:16:58 +0300 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d0442838a2d455f04d1635e08 X-Trace: ger.gmane.org 1356124685 19714 80.91.229.3 (21 Dec 2012 21:18:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Dec 2012 21:18:05 +0000 (UTC) To: 13251@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 21 22:18:19 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tm9yz-0002UN-At for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2012 22:18:17 +0100 Original-Received: from localhost ([::1]:59027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm9yl-0002sf-9u for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2012 16:18:03 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm9yc-0002sW-9i for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2012 16:18:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tm9yV-0008PV-Ih for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2012 16:17:54 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm9yV-0008PR-FO for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2012 16:17:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Tm9yk-0007Lo-DA for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2012 16:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Constantin Kulikov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Dec 2012 21:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13251 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.135612465228214 (code B ref -1); Fri, 21 Dec 2012 21:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Dec 2012 21:17:32 +0000 Original-Received: from localhost ([127.0.0.1]:54661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tm9yF-0007L0-PT for submit@debbugs.gnu.org; Fri, 21 Dec 2012 16:17:32 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47472) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tm9yD-0007Ks-1V for submit@debbugs.gnu.org; Fri, 21 Dec 2012 16:17:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tm9xt-0008DR-CX for submit@debbugs.gnu.org; Fri, 21 Dec 2012 16:17:13 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:40066) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm9xt-0008DN-8l for submit@debbugs.gnu.org; Fri, 21 Dec 2012 16:17:09 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm9xo-0002Nc-PQ for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2012 16:17:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tm9xj-0008AW-V1 for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2012 16:17:04 -0500 Original-Received: from mail-we0-f180.google.com ([74.125.82.180]:44794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm9xj-00089z-Kh for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2012 16:16:59 -0500 Original-Received: by mail-we0-f180.google.com with SMTP id t57so2387814wey.11 for ; Fri, 21 Dec 2012 13:16:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=j97R9WL/cRL3hbK/y8vpeAUXIHKk/3lzpP0lqtmgnR0=; b=kpoeZRGZDt69laykklWlm4JfyQBftJuIZVKaLvweUb26lOuQlJ80M35BtC2S1UxnnN o81q9Ups9D2aa5XSYnIwl3xYuOtZW2wj2JhFszy4R53Gt78jfQFNHv1ZDGKi++hVkUcZ P2aOxNczvWbmrGDJRO1iSWn3y/DQR5Tc/72SAiYibn7/v36nfEaaynzHdgSSRIhrkjlb kUOPccx0hE2c3mn6ZwTU+3vNXpSdmNHLFAfYRux67DUlc4C8DNRwHWJIl2BeVRCVUkP1 CgtqX+TOTMqBWoVYYC9WoZ+7UUwv5SY6CmqgzdZm8fPOA3M00RuHzhtTiLpDdEf98gzi VfxQ== Original-Received: by 10.180.82.69 with SMTP id g5mr25738724wiy.21.1356124618834; Fri, 21 Dec 2012 13:16:58 -0800 (PST) Original-Received: by 10.217.47.138 with HTTP; Fri, 21 Dec 2012 13:16:58 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:68874 Archived-At: --f46d0442838a2d455f04d1635e08 Content-Type: text/plain; charset=UTF-8 // 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 )' and frame is switched to that 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. --f46d0442838a2d455f04d1635e08 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
// 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 ne= wly created frame.
I need it for my emacs package, that will save and re= store 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 hoo= k I do
`(switch-to-buffer <some-buffer>)' and frame is switche= d 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 set= ting the
`initial-buffer-choice' in the `after-make-frame-functions&= #39; hook. One drawback of this
approach is that it could onl= y 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
replacin= g

=C2=A0 (unless (or files commands)
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (if (stringp initial-buffer-choice)=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (find-file initial-buffer-choice)=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (switch-to-buffer (get-= buffer-create "*scratch*")
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 'norecord)))
to
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unless (= or files commands)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (switch-to-buffer
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (get-buffer-create
=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (or (cond=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((stringp initial-buffer-choice) (find= -file-noselect initial-buffer-choice))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((functionp initial-buffer-choice) (funca= ll initial-buffer-choice)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "*scratch= *"))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 'norecord))

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

(defcustom initial-buffer-choice nil
=C2=A0 "Buffer = to show after starting Emacs.
If the value is nil and `inhibit-startup-s= creen' is nil, show the
startup screen.=C2=A0 If the value is a stri= ng, visit the specified file
or directory using `find-file'.=C2=A0 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 dir= ectory when no target file is specified."
=C2=A0 :type '(choice
=C2=A0=C2=A0=C2=A0 =C2=A0 (const=C2=A0=C2=A0= =C2=A0=C2=A0 :tag "Startup screen" nil)
=C2=A0=C2=A0=C2=A0 =C2= =A0 (directory :tag "Directory" :value "~/")
=C2=A0= =C2=A0=C2=A0 =C2=A0 (file=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :tag "File&quo= t; :value "~/.emacs")
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (function=C2=A0 :tag "Function")=C2=A0=C2=A0=C2=A0 =C2=A0 (const=C2=A0=C2=A0=C2=A0=C2=A0 :tag "Lisp = scratch buffer" t))
=C2=A0 :version "23.1"
=C2=A0 :gro= up 'initialization)

This code allows setting `initial-buffer-cho= ice' to a function returning needed buffer.

--f46d0442838a2d455f04d1635e08--