[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13594: 24.2.92; [PATCH] compilation-start doesn't consider nil OUTWI

From: Stefan Monnier
Subject: bug#13594: 24.2.92; [PATCH] compilation-start doesn't consider nil OUTWIN
Date: Tue, 19 Mar 2013 23:12:08 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> Basically, as it currently stands "don't display at all" can be done in
>> 2 ways:
>> - make it work only for those callers that are prepared for it: for this
>> case, we could simply define a t return value (returned from an
>> ACTION) to mean "not displayed".  Ideally, display-buffer would return
>> nil in this case, but returning t is OK as well.
>> - make it work everywhere: then we need display-buffer to return
>> a "dummy" window (i.e. an object that behaves like a window object
>> but that is not displayed).
>> I'm beginning to think the best choice is the first option: it requires
>> no changes right away, and we can progressively change callers so that
>> they can handle the "not displayed" case.

> Does this roughly follow your idea? i.e. document display-buffer to
> allow non-window return value (I also get rid of mentioning nil). In
> compile.el, handle non-window return value. The attached patch does
> these two. (I'll prepare a thorough patch tomorrow.).

It only does one half: change a few callers to handle a non-window
return value.  But the other half is important: the non-window return
value should only be possible if the caller announces that it's ready to
handle it.


> diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
> index b82afc67..8edfe487 100644
> --- a/lisp/progmodes/compile.el
> +++ b/lisp/progmodes/compile.el
> @@ -1638,7 +1638,8 @@ (defun compilation-start (command &optional mode 
> name-function highlight-regexp)
>            (list command mode name-function highlight-regexp))
>       (set (make-local-variable 'revert-buffer-function)
>            'compilation-revert-buffer)
> -     (set-window-start outwin (point-min))
> +     (when (windowp outwin)
> +       (set-window-start outwin (point-min)))
>       ;; Position point as the user will see it.
>       (let ((desired-visible-point
> @@ -1647,15 +1648,18 @@ (defun compilation-start (command &optional mode 
> name-function highlight-regexp)
>                  (point-max)
>                ;; Normally put it at the top.
>                (point-min))))
> -       (if (eq outwin (selected-window))
> -           (goto-char desired-visible-point)
> -         (set-window-point outwin desired-visible-point)))
> +       (cond
> +        ((windowp outwin)
> +         (set-window-point outwin desired-visible-point))
> +        ((eq outwin (selected-window))
> +         (goto-char desired-visible-point))))
>       ;; The setup function is called before compilation-set-window-height
>       ;; so it can set the compilation-window-height buffer locally.
>       (if compilation-process-setup-function
>           (funcall compilation-process-setup-function))
> -     (compilation-set-window-height outwin)
> +     (and (windowp outwin)
> +          (compilation-set-window-height outwin))
>       ;; Start the compilation.
>       (if (fboundp 'start-process)
>           (let ((proc
> diff --git a/lisp/window.el b/lisp/window.el
> index 63d75f60..e96c8c60 100644
> --- a/lisp/window.el
> +++ b/lisp/window.el
> @@ -5368,7 +5368,8 @@ (defun display-buffer (buffer-or-name &optional action 
> frame)
>    "Display BUFFER-OR-NAME in some window, without selecting it.
>  BUFFER-OR-NAME must be a buffer or the name of an existing
>  buffer.  Return the window chosen for displaying BUFFER-OR-NAME,
> -or nil if no such window is found.
> +or a non-nil value to mean one of the actions forbids displaying
> +the buffer.
>  Optional argument ACTION, if non-nil, should specify a display
>  action.  Its form is described below.
> @@ -5394,7 +5395,9 @@ (defun display-buffer (buffer-or-name &optional action 
> frame)
>  `display-buffer-fallback-action' (in order).  Then it calls each
>  function in the combined function list in turn, passing the
>  buffer as the first argument and the combined alist as the second
> -argument, until one of the functions returns non-nil.
> +argument, until one of the functions returns non-nil.  If the
> +value is not a window object, the search stops and no buffer is
> +displayed.
>  If ACTION is nil, the function list and the alist are built using
>  only the other variables mentioned above.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]