From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#30314: Define aliases for window display actions Date: Tue, 06 Feb 2018 23:42:10 +0200 Organization: LINKOV.NET Message-ID: <87lgg5x0b1.fsf@mail.linkov.net> References: <87mv0tsnk8.fsf@mail.linkov.net> <871si0qtfe.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1517953372 13536 195.159.176.226 (6 Feb 2018 21:42:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 6 Feb 2018 21:42:52 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) To: 30314@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 06 22:42:48 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejB0J-0001RD-Hs for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Feb 2018 22:42:15 +0100 Original-Received: from localhost ([::1]:39474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejB2K-00048k-Pk for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Feb 2018 16:44:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejB26-00044i-KX for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2018 16:44:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejB23-0006Xe-Eb for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2018 16:44:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52748) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejB23-0006XK-9X for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2018 16:44:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ejB23-00059C-0n for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2018 16:44:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Feb 2018 21:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30314 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30314-submit@debbugs.gnu.org id=B30314.151795343819769 (code B ref 30314); Tue, 06 Feb 2018 21:44:02 +0000 Original-Received: (at 30314) by debbugs.gnu.org; 6 Feb 2018 21:43:58 +0000 Original-Received: from localhost ([127.0.0.1]:60645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejB1y-00058n-AY for submit@debbugs.gnu.org; Tue, 06 Feb 2018 16:43:58 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:44572 helo=homiemail-a20.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejB1v-00058e-WD for 30314@debbugs.gnu.org; Tue, 06 Feb 2018 16:43:56 -0500 Original-Received: from homiemail-a20.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a20.g.dreamhost.com (Postfix) with ESMTP id 42F507EC064 for <30314@debbugs.gnu.org>; Tue, 6 Feb 2018 13:43:55 -0800 (PST) Original-Received: from localhost.linkov.net (m91-129-107-8.cust.tele2.ee [91.129.107.8]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a20.g.dreamhost.com (Postfix) with ESMTPSA id 635897EC061 for <30314@debbugs.gnu.org>; Tue, 6 Feb 2018 13:43:54 -0800 (PST) In-Reply-To: <871si0qtfe.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 05 Feb 2018 00:30:29 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142992 Archived-At: --=-=-= Content-Type: text/plain > + (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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=display-buffer--maybe.patch 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)) --=-=-=--