From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Liu Newsgroups: gmane.emacs.bugs Subject: bug#16346: 24.3; electric-pair-mode close-paren issue Date: Fri, 10 Jan 2014 12:11:26 +0800 Message-ID: References: <878uuuy7g1.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1389327135 24465 80.91.229.3 (10 Jan 2014 04:12:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Jan 2014 04:12:15 +0000 (UTC) Cc: 16346@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 10 05:12:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W1TSG-00086X-Io for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Jan 2014 05:12:20 +0100 Original-Received: from localhost ([::1]:55178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1TSG-0002SB-33 for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Jan 2014 23:12:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1TS5-0002Rs-Om for bug-gnu-emacs@gnu.org; Thu, 09 Jan 2014 23:12:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1TRy-0007Bg-EJ for bug-gnu-emacs@gnu.org; Thu, 09 Jan 2014 23:12:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1TRy-0007Ba-Ai for bug-gnu-emacs@gnu.org; Thu, 09 Jan 2014 23:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W1TRx-0006bM-Mn for bug-gnu-emacs@gnu.org; Thu, 09 Jan 2014 23:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Leo Liu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Jan 2014 04:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16346 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16346-submit@debbugs.gnu.org id=B16346.138932709925331 (code B ref 16346); Fri, 10 Jan 2014 04:12:01 +0000 Original-Received: (at 16346) by debbugs.gnu.org; 10 Jan 2014 04:11:39 +0000 Original-Received: from localhost ([127.0.0.1]:44553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1TRa-0006aU-JI for submit@debbugs.gnu.org; Thu, 09 Jan 2014 23:11:38 -0500 Original-Received: from mail-pb0-f53.google.com ([209.85.160.53]:56453) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1TRZ-0006aK-D9 for 16346@debbugs.gnu.org; Thu, 09 Jan 2014 23:11:37 -0500 Original-Received: by mail-pb0-f53.google.com with SMTP id ma3so3907199pbc.12 for <16346@debbugs.gnu.org>; Thu, 09 Jan 2014 20:11:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:face:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=aftPYWWUCbTxtYIJG0ChXCYOxFSepButT5k1IptZmyI=; b=tcvTasHYCm9+/JietF9PaIRHwq639zmOfMQ80mxAn23MBpeMflZVnC8mQ9Ch41KdPy mCChJkcDJsxAwUSdEawEnCfC2rG0jJYBcm6PVsYFcoVxvKTC5uO99zTGkQ7Oh99dxec1 FFwEOJguciv+RakwAV7+bSlGMitNyjTXPRnH3LTon5EhnVzoHyA3a/A/LBqTPPEoAMiJ OC1tNSnQLci9kFCqV7XXURjyC0IxAw7Z8a2mtIAI2elRyCzeYekoVUwpP9//uzGLBUy6 8DuQ83oXA3hLm0BIVKbb5Z7bZMTefVuaq1CzO6oJqDbhlAP6CZyfxnj2xDIt6T3dnsnG wj7A== X-Received: by 10.67.3.68 with SMTP id bu4mr8321288pad.144.1389327096620; Thu, 09 Jan 2014 20:11:36 -0800 (PST) Original-Received: from Zeuss-MacBook.local ([221.217.244.203]) by mx.google.com with ESMTPSA id pq1sm13722068pbc.8.2014.01.09.20.11.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jan 2014 20:11:36 -0800 (PST) Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoAgMAAADxkFD+AAAADFBMVEUvT09qWs3/pQD///+J kUVcAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9cBBwMLOd3veKQA AACuSURBVBjTldE9CgIxEAXgB+lEyFUC2wo5ikdZ8DSypxhMY7H9VuIVwlqkGRgnm59VsHGafIQ3 CZlAtmKIRaHETgYa12lqvEsPYKf8wXHsPGfqPaUM0g9aJPKFXkmNQmSDqwzz4Fpgpz+6WAPY2z5o uPJJpu0uypcl4nyCibMLQ8lCiVjayLoQvw5LsVKQuHPRR958HZbOcVsKeepcLxpByjycGvnKmY+c MBvrtyjfe0vmuLvdq/kAAAAASUVORK5CYII= In-Reply-To: (Leo Liu's message of "Fri, 10 Jan 2014 11:24:24 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (OS X 10.9.1) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:83207 Archived-At: 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))