unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
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: Fri, 10 Jan 2014 12:11:26 +0800	[thread overview]
Message-ID: <m161psiihd.fsf@gmail.com> (raw)
In-Reply-To: <m1ha9ciknr.fsf@gmail.com> (Leo Liu's message of "Fri, 10 Jan 2014 11:24:24 +0800")

On 2014-01-10 11:24 +0800, Leo Liu wrote:
> But maybe eldoc-post-insert-mode (maybe even a new name
> eldoc-edit-mode?) can check on char changes instead? Is this better?

Stefan, do you think this is better? With the following patch,
eldoc-edit-mode no longer depends on post-self-insert-hook.

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 3a7f08f5..1da6c0ab 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -173,19 +173,29 @@ (define-minor-mode eldoc-mode
    (remove-hook 'post-command-hook 'eldoc-schedule-timer)
    (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area)))
 
+(defvar-local eldoc-edit-should-print nil)
+
+(defun eldoc-after-change (beg end len)
+  (and (or (> len 0) (and (zerop len) (> end beg)))
+       (setq eldoc-edit-should-print t)))
+
 ;;;###autoload
-(define-minor-mode eldoc-post-insert-mode nil
+(define-minor-mode eldoc-edit-mode nil
   :group 'eldoc :lighter (:eval (if eldoc-mode ""
-				  (concat eldoc-minor-mode-string "|i")))
+				  (concat eldoc-minor-mode-string "|e")))
   (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))))
+		    (when (and (not eldoc-mode) eldoc-edit-should-print)
+		      (ignore-errors (eldoc-print-current-symbol-info))
+		      (setq eldoc-edit-should-print nil)))))
+    (if eldoc-edit-mode
+	(progn
+	  (add-hook 'post-command-hook prn-info nil t)
+	  (add-hook 'after-change-functions 'eldoc-after-change nil t))
+      (remove-hook 'post-command-hook prn-info t)
+      (remove-hook 'after-change-functions 'eldoc-after-change t))))
 
-(add-hook 'eval-expression-minibuffer-setup-hook 'eldoc-post-insert-mode)
+(add-hook 'eval-expression-minibuffer-setup-hook 'eldoc-edit-mode)
 
 ;;;###autoload
 (defun turn-on-eldoc-mode ()
@@ -309,7 +319,7 @@ (defvar eldoc-documentation-function nil
 
 (defun eldoc-print-current-symbol-info ()
   (condition-case err
-      (and (or (eldoc-display-message-p) eldoc-post-insert-mode)
+      (and (or (eldoc-display-message-p) eldoc-edit-mode)
 	   (if eldoc-documentation-function
 	       (eldoc-message (funcall eldoc-documentation-function))
 	     (let* ((current-symbol (eldoc-current-symbol))





  reply	other threads:[~2014-01-10  4:11 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 [this message]
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
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=m161psiihd.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).