unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Viktor Obeling <viktor@obeling.org>
To: 42337@debbugs.gnu.org
Subject: bug#42337: [PATCH] Use display-buffer to make the calc popup
Date: Sun, 12 Jul 2020 21:41:24 +0200	[thread overview]
Message-ID: <87a704cyhn.fsf@mon.localdomain> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Use-display-buffer-to-make-the-calc-popup.patch --]
[-- Type: text/x-patch, Size: 3030 bytes --]

From e18d2f85504669e24c9f060c5b36e14c60ba6957 Mon Sep 17 00:00:00 2001
From: Viktor Obeling <vpo@mon.localdomain>
Date: Sun, 12 Jul 2020 17:58:28 +0200
Subject: [PATCH] Use display-buffer to make the calc popup

* lisp/calc/calc.el (calc--popup-buffer, calc):
Allows the user to more easily customize the buffer placement by
using display-buffer-alist.

Copyright-paperwork-exempt: yes
---
 lisp/calc/calc.el | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index 4e4fb67173..5f3b2877d3 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -1394,6 +1394,19 @@ calc-create-buffer
     (require 'calc-ext)
     (calc-set-language calc-language calc-language-option t)))
 
+(defun calc--popup-buffer (buffer alist)
+  "Action function for `display-buffer'."
+  (let ((w (get-largest-window)))
+    (when (and pop-up-windows
+               (> (window-height w)
+                  (+ window-min-height calc-window-height 2)))
+      (setq w (split-window w
+                            (- (window-height w)
+                               calc-window-height 2)
+                            nil))
+      (set-window-buffer w buffer)
+      (select-window w))))
+
 ;;;###autoload
 (defun calc (&optional arg full-display interactive)
   "The Emacs Calculator.  Full documentation is listed under `calc-mode'."
@@ -1412,25 +1425,14 @@ calc
 	(calc-quit)
       (calc-create-buffer)
       (setq calc-was-keypad-mode nil)
-      (if (or (eq full-display t)
-              (and (null full-display) calc-full-mode))
-          (switch-to-buffer (current-buffer) t)
-        (if (get-buffer-window (current-buffer))
-            (select-window (get-buffer-window (current-buffer)))
-          (if calc-window-hook
-              (run-hooks 'calc-window-hook)
-            (let ((w (get-largest-window)))
-              (if (and pop-up-windows
-                       (> (window-height w)
-                          (+ window-min-height calc-window-height 2)))
-                  (progn
-                    (setq w (split-window w
-                                          (- (window-height w)
-                                             calc-window-height 2)
-                                          nil))
-                    (set-window-buffer w (current-buffer))
-                    (select-window w))
-                (pop-to-buffer (current-buffer)))))))
+      (cond ((or (eq full-display t)
+                 (and (null full-display) calc-full-mode))
+             (switch-to-buffer (current-buffer) t))
+            ((get-buffer-window (current-buffer))
+             (select-window (get-buffer-window (current-buffer))))
+            (calc-window-hook
+             (run-hooks 'calc-window-hook))
+            (t (pop-to-buffer (current-buffer) (cons #'calc--popup-buffer nil))))
       (with-current-buffer (calc-trail-buffer)
         (and calc-display-trail
              (= (window-width) (frame-width))
-- 
2.26.2


[-- Attachment #2: Type: text/plain, Size: 19 bytes --]


--
Viktor Obeling

             reply	other threads:[~2020-07-12 19:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-12 19:41 Viktor Obeling [this message]
2020-08-05 14:05 ` bug#42337: [PATCH] Use display-buffer to make the calc popup Lars Ingebrigtsen
2020-09-14 14:59   ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87a704cyhn.fsf@mon.localdomain \
    --to=viktor@obeling.org \
    --cc=42337@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).