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: Sat, 03 Aug 2019 20:35:23 -0400 Message-ID: <87k1btsr78.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> 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="240111"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.90 (gnu/linux) Cc: "Basil L. Contovounesios" , sanelz@gmail.com, 36886@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 04 02:36:11 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 1hu4VO-0010IJ-An for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Aug 2019 02:36:10 +0200 Original-Received: from localhost ([::1]:42448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hu4VM-0002Hl-Op for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Aug 2019 20:36:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53311) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hu4VH-0002Gp-OS for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2019 20:36:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hu4VG-0006L6-BM for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2019 20:36:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hu4VG-0006L0-7o for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2019 20:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hu4VG-00009t-3m for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2019 20:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Aug 2019 00:36:02 +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.1564878933573 (code B ref 36886); Sun, 04 Aug 2019 00:36:02 +0000 Original-Received: (at 36886) by debbugs.gnu.org; 4 Aug 2019 00:35:33 +0000 Original-Received: from localhost ([127.0.0.1]:60222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hu4Um-000099-M9 for submit@debbugs.gnu.org; Sat, 03 Aug 2019 20:35:33 -0400 Original-Received: from mail-io1-f42.google.com ([209.85.166.42]:38209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hu4Uk-00008x-PT for 36886@debbugs.gnu.org; Sat, 03 Aug 2019 20:35:31 -0400 Original-Received: by mail-io1-f42.google.com with SMTP id j6so40412586ioa.5 for <36886@debbugs.gnu.org>; Sat, 03 Aug 2019 17:35:30 -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=VZbzQTLGuIb6B+iM57huxtklbw985aRYlyS3H/Itttg=; b=NbO4a7L0bJUDJdhZvI94TqPVjnVx/uww3ZmndmmS73qhsGo+fT7IspERy7OgN2Z5Je I1fklOYlJYElgst5Io083dpwvlEZuMITJGUeVDxb4YfmljeA9suVt2TBnmo0aTjJDqIW JPrrOQak3OW43BHlM9Rto7w5uIPf0qawTRfgIAv6Mt4OfEhm2zWMAWOoy2laHv7NgaHj +VD+Wz30jwzrdM7sR5jOdsWRYaypKxhRoixUy+EjupDesEuO7FcE1B0HOXiulhY7lNEn pFCl1yrGr72rykyYWYY0Qgw1w+FKnYx/8hqpMmY9xpcoZq5DX24uzeqCRF2cYygMUmEF FXxw== 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=VZbzQTLGuIb6B+iM57huxtklbw985aRYlyS3H/Itttg=; b=b0SE6aqgAXuhJcfTRhRe8NnrvUhubySMhAsl0IaTo5ANRSvMx0KYQlSElHnXuyYKRZ q2zC3727/5vLQrIZI3psZOtR1iYiTJn0ywaJk56JlR4OImxhWs28EFtKd8S+JwasuQoG dJHu9IsldR9Pd3MPKSMPScdnGzeqdp1Rc1No75MZyAU3HEzhK64ZXuHYhQTJCv+jKgFJ TBB9SH22YOGaYuUYiuP9BXIvUqjAULPoeHM63YtXvJN1TxCjMxqKv3XoMp1/uI89sFYh PZHK8sKlRDLxW7xt+06jR4CPrMExIsSuDbgo4rDdOHAi2u0C4zcGI+Kwm7/RurLLCpmN eD2Q== X-Gm-Message-State: APjAAAU2VjlxfcE7Geg8eGEp5PblFLfs0iONlaiC6t5Xv/Q5zXKACjya wWgQAffO/ht5BEQhDbW8xKkBLIaj X-Google-Smtp-Source: APXvYqyger4y2+Y4gPjxdkOl6J5fPB/xu/+ar4PqwnpNgVxfo5i44rjYvGLF7/1ey7Amq1Dwi87aog== X-Received: by 2002:a6b:6611:: with SMTP id a17mr106377020ioc.179.1564878925093; Sat, 03 Aug 2019 17:35:25 -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 t14sm64086682ioi.60.2019.08.03.17.35.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 17:35:24 -0700 (PDT) In-Reply-To: <83ftmjfxq7.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 02 Aug 2019 17:28:16 +0300") 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:164515 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > I actually don't understand why, when the globalized mode is ON, it > doesn't work in the minibuffer. What am I missing? define-globalized-minor-mode only adds after-change-major-mode-hook, find-file-hook, and change-major-mode-hook. AFAICT, the minibuffer stays in fundamental-mode, and doesn't visit a file so none of those are triggered. Possible patch attached (some additional manual updates + NEWS would be needed for define-globalized-minor-mode change). --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Respect-global-eldoc-mode-in-minibuffers-Bug-36886.patch Content-Description: patch >From d16b9c5dffb84c53bc6f55c4ca74fc8135d48d7f 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. * lisp/emacs-lisp/eldoc.el (global-eldoc-mode): Add or remove eldoc-mode to eval-expression-minibuffer-setup-hook when enabling or disabling global-eldoc-mode. * lisp/simple.el (read--expression): Remove the no-longer-needed unconditional call to eldoc-mode. --- lisp/emacs-lisp/easy-mmode.el | 38 ++++++++++++++++++++++---------------- lisp/emacs-lisp/eldoc.el | 5 ++++- lisp/simple.el | 1 - 3 files changed, 26 insertions(+), 18 deletions(-) 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..e5f1832de6 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -207,7 +207,10 @@ 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 + (if global-eldoc-mode + (add-hook 'eval-expression-minibuffer-setup-hook #'eldoc-mode) + (remove-hook 'eval-expression-minibuffer-setup-hook #'eldoc-mode))) ;;;###autoload (defun turn-on-eldoc-mode () diff --git a/lisp/simple.el b/lisp/simple.el index e33709e8ad..f81400c073 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1583,7 +1583,6 @@ read--expression ;; FIXME: call emacs-lisp-mode? (add-function :before-until (local 'eldoc-documentation-function) #'elisp-eldoc-documentation-function) - (eldoc-mode 1) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil t) (run-hooks 'eval-expression-minibuffer-setup-hook)) -- 2.11.0 --=-=-=--