From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#36886: 26.2; (global-eldoc-mode -1) should disable eldoc completely Date: Wed, 14 Aug 2019 20:58:12 -0400 Message-ID: <8736i3qm6z.fsf@gmail.com> References: <87h8719nzl.fsf@example.com> <83imrggjmo.fsf@gnu.org> <8736ijap0e.fsf@example.com> <87d0hn23mm.fsf@tcd.ie> <83mugrg4kv.fsf@gnu.org> <87k1bvzovi.fsf@tcd.ie> <83ftmjfxq7.fsf@gnu.org> <87k1btsr78.fsf@gmail.com> <87ftmhs70z.fsf@tcd.ie> <87a7cproch.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="29545"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.90 (gnu/linux) Cc: 36886@debbugs.gnu.org, sanelz@gmail.com To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 15 02:59:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hy46j-0007XX-K5 for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Aug 2019 02:59:13 +0200 Original-Received: from localhost ([::1]:36902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy46h-0000jI-Tl for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Aug 2019 20:59:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38362) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy46Z-0000fr-PG for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 20:59:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hy46Y-0005ke-33 for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 20:59:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hy46X-0005kR-UY for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 20:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hy46X-00080K-RX for bug-gnu-emacs@gnu.org; Wed, 14 Aug 2019 20:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Aug 2019 00:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36886 X-GNU-PR-Package: emacs Original-Received: via spool by 36886-submit@debbugs.gnu.org id=B36886.156583070230709 (code B ref 36886); Thu, 15 Aug 2019 00:59:01 +0000 Original-Received: (at 36886) by debbugs.gnu.org; 15 Aug 2019 00:58:22 +0000 Original-Received: from localhost ([127.0.0.1]:49981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hy45u-0007zE-3S for submit@debbugs.gnu.org; Wed, 14 Aug 2019 20:58:22 -0400 Original-Received: from mail-ot1-f44.google.com ([209.85.210.44]:44617) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hy45r-0007yy-NJ for 36886@debbugs.gnu.org; Wed, 14 Aug 2019 20:58:20 -0400 Original-Received: by mail-ot1-f44.google.com with SMTP id w4so2405230ote.11 for <36886@debbugs.gnu.org>; Wed, 14 Aug 2019 17:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=pZhkWT3csb90r67DibHpoeRzvK+mhTZXWz/fZQ4VHKY=; b=R3sZgigbNVgJz+Xs6ax1suc3vrdaTXRGkw5/8Volmq8muaSYXEzofB8kfCA4AjCn0e VwdNiRQeW0TmxlpPXV7cf8df8AVVMYWbrgPfrzqh4GgkKRU0VkEkPlHaCHsKzWn/PLM5 KsSAQRD+IbdwjzQrms+fJ9KAXTa4F/m4S3EAE9UxNZiNDuC49oMVjs0DtkK1NdzTA4zG R6gX4rS5myzdrBKdvp8Db2w7CgusQ5JPnP0YjQtSwDR+CQKbUsfG+eaPojqnv83IV9dk hQSG7BKjJDgD9480zYdenSZcYYd/isZV4ODztPpfakoxQlnuKdJvpQ1HmEy916pbngF2 N5oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=pZhkWT3csb90r67DibHpoeRzvK+mhTZXWz/fZQ4VHKY=; b=SS2dXmo/JiEMvPJvJCZAeTY9aZxZY4JKwpzuCNUM8qr9EhOL04vSTRrbziqbv94npm 9qaZ+sSTVe7OcJGNvoZ06UWVsl+oYyWPKtGe2tawpPmmzmhM7eNemWxB7GqnTT5utESZ mUzWA0ih7/6lPjJmN34ywZW0dgdtTDVobTNMzt82HqcuxCoYky2cKq1IB6D0PbxyfkWo Tn7esoPneerE1WuGK8Dk95cRAn5OIec6Qz1tiLAaaFjUeAMroHD/RdNjTPezaf7WFUoE ddNRd9yjksC/Ir5OMoXsRFi2uCqXG+YCTGsHNmP1GiLusq6aPh9CEEPDtalcf+fJ/zxc +H4w== X-Gm-Message-State: APjAAAU3jrMdL3mXJQM7SIeqeN2Mpq/1KSNJUxyQddXTkfx4/SrpYGAq RiDj4BBBH8AcN8hy92ZJ/OY= X-Google-Smtp-Source: APXvYqxI33q78D0duFyAEI70NQlEOlqDfKDC5oWqXJiearz2ALl/Is4B00mcw9GGNJ9wq1VCZAH6Fw== X-Received: by 2002:a6b:6b02:: with SMTP id g2mr3023322ioc.13.1565830694023; Wed, 14 Aug 2019 17:58:14 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id t2sm2830443iod.81.2019.08.14.17.58.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Aug 2019 17:58:13 -0700 (PDT) In-Reply-To: <87a7cproch.fsf@gmail.com> (Noam Postavsky's message of "Sun, 04 Aug 2019 10:34:38 -0400") 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: 209.51.188.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:165000 Archived-At: --=-=-= Content-Type: text/plain Updated patch attached. I'll push in a few days, assuming nothing else turns up. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Respect-global-eldoc-mode-in-minibuffers-Bug-36886.patch Content-Description: patch >From d2557c135a83eda9e1c5347850669c195ae588b4 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 3 Aug 2019 20:19:31 -0400 Subject: [PATCH] Respect global-eldoc-mode in minibuffers (Bug#36886) * lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Accept a BODY parameter. * doc/lispref/modes.texi (Defining Minor Modes): Document new parameter. * etc/NEWS: Announce it. * lisp/simple.el (read--expression): Move eldoc-mode setup to... * lisp/emacs-lisp/eldoc.el (eldoc--eval-expression-setup): ... here, new function. (global-eldoc-mode): Add or remove it to eval-expression-minibuffer-setup-hook when enabling or disabling global-eldoc-mode. This enables eldoc in the minibuffer (solving Bug#27202), only when global-eldoc-mode is enabled. --- doc/lispref/modes.texi | 8 ++++---- etc/NEWS | 3 +++ lisp/emacs-lisp/easy-mmode.el | 38 ++++++++++++++++++++++---------------- lisp/emacs-lisp/eldoc.el | 19 ++++++++++++++++++- lisp/simple.el | 6 ++---- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index d12f241424..d7e1213ea9 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -1783,12 +1783,12 @@ Defining Minor Modes (hungry-electric-delete t))))) @end smallexample -@defmac define-globalized-minor-mode global-mode mode turn-on keyword-args@dots{} +@defmac define-globalized-minor-mode global-mode mode turn-on keyword-args@dots{} body@dots{} This defines a global toggle named @var{global-mode} whose meaning is to enable or disable the buffer-local minor mode @var{mode} in all -buffers. To turn on the minor mode in a buffer, it uses the function -@var{turn-on}; to turn off the minor mode, it calls @var{mode} with -@minus{}1 as argument. +buffers. It also executes the @var{body} forms. To turn on the minor +mode in a buffer, it uses the function @var{turn-on}; to turn off the +minor mode, it calls @var{mode} with @minus{}1 as argument. Globally enabling the mode also affects buffers subsequently created by visiting files, and buffers that use a major mode other than diff --git a/etc/NEWS b/etc/NEWS index 13de6bb0f8..318bfe4259 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2378,6 +2378,9 @@ the Emacs Lisp manual. ** `directory-files-recursively' can now take an optional PREDICATE parameter to control descending into subdirectories. ++++ +** 'define-globalized-minor-mode' now takes BODY forms. + * Changes in Emacs 27.1 on Non-Free Operating Systems diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index be531aab84..fcbddc8629 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -363,18 +363,21 @@ 'easy-mmode-define-global-mode ;;;###autoload (defalias 'define-global-minor-mode 'define-globalized-minor-mode) ;;;###autoload -(defmacro define-globalized-minor-mode (global-mode mode turn-on &rest keys) +(defmacro define-globalized-minor-mode (global-mode mode turn-on &rest body) "Make a global mode GLOBAL-MODE corresponding to buffer-local minor MODE. TURN-ON is a function that will be called with no args in every buffer and that should try to turn MODE on if applicable for that buffer. -KEYS is a list of CL-style keyword arguments. As the minor mode - defined by this function is always global, any :global keyword is - ignored. Other keywords have the same meaning as in `define-minor-mode', - which see. In particular, :group specifies the custom group. - The most useful keywords are those that are passed on to the - `defcustom'. It normally makes no sense to pass the :lighter - or :keymap keywords to `define-globalized-minor-mode', since these - are usually passed to the buffer-local version of the minor mode. +Each of KEY VALUE is a pair of CL-style keyword arguments. As + the minor mode defined by this function is always global, any + :global keyword is ignored. Other keywords have the same + meaning as in `define-minor-mode', which see. In particular, + :group specifies the custom group. The most useful keywords + are those that are passed on to the `defcustom'. It normally + makes no sense to pass the :lighter or :keymap keywords to + `define-globalized-minor-mode', since these are usually passed + to the buffer-local version of the minor mode. +BODY contains code to execute each time the mode is enabled or disabled. + It is executed after toggling the mode, and before running GLOBAL-MODE-hook. If MODE's set-up depends on the major mode in effect when it was enabled, then disabling and reenabling MODE should make MODE work @@ -384,7 +387,9 @@ define-globalized-minor-mode When a major mode is initialized, MODE is actually turned on just after running the major mode's hook. However, MODE is not turned -on if the hook has explicitly disabled it." +on if the hook has explicitly disabled it. + +\(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY)" (declare (doc-string 2)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) @@ -404,12 +409,12 @@ define-globalized-minor-mode keyw) ;; Check keys. - (while (keywordp (setq keyw (car keys))) - (setq keys (cdr keys)) + (while (keywordp (setq keyw (car body))) + (pop body) (pcase keyw - (:group (setq group (nconc group (list :group (pop keys))))) - (:global (setq keys (cdr keys))) - (_ (push keyw extra-keywords) (push (pop keys) extra-keywords)))) + (:group (setq group (nconc group (list :group (pop body))))) + (:global (pop body)) + (_ (push keyw extra-keywords) (push (pop body) extra-keywords)))) `(progn (progn @@ -446,7 +451,8 @@ define-globalized-minor-mode ;; Go through existing buffers. (dolist (buf (buffer-list)) (with-current-buffer buf - (if ,global-mode (funcall #',turn-on) (when ,mode (,mode -1)))))) + (if ,global-mode (funcall #',turn-on) (when ,mode (,mode -1))))) + ,@body) ;; Autoloading define-globalized-minor-mode autoloads everything ;; up-to-here. diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 16b5863209..2892faae21 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -207,7 +207,24 @@ eldoc-mode (define-globalized-minor-mode global-eldoc-mode eldoc-mode turn-on-eldoc-mode :group 'eldoc :initialize 'custom-initialize-delay - :init-value t) + :init-value t + ;; For `read--expression', the usual global mode mechanism of + ;; `change-major-mode-hook' runs in the minibuffer before + ;; `eldoc-documentation-function' is set, so `turn-on-eldoc-mode' + ;; does nothing. Configure and enable eldoc from + ;; `eval-expression-minibuffer-setup-hook' instead. + (if global-eldoc-mode + (add-hook 'eval-expression-minibuffer-setup-hook + #'eldoc--eval-expression-setup) + (remove-hook 'eval-expression-minibuffer-setup-hook + #'eldoc--eval-expression-setup))) + +(defun eldoc--eval-expression-setup () + ;; Setup `eldoc', similar to `emacs-lisp-mode'. FIXME: Call + ;; `emacs-lisp-mode' itself? + (add-function :before-until (local 'eldoc-documentation-function) + #'elisp-eldoc-documentation-function) + (eldoc-mode +1)) ;;;###autoload (defun turn-on-eldoc-mode () diff --git a/lisp/simple.el b/lisp/simple.el index e33709e8ad..479c2d38fd 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1580,10 +1580,8 @@ read--expression (let ((minibuffer-completing-symbol t)) (minibuffer-with-setup-hook (lambda () - ;; FIXME: call emacs-lisp-mode? - (add-function :before-until (local 'eldoc-documentation-function) - #'elisp-eldoc-documentation-function) - (eldoc-mode 1) + ;; FIXME: call emacs-lisp-mode (see also + ;; `eldoc--eval-expression-setup')? (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil t) (run-hooks 'eval-expression-minibuffer-setup-hook)) -- 2.11.0 --=-=-=--