all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: 30314@debbugs.gnu.org
Subject: bug#30314: Define aliases for window display actions
Date: Tue, 06 Feb 2018 23:42:10 +0200	[thread overview]
Message-ID: <87lgg5x0b1.fsf@mail.linkov.net> (raw)
In-Reply-To: <871si0qtfe.fsf@mail.linkov.net> (Juri Linkov's message of "Mon,  05 Feb 2018 00:30:29 +0200")

[-- Attachment #1: Type: text/plain, Size: 235 bytes --]

> +        (and (if (eq pop-up-frames 'graphic-only)
> +	         (display-graphic-p)
> +	       pop-up-frames)
> +	     (display-buffer-pop-up-frame buffer alist))

Nah, this can't be right.  Better to create new functions for this:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: display-buffer--maybe.patch --]
[-- Type: text/x-diff, Size: 5922 bytes --]

diff --git a/lisp/files.el b/lisp/files.el
index 414eb3f..4b67b02 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3315,15 +3315,7 @@ hack-local-variables-confirm
 
       ;; Display the buffer and read a choice.
       (save-window-excursion
-	(pop-to-buffer buf `((display-buffer--maybe-same-window
-                              display-buffer-reuse-window
-                              display-buffer--maybe-pop-up-frame-or-window
-                              display-buffer-at-bottom)
-	                     ,(if temp-buffer-resize-mode
-		                  '(window-height . resize-temp-buffer-window)
-	                        '(window-height . fit-window-to-buffer))
-	                     ,(when temp-buffer-resize-mode
-	                        '(preserve-size . (nil . t)))))
+	(pop-to-buffer buf '(display-buffer--maybe-at-bottom))
 	(let* ((exit-chars '(?y ?n ?\s ?\C-g ?\C-v))
 	       (prompt (format "Please type %s%s: "
 			       (if offer-save "y, n, or !" "y or n")
@@ -6929,15 +6921,7 @@ save-buffers-kill-emacs
            (or (not active)
                (with-displayed-buffer-window
                 (get-buffer-create "*Process List*")
-                `((display-buffer--maybe-same-window
-                   display-buffer-reuse-window
-                   display-buffer--maybe-pop-up-frame-or-window
-                   display-buffer-at-bottom)
-	          ,(if temp-buffer-resize-mode
-		       '(window-height . resize-temp-buffer-window)
-	             '(window-height . fit-window-to-buffer))
-	          ,(when temp-buffer-resize-mode
-	             '(preserve-size . (nil . t))))
+                '(display-buffer--maybe-at-bottom)
                 #'(lambda (window _value)
                     (with-selected-window window
                       (unwind-protect
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 4d14b26..5d91242 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1823,12 +1823,7 @@ minibuffer-completion-help
              ;; window, mark it as softly-dedicated, so bury-buffer in
              ;; minibuffer-hide-completions will know whether to
              ;; delete the window or not.
-             (display-buffer-mark-dedicated 'soft)
-             ;; Disable `pop-up-windows' temporarily to allow
-             ;; `display-buffer--maybe-pop-up-frame-or-window'
-             ;; in the display actions below to pop up a frame
-             ;; if `pop-up-frames' is non-nil, but not to pop up a window.
-             (pop-up-windows nil))
+             (display-buffer-mark-dedicated 'soft))
         (with-displayed-buffer-window
           "*Completions*"
           ;; This is a copy of `display-buffer-fallback-action'
@@ -1836,7 +1831,7 @@ minibuffer-completion-help
           ;; with `display-buffer-at-bottom'.
           `((display-buffer--maybe-same-window
              display-buffer-reuse-window
-             display-buffer--maybe-pop-up-frame-or-window
+             display-buffer--maybe-pop-up-frame
              ;; Use `display-buffer-below-selected' for inline completions,
              ;; but not in the minibuffer (e.g. in `eval-expression')
              ;; for which `display-buffer-at-bottom' is used.
diff --git a/lisp/window.el b/lisp/window.el
index abd1a68..8c5e441 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -7289,12 +7289,23 @@ display-buffer--maybe-pop-up-frame-or-window
 
 If that cannot be done, and `pop-up-windows' is non-nil, try
 again with `display-buffer-pop-up-window'."
-  (or (and (if (eq pop-up-frames 'graphic-only)
-	       (display-graphic-p)
-	     pop-up-frames)
-	   (display-buffer-pop-up-frame buffer alist))
-      (and pop-up-windows
-	   (display-buffer-pop-up-window buffer alist))))
+  (or (display-buffer--maybe-pop-up-frame buffer alist)
+      (display-buffer--maybe-pop-up-window buffer alist)))
+
+(defun display-buffer--maybe-pop-up-frame (buffer alist)
+  "Try displaying BUFFER based on `pop-up-frames'.
+If `pop-up-frames' is non-nil (and not `graphic-only' on a
+text-only terminal), try with `display-buffer-pop-up-frame'."
+  (and (if (eq pop-up-frames 'graphic-only)
+	   (display-graphic-p)
+	 pop-up-frames)
+       (display-buffer-pop-up-frame buffer alist)))
+
+(defun display-buffer--maybe-pop-up-window (buffer alist)
+  "Try displaying BUFFER based on `pop-up-windows'.
+If `pop-up-windows' is non-nil, try with `display-buffer-pop-up-window'."
+  (and pop-up-windows
+       (display-buffer-pop-up-window buffer alist)))
 
 (defun display-buffer-in-child-frame (buffer alist)
   "Display BUFFER in a child frame.
@@ -7360,6 +7371,17 @@ display-buffer-below-selected
 	     (window--display-buffer
 	      buffer window 'reuse alist display-buffer-mark-dedicated)))))
 
+(defun display-buffer--maybe-at-bottom (buffer alist)
+  (let ((alist (append alist `(,(if temp-buffer-resize-mode
+		                    '(window-height . resize-temp-buffer-window)
+	                          '(window-height . fit-window-to-buffer))
+	                       ,(when temp-buffer-resize-mode
+	                          '(preserve-size . (nil . t)))))))
+    (or (display-buffer--maybe-same-window buffer alist)
+        (display-buffer-reuse-window buffer alist)
+        (display-buffer--maybe-pop-up-frame buffer alist)
+        (display-buffer-at-bottom buffer alist))))
+
 (defun display-buffer-at-bottom (buffer alist)
   "Try displaying BUFFER in a window at the bottom of the selected frame.
 This either reuses such a window provided it shows BUFFER
@@ -7376,8 +7398,8 @@ display-buffer-at-bottom
 	 (setq bottom-window-shows-buffer t)
 	 (setq bottom-window window))
 	((not bottom-window)
-	 (setq bottom-window window)))
-       nil nil 'nomini))
+	 (setq bottom-window window))))
+     nil nil 'nomini)
     (or (and bottom-window-shows-buffer
 	     (window--display-buffer
 	      buffer bottom-window 'reuse alist display-buffer-mark-dedicated))

  reply	other threads:[~2018-02-06 21:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31 21:52 bug#30314: Define aliases for window display actions Juri Linkov
2018-02-04 22:30 ` Juri Linkov
2018-02-06 21:42   ` Juri Linkov [this message]
2018-02-10 21:55     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lgg5x0b1.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=30314@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.