From 9139632a34c396ccd1677e86f3e4e870c025b2e3 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 3 Dec 2013 03:19:24 +0200 Subject: [PATCH] * lisp/window.el (display-buffer-no-window): New action function. (display-buffer-alist, display-buffer): Doc fix. (Bug#13594) * lisp/simple.el (shell-command): Add window alist entry `allow-no-window' to `display-buffer'. (async-shell-command): Doc fix. * lisp/progmodes/compile.el (compilation-start): Rename window alist entry `no-display-ok' to `allow-no-window'. * doc/lispref/windows.texi (Choosing Window): Rename `no-display-ok' to `allow-no-window'. --- doc/lispref/ChangeLog | 5 +++++ doc/lispref/windows.texi | 4 ++-- etc/NEWS | 7 +++++-- lisp/ChangeLog | 15 ++++++++++++++- lisp/progmodes/compile.el | 6 +++--- lisp/simple.el | 8 +++++++- lisp/window.el | 28 +++++++++++++++++++--------- 7 files changed, 55 insertions(+), 18 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index cd94a72f77d..92335dc616d 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2013-12-03 Juri Linkov + + * windows.texi (Choosing Window): Rename `no-display-ok' to + `allow-no-window'. (Bug#13594) + 2013-11-30 Glenn Morris * Makefile.in (distclean): Remove Makefile. diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 8f592dfebb3..661860025f3 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -1843,9 +1843,9 @@ The constant @code{display-buffer-fallback-action}. Each action function is called in turn, passing the buffer as the first argument and the combined action alist as the second argument, until one of the functions returns non-@code{nil}. The caller can -pass @code{(no-display-ok . t)} as an element of the action alist to +pass @code{(allow-no-window . t)} as an element of the action alist to indicate its readiness to handle the case of not displaying the -buffer. +buffer in a window. The argument @var{action} can also have a non-@code{nil}, non-list value. This has the special meaning that the buffer should be diff --git a/etc/NEWS b/etc/NEWS index 1f050c6b975..679a724f046 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1848,9 +1848,12 @@ reused. *** New option `switch-to-buffer-preserve-window-point' to restore a window's point when switching buffers. -*** New display action alist entry `no-display-ok' to indicate the +*** New display action function `display-buffer-no-window' to not +display the buffer in a window. + +*** New display action alist entry `allow-no-window' to indicate the caller of `display-buffer' is ready to handle the case of not -displaying the buffer. +displaying the buffer in a window. *** New display action alist entries `window-height' and `window-width' specify the size of new windows created by `display-buffer'. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9632b9216a0..42802fd43f4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2013-12-03 Juri Linkov + + * progmodes/compile.el (compilation-start): Rename window alist + entry `no-display-ok' to `allow-no-window'. + + * simple.el (shell-command): Add window alist entry + `allow-no-window' to `display-buffer'. + (async-shell-command): Doc fix. + + * window.el (display-buffer-no-window): New action function. + (display-buffer-alist, display-buffer): Doc fix. (Bug#13594) + 2013-12-02 Dmitry Gutov * vc/log-edit.el (log-edit-set-header): Extract from @@ -537,7 +549,8 @@ (Bug#13594) * window.el (display-buffer-alist, display-buffer): Document the - new parameter no-display-ok. + new parameter no-display-ok. Return either a window or nil + but never a non-window value. 2013-11-18 Stefan Monnier diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 58f14f68658..58325b26634 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1632,7 +1632,7 @@ Returns the compilation buffer created." (set-buffer-modified-p nil)) ;; Pop up the compilation buffer. ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01638.html - (setq outwin (display-buffer outbuf '(nil (no-display-ok . t)))) + (setq outwin (display-buffer outbuf '(nil (allow-no-window . t)))) (with-current-buffer outbuf (let ((process-environment (append @@ -2513,7 +2513,7 @@ and overlay is highlighted between MK and END-MK." ;; the error location if the two buffers are in two ;; different frames. So don't do it if it's not necessary. pre-existing - (display-buffer (marker-buffer msg) '(nil (no-display-ok . t))))) + (display-buffer (marker-buffer msg) '(nil (allow-no-window . t))))) (highlight-regexp (with-current-buffer (marker-buffer msg) ;; also do this while we change buffer (goto-char (marker-position msg)) @@ -2635,7 +2635,7 @@ attempts to find a file whose name is produced by (format FMT FILENAME)." (save-excursion ;This save-excursion is probably not right. (let ((w (let ((pop-up-windows t)) (display-buffer (marker-buffer marker) - '(nil (no-display-ok . t)))))) + '(nil (allow-no-window . t)))))) (with-current-buffer (marker-buffer marker) (goto-char marker) (and w (compilation-set-window w marker))) diff --git a/lisp/simple.el b/lisp/simple.el index bdf1455f4e2..260c1702def 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2640,6 +2640,12 @@ to execute it asynchronously. The output appears in the buffer `*Async Shell Command*'. That buffer is in shell mode. +You can configure `async-shell-command-buffer' to specify what to do in +case when `*Async Shell Command*' buffer is already taken by another +running shell command. To run COMMAND without displaying the output +in a window you can configure `display-buffer-alist' to use the action +`display-buffer-no-window' for the buffer `*Async Shell Command*'. + In Elisp, you will often be better served by calling `start-process' directly, since it offers more control and does not impose the use of a shell (with its need to quote arguments)." @@ -2826,7 +2832,7 @@ the use of a shell (with its need to quote arguments)." ;; which comint sometimes adds for prompts. (let ((inhibit-read-only t)) (erase-buffer)) - (display-buffer buffer) + (display-buffer buffer '(nil (allow-no-window . t))) (setq default-directory directory) (setq proc (start-process "Shell" buffer shell-file-name shell-command-switch command)) diff --git a/lisp/window.el b/lisp/window.el index 7978623ac77..24fe6a27895 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5851,13 +5851,8 @@ This is a list of elements (CONDITION . ACTION), where: `display-buffer' scans this alist until it either finds a matching regular expression or the function specified by a -condition returns non-nil. It can pass (no-display-ok . t) in -its action alist to indicate readiness for the case of not -displaying the buffer and FUNCTION can safely return a non-window -value to suppress displaying. - -In any of these cases, it adds the associated action to the list -of actions it will try." +condition returns non-nil. In any of these cases, it adds the +associated action to the list of actions it will try." :type `(alist :key-type (choice :tag "Condition" regexp @@ -5939,8 +5934,9 @@ ALIST is an arbitrary association list (alist). Each such FUNCTION should accept two arguments: the buffer to display and an alist. Based on those arguments, it should display the buffer and return the window. If the caller is -prepared to handle the case of not displaying the buffer it -should pass (no-display-ok . t) as an element of the ALIST. +prepared to handle the case of not displaying the buffer +and returning nil from `display-buffer' it should pass +\(allow-no-window . t) as an element of the ALIST. The `display-buffer' function builds a function list and an alist by combining the functions and alists specified in @@ -5995,6 +5991,10 @@ Recognized alist entries include: argument - a new window. The function is supposed to adjust the width of the window; its return value is ignored. + `allow-no-window' -- A non-nil value indicates readiness for the case + of not displaying the buffer and FUNCTION can safely return + a non-window value to suppress displaying. + The ACTION argument to `display-buffer' can also have a non-nil and non-list value. This means to display the buffer in a window other than the selected one, even if it is already displayed in @@ -6337,6 +6337,16 @@ that frame." (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame (window-frame window))))))) +(defun display-buffer-no-window (buffer alist) + "Display BUFFER in no window. +If ALIST has a non-nil `allow-no-window' entry, then don't display +a window at all. This makes possible to override the default action +and avoid displaying the buffer. It is assumed that when the caller +specifies a non-nil `allow-no-window' then it can handle a nil value +returned from `display-buffer' in this case." + (when (cdr (assq 'allow-no-window alist)) + 'fail)) + ;;; Display + selection commands: (defun pop-to-buffer (buffer &optional action norecord) "Select buffer BUFFER in some window, preferably a different one. -- 2.39.2