all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	sanelz@gmail.com, 36886@debbugs.gnu.org
Subject: bug#36886: 26.2; (global-eldoc-mode -1) should disable eldoc completely
Date: Sat, 03 Aug 2019 20:35:23 -0400	[thread overview]
Message-ID: <87k1btsr78.fsf@gmail.com> (raw)
In-Reply-To: <83ftmjfxq7.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 02 Aug 2019 17:28:16 +0300")

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

Eli Zaretskii <eliz@gnu.org> 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).


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

From d16b9c5dffb84c53bc6f55c4ca74fc8135d48d7f Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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


  reply	other threads:[~2019-08-04  0:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 10:30 bug#36886: 26.2; (global-eldoc-mode -1) should disable eldoc completely Sanel Zukan
2019-08-01 11:37 ` Basil L. Contovounesios
2019-08-01 12:29   ` Sanel Zukan
2019-08-01 13:38   ` Dmitry Gutov
2019-08-02  6:35 ` Eli Zaretskii
2019-08-02  9:35   ` Sanel Zukan
2019-08-02 11:44     ` Basil L. Contovounesios
2019-08-02 12:00       ` Eli Zaretskii
2019-08-02 13:19         ` Basil L. Contovounesios
2019-08-02 14:28           ` Eli Zaretskii
2019-08-04  0:35             ` Noam Postavsky [this message]
2019-08-04  7:51               ` Basil L. Contovounesios
2019-08-04  9:00                 ` Štěpán Němec
2019-08-04 14:34                 ` Noam Postavsky
2019-08-15  0:58                   ` Noam Postavsky
2019-08-15  8:31                     ` Štěpán Němec
2019-08-21  0:24                       ` Noam Postavsky
2019-08-04 16:27               ` Eli Zaretskii
2019-08-02 12:36       ` Sanel Zukan
2019-08-02 11:50     ` Eli Zaretskii
2019-08-02 12:51       ` Sanel Zukan
2019-08-02 14:33         ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=87k1btsr78.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=36886@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=eliz@gnu.org \
    --cc=sanelz@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.