From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: display-buffer-alist simplifications Date: Fri, 05 Aug 2011 19:45:05 +0300 Organization: JURTA Message-ID: <87oc037qwj.fsf@mail.jurta.org> References: <87mxgem09k.fsf@stupidchicken.com> <4E22AE2B.5040806@gmx.at> <4E248102.6080904@gmx.at> <4E380918.3060806@gmx.at> <4E397611.5020603@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1312563564 486 80.91.229.12 (5 Aug 2011 16:59:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 5 Aug 2011 16:59:24 +0000 (UTC) Cc: martin rudalics , Chong Yidong , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 05 18:59:19 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 1QpNjy-0005Ey-32 for ged-emacs-devel@m.gmane.org; Fri, 05 Aug 2011 18:59:18 +0200 Original-Received: from localhost ([::1]:37405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpNjx-0007TD-OS for ged-emacs-devel@m.gmane.org; Fri, 05 Aug 2011 12:59:17 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:42830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpNju-0007Rs-3W for emacs-devel@gnu.org; Fri, 05 Aug 2011 12:59:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpNjs-0004Vc-HV for emacs-devel@gnu.org; Fri, 05 Aug 2011 12:59:14 -0400 Original-Received: from smarty.dreamhost.com ([208.113.175.8]:35578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpNjs-0004VH-AX for emacs-devel@gnu.org; Fri, 05 Aug 2011 12:59:12 -0400 Original-Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id 4B5AE6E804D; Fri, 5 Aug 2011 09:59:10 -0700 (PDT) Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id B8596451C106; Fri, 5 Aug 2011 09:59:08 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Thu, 04 Aug 2011 14:16:43 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.113.175.8 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:142903 Archived-At: > What problems do you guys (fore)see with such a setup? Let's see how such a setup serves some specific test-cases: 1. The user should be able to specify whether to display the buffer in the same window or in another window and which window to select after displaying the buffer in another window. Currently these differences are encoded in function names: `switch-to-buffer' - display buffer in the selected window `pop-to-buffer' - display buffer and select its window `display-buffer' - display buffer, but don't select its window and they are used quite inconsistently in applications. For instance, to display the "*vc-diff*" buffer, `vc-diff-internal' calls (pop-to-buffer "*vc-diff*"), but `vc-annotate-show-diff-revision-at-line-internal' calls (switch-to-buffer "*vc-diff*"). How the user can override these application defaults? To display the "*vc-diff*" buffer in the selected window (like `switch-to-buffer'): (setq display-buffer-alist '( ("*vc-diff*" display-buffer-same-window))) To display the "*vc-diff*" buffer and not select its window: (setq display-buffer-alist '( ("*vc-diff*" display-buffer-other-window))) To display the "*vc-diff*" buffer and select its window (like `pop-to-buffer'): (setq display-buffer-alist '( ("*vc-diff*" display-buffer-pop-to-buffer))) 2. How the user can override the global defaults? For instance, I want to display the *Help* buffer in the selected window. But when it's already displayed in another window, then prefer reusing another window (because otherwise two windows will be displayed with the same buffer). And not reuse a window on another frame. Should I write a new function and use it like: (setq display-buffer-alist '( ("*Help*" display-buffer-other-window-same-frame-or-same-window))) Or provide additional arguments to the predefined functions like: (setq display-buffer-alist '( ("*Help*" display-buffer-same-window reuse-other-window-same-frame))) Or (setq display-buffer-alist '( ("*Help*" display-buffer-same-window (reuse-window . same-frame)))) 3. How applications can override the global default? For instance, what to do to fit the command `info-other-window': (defun info-other-window (&optional file-or-node) "Like `info' but show the Info buffer in another window." (interactive (if current-prefix-arg (list (read-file-name "Info file name: " nil nil t)))) (let (same-window-buffer-names same-window-regexps (pop-up-windows t)) (info file-or-node))) info the new setup? Maybe something like this: (defalias 'info-other-window 'info) ;;;###autoload (add-hook 'display-buffer-alist ;;;###autoload '(info-check-command-name display-buffer-pop-to-buffer)) (defun info-check-command-name (buffer-name) (and (eq this-command 'info-other-window) (string-match-p "\\*info\\*\\(\\|<[0-9]+>\\)" buffer-name)))