From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: display-buffer-alist simplifications Date: Fri, 05 Aug 2011 13:48:07 -0400 Message-ID: <87mxfnn414.fsf@stupidchicken.com> References: <87mxgem09k.fsf@stupidchicken.com> <4E2A7EBD.7050300@gmx.at> <87livooqt6.fsf@stupidchicken.com> <4E2B158B.1080101@gmx.at> <87wrf8iyse.fsf@stupidchicken.com> <4E2BEED2.5040608@gmx.at> <8739hvu6lh.fsf@stupidchicken.com> <4E2C50E6.3020103@gmx.at> <878vrnweju.fsf@stupidchicken.com> <4E2D34D7.4040002@gmx.at> <87r55cjvef.fsf@stupidchicken.com> <87sjpsnerd.fsf@mail.jurta.org> <4E355D2C.40709@gmx.at> <87k4axzg7j.fsf@mail.jurta.org> <87oc092gy0.fsf@stupidchicken.com> <4E380897.5000406@gmx.at> <871ux2nsrw.fsf@stupidchicken.com> <4E3AA5DA.8030403@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1312566499 19519 80.91.229.12 (5 Aug 2011 17:48:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 5 Aug 2011 17:48:19 +0000 (UTC) Cc: Juri Linkov , emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 05 19:48:15 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QpOVL-0006Z8-2l for ged-emacs-devel@m.gmane.org; Fri, 05 Aug 2011 19:48:15 +0200 Original-Received: from localhost ([::1]:35295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpOVK-0004td-H5 for ged-emacs-devel@m.gmane.org; Fri, 05 Aug 2011 13:48:14 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:43200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpOVI-0004tY-86 for emacs-devel@gnu.org; Fri, 05 Aug 2011 13:48:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpOVG-0008Fn-Ut for emacs-devel@gnu.org; Fri, 05 Aug 2011 13:48:12 -0400 Original-Received: from vm-emlprdomr-03.its.yale.edu ([130.132.50.144]:57255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpOVG-0008Fj-Rl for emacs-devel@gnu.org; Fri, 05 Aug 2011 13:48:10 -0400 Original-Received: from furball ([128.36.14.32]) (authenticated bits=0) by vm-emlprdomr-03.its.yale.edu (8.14.4/8.14.4) with ESMTP id p75Hm75X029385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 5 Aug 2011 13:48:08 -0400 In-Reply-To: <4E3AA5DA.8030403@gmx.at> (martin rudalics's message of "Thu, 04 Aug 2011 15:59:54 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Scanned-By: MIMEDefang 2.71 on 130.132.50.144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 130.132.50.144 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:142905 Archived-At: martin rudalics writes: >> We can specify that these old variables override the new behavior, >> i.e. `display-buffer-fallback-alist' only applies to buffers not >> matching `special-display-buffer-names'. > > In Emacs 23 a user can specify that a buffer shall be displayed in the > selected window by adding its name to `same-window-buffer-names'. An > application can override the user by binding `same-window-buffer-names' > temporarily to nil. We have to offer a similar feature in Emacs 24. > > Currently this can be done by setting `display-buffer-alist' from > `same-window-buffer-names' via `display-buffer-alist-set'. But how > would we do that with `display-buffer-fallback-alist'? IIUC, the intention of same-window-buffer-names is to specify that such buffers should appear in the "same" window. But if the argument to display-buffer specifies some other method for displaying the buffer, Emacs should obey that argument rather than same-window-buffer-names. So, this can be handled by (setq display-buffer-fallback-alist '("\\*\\(shell\\|unsent mail\\|mail\\|inferior-lisp\\|ielm\\)\\*" (display-buffer-method reuse-window same-frame) (reuse-window-window same))) Just to be sure we are one the same page, here is how I imagine the system would work: - "Display specifiers" are cons cells (VAR . VALUE). For example, (reuse-window-window other) means that when Emacs is trying to reuse a window, it must use a window other than the selected one. - `display-buffer-method' is a special display specifier. Its VALUE is a list of "display-methods", one of `reuse-window', `pop-up-window', etc., or a "macro specifier" (any symbol except the reserved symbols `reuse-window' etc). (I'll use the word "macro" for now, but we might want to pick another word since "macro" can be confused with keyboard macros.) - `display-buffer-alist' is an alist that maps a matcher (regexp, label, or matcher function) to an alist of display specifiers. - `display-buffer-fallback-alist' is an alist of display specifiers. - `display-buffer-macro-specifiers' is an alist that maps a "macro specifier" to an alist of display specifiers. It must include a `display-buffer-method' specifier. - The action of `display-buffer' can be conceptually described this way: 1. Construct an alist of display specifiers by appending (in order) (a) the first matching display specifier alist found in `display-buffer-alist', if any (b) the SPECIFIERS argument (c) `display-buffer-fallback-alist' 2. Get the value of the `display-buffer-macro-specifiers' specifier from this alist. 3. Iterate through the list of specified methods, trying to display with each method, obeying specifiers such as `reuse-window-window' drawn from the constructed alist. If the method fails, try the next method in the list. If it succeeds, stop. 4. If one of the methods is a macro specifier, add that macro's specifier alist "temporarily" to the front of the constructed alist. Then look up `display-buffer-macro-specifiers' again, and iterate again through that list, as in step 3. The "macro" fails iff all of its `display-buffer-macro-specifiers' fail.