* 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'.
This commit is contained in:
Juri Linkov 2013-12-03 03:19:24 +02:00
parent 370f765594
commit 9139632a34
7 changed files with 55 additions and 18 deletions

View file

@ -1,3 +1,8 @@
2013-12-03 Juri Linkov <juri@jurta.org>
* windows.texi (Choosing Window): Rename `no-display-ok' to
`allow-no-window'. (Bug#13594)
2013-11-30 Glenn Morris <rgm@gnu.org>
* Makefile.in (distclean): Remove Makefile.

View file

@ -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

View file

@ -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'.

View file

@ -1,3 +1,15 @@
2013-12-03 Juri Linkov <juri@jurta.org>
* 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 <dgutov@yandex.ru>
* 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 <monnier@iro.umontreal.ca>

View file

@ -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)))

View file

@ -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))

View file

@ -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.