From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Viktor Obeling Newsgroups: gmane.emacs.bugs Subject: bug#42337: [PATCH] Use display-buffer to make the calc popup Date: Sun, 12 Jul 2020 21:41:24 +0200 Message-ID: <87a704cyhn.fsf@mon.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37840"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.10; emacs 26.3 To: 42337@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 12 23:18:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jujMQ-0009kl-Tw for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Jul 2020 23:18:11 +0200 Original-Received: from localhost ([::1]:56112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jujMP-0004Fl-R2 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Jul 2020 17:18:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jujMJ-0004Fe-B4 for bug-gnu-emacs@gnu.org; Sun, 12 Jul 2020 17:18:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jujMJ-0004rk-2b for bug-gnu-emacs@gnu.org; Sun, 12 Jul 2020 17:18:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jujMI-00022o-Ve for bug-gnu-emacs@gnu.org; Sun, 12 Jul 2020 17:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Viktor Obeling Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Jul 2020 21:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42337 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15945886597812 (code B ref -1); Sun, 12 Jul 2020 21:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Jul 2020 21:17:39 +0000 Original-Received: from localhost ([127.0.0.1]:46928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jujLv-00021v-Bm for submit@debbugs.gnu.org; Sun, 12 Jul 2020 17:17:39 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:46756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1juhrB-0008Eq-HR for submit@debbugs.gnu.org; Sun, 12 Jul 2020 15:41:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juhrB-00033E-A1 for bug-gnu-emacs@gnu.org; Sun, 12 Jul 2020 15:41:49 -0400 Original-Received: from mailrelay4-3.pub.mailoutpod1-cph3.one.com ([46.30.212.13]:60534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juhr9-00080f-3S for bug-gnu-emacs@gnu.org; Sun, 12 Jul 2020 15:41:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obeling.org; s=20191106; h=content-type:mime-version:message-id:date:subject:to:from:from; bh=+T81VJTnGPRTIk62eV7gCWflJJRiBTgOadkxJvzg2wY=; b=PPIFZprWSZXuvTalR/VY9gdovU/iDruFAYU83bKTrdJcTMV8ckv1OTNpFkD1x8n5iBjRe1WpAAbiy 3/EhGaH4NoavzdEBlxU554F4TEY7FaIzF4yfs0kZRuNZSHmfGJ0UfNXkEPcAeYQlPMx3ClZx7QWYaU WWo9095q48vdr5CLhNYTChYCWDu8WoWOG8rWqnmW03rvru2uS4NcOhjMx0JyBquVUCPtMvFvJxaZzh jqrA3CjMN8rhgGROx4Yrso0JnkQ8M16o0gE9gviqLqfvEqsYC8sAPMa/nm/zBqaiRpxrb4sYUMuH4w sdt6dWo1Av24epfbyBv3v86CSi/rEoQ== X-HalOne-Cookie: edf67f1e9f41d2deb78065fae97051f7942121f2 X-HalOne-ID: abaecf5f-c477-11ea-9b1c-d0431ea8bb10 Original-Received: from mon.localdomain (7-14-107-185.static.kviknet.dk [185.107.14.7]) by mailrelay4.pub.mailoutpod1-cph3.one.com (Halon) with ESMTPSA id abaecf5f-c477-11ea-9b1c-d0431ea8bb10; Sun, 12 Jul 2020 19:41:40 +0000 (UTC) Received-SPF: none client-ip=46.30.212.13; envelope-from=viktor@obeling.org; helo=mailrelay4-3.pub.mailoutpod1-cph3.one.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 15:41:40 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 12 Jul 2020 17:17:38 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182954 Archived-At: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-display-buffer-to-make-the-calc-popup.patch >From e18d2f85504669e24c9f060c5b36e14c60ba6957 Mon Sep 17 00:00:00 2001 From: Viktor Obeling 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 --=-=-= Content-Type: text/plain -- Viktor Obeling --=-=-=--