From: Leo Liu <sdl.web@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 16346@debbugs.gnu.org
Subject: bug#16346: 24.3; electric-pair-mode close-paren issue
Date: Sat, 11 Jan 2014 12:38:31 +0800 [thread overview]
Message-ID: <m1ppnznneg.fsf@gmail.com> (raw)
In-Reply-To: <jwv38kvbvvi.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Fri, 10 Jan 2014 12:20:49 -0500")
On 2014-01-11 01:20 +0800, Stefan Monnier wrote:
> I think the idea is fine, but using post-self-insert-hook turns out to
> be a bad idea, I think (tho I liked it, initially).
> Could you try and re-implement it as a minor mode that enables
> eldoc-mode and tweaks eldoc-message-commands buffer-locally, to see if
> that works better?
The following patch seems to do it. Comments?
=== modified file 'lisp/emacs-lisp/eldoc.el'
--- lisp/emacs-lisp/eldoc.el 2014-01-06 23:34:05 +0000
+++ lisp/emacs-lisp/eldoc.el 2014-01-11 04:31:35 +0000
@@ -62,6 +62,11 @@
:type 'number
:group 'eldoc)
+(defcustom eldoc-print-after-edit nil
+ "If non-nil eldoc info is only shown when editing."
+ :type 'boolean
+ :group 'eldoc)
+
;;;###autoload
(defcustom eldoc-minor-mode-string (purecopy " ElDoc")
"String to display in mode line when ElDoc Mode is enabled; nil for none."
@@ -150,6 +155,16 @@
"The function used by `eldoc-message' to display messages.
It should receive the same arguments as `message'.")
+(defvar eldoc-edit-message-commands
+ (let ((cmds (make-vector 31 0))
+ (re (regexp-opt '("delete" "insert" "edit" "electric" "newline"))))
+ (mapatoms (lambda (s)
+ (and (commandp s)
+ (string-match re (symbol-name s))
+ (intern (symbol-name s) cmds)))
+ obarray)
+ cmds))
+
\f
;;;###autoload
(define-minor-mode eldoc-mode
@@ -168,25 +183,13 @@
(setq eldoc-last-message nil)
(if eldoc-mode
(progn
+ (when eldoc-print-after-edit
+ (setq-local eldoc-message-commands eldoc-edit-message-commands))
(add-hook 'post-command-hook 'eldoc-schedule-timer nil t)
(add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t))
- (remove-hook 'post-command-hook 'eldoc-schedule-timer)
- (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area)))
-
-;;;###autoload
-(define-minor-mode eldoc-post-insert-mode nil
- :group 'eldoc :lighter (:eval (if eldoc-mode ""
- (concat eldoc-minor-mode-string "|i")))
- (setq eldoc-last-message nil)
- (let ((prn-info (lambda ()
- (unless eldoc-mode
- (eldoc-print-current-symbol-info)))))
- (if eldoc-post-insert-mode
- (add-hook 'post-self-insert-hook prn-info nil t)
- (remove-hook 'post-self-insert-hook prn-info t))))
-
-;; FIXME: This changes Emacs's behavior when the file is loaded!
-(add-hook 'eval-expression-minibuffer-setup-hook 'eldoc-post-insert-mode)
+ (kill-local-variable 'eldoc-message-commands)
+ (remove-hook 'post-command-hook 'eldoc-schedule-timer t)
+ (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t)))
;;;###autoload
(defun turn-on-eldoc-mode ()
@@ -264,8 +267,10 @@
;; This doesn't seem to be required for Emacs 19.28 and earlier.
(defun eldoc-pre-command-refresh-echo-area ()
(and eldoc-last-message
- (if (eldoc-display-message-no-interference-p)
- (eldoc-message eldoc-last-message)
+ (if (and (eldoc-display-message-no-interference-p)
+ (symbolp this-command)
+ (intern-soft (symbol-name this-command) eldoc-message-commands))
+ (eldoc-message eldoc-last-message)
(setq eldoc-last-message nil))))
;; Decide whether now is a good time to display a message.
@@ -283,9 +288,7 @@
;; Check various conditions about the current environment that might make
;; it undesirable to print eldoc messages right this instant.
(defun eldoc-display-message-no-interference-p ()
- (and eldoc-mode
- (not executing-kbd-macro)
- (not (and (boundp 'edebug-active) edebug-active))))
+ (not (or executing-kbd-macro (bound-and-true-p edebug-active))))
\f
;;;###autoload
@@ -309,7 +312,7 @@
;; This is run from post-command-hook or some idle timer thing,
;; so we need to be careful that errors aren't ignored.
(with-demoted-errors "eldoc error: %s"
- (and (or (eldoc-display-message-p) eldoc-post-insert-mode)
+ (and (eldoc-display-message-p)
(if eldoc-documentation-function
(eldoc-message (funcall eldoc-documentation-function))
(let* ((current-symbol (eldoc-current-symbol))
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2014-01-09 01:59:19 +0000
+++ lisp/simple.el 2014-01-11 04:28:32 +0000
@@ -1387,6 +1387,7 @@
(lambda ()
(add-hook 'completion-at-point-functions
#'lisp-completion-at-point nil t)
+ (eldoc-mode 1)
(run-hooks 'eval-expression-minibuffer-setup-hook))
(read-from-minibuffer prompt initial-contents
read-expression-map t
next prev parent reply other threads:[~2014-01-11 4:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-05 2:57 bug#16346: 24.3; electric-pair-mode close-paren issue Leo Liu
2014-01-05 11:49 ` João Távora
2014-01-05 15:30 ` Leo Liu
2014-01-05 19:25 ` João Távora
2014-01-05 23:13 ` Stefan Monnier
2014-01-06 0:48 ` Leo Liu
2014-01-09 16:12 ` Stefan Monnier
2014-01-10 3:24 ` Leo Liu
2014-01-10 4:11 ` Leo Liu
2014-01-10 14:14 ` Stefan Monnier
2014-01-10 16:46 ` Leo Liu
2014-01-10 17:20 ` Stefan Monnier
2014-01-11 4:38 ` Leo Liu [this message]
2014-01-11 5:35 ` Stefan Monnier
2014-01-11 6:11 ` Leo Liu
2014-01-12 3:35 ` Stefan Monnier
2014-01-12 4:21 ` Leo Liu
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=m1ppnznneg.fsf@gmail.com \
--to=sdl.web@gmail.com \
--cc=16346@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.