unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42337: [PATCH] Use display-buffer to make the calc popup
@ 2020-07-12 19:41 Viktor Obeling
  2020-08-05 14:05 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Viktor Obeling @ 2020-07-12 19:41 UTC (permalink / raw)
  To: 42337

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-14 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-12 19:41 bug#42337: [PATCH] Use display-buffer to make the calc popup Viktor Obeling
2020-08-05 14:05 ` Lars Ingebrigtsen
2020-09-14 14:59   ` Lars Ingebrigtsen

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