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: Sat, 11 Jan 2014 12:38:31 +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 1389415155 14866 80.91.229.3 (11 Jan 2014 04:39:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Jan 2014 04:39: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 Sat Jan 11 05:39: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 1W1qLw-0002xq-Fq for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Jan 2014 05:39:20 +0100 Original-Received: from localhost ([::1]:60160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1qLw-0003kR-3d for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Jan 2014 23:39:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1qLm-0003kJ-2M for bug-gnu-emacs@gnu.org; Fri, 10 Jan 2014 23:39:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1qLe-0003mu-Oi for bug-gnu-emacs@gnu.org; Fri, 10 Jan 2014 23:39:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1qLe-0003mq-Ks for bug-gnu-emacs@gnu.org; Fri, 10 Jan 2014 23:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W1qLe-0002Tm-4Z for bug-gnu-emacs@gnu.org; Fri, 10 Jan 2014 23:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Leo Liu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Jan 2014 04:39:02 +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.13894151219487 (code B ref 16346); Sat, 11 Jan 2014 04:39:02 +0000 Original-Received: (at 16346) by debbugs.gnu.org; 11 Jan 2014 04:38:41 +0000 Original-Received: from localhost ([127.0.0.1]:45928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1qLI-0002Sx-Il for submit@debbugs.gnu.org; Fri, 10 Jan 2014 23:38:41 -0500 Original-Received: from mail-pa0-f47.google.com ([209.85.220.47]:36181) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1qLF-0002Sl-Sf for 16346@debbugs.gnu.org; Fri, 10 Jan 2014 23:38:38 -0500 Original-Received: by mail-pa0-f47.google.com with SMTP id kq14so5581224pab.20 for <16346@debbugs.gnu.org>; Fri, 10 Jan 2014 20:38:37 -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=x8naBFeGiCpZlmmbCErdydQLnKdL2Onqr6uiSxUyZZg=; b=uLMR+1DusKlan9Di315UcNkY1fctA4r2Mdu2DtjWptMFV5xhX7oDTXEtICjtFMx4da 1Tlrrk/xJO4u604WxeZK/54+hEowMOCucIi1M0WoAFBKqup2rgg0Udk4YeQC3jfIXWac SqeMhiUsLyk638Lnggp2fVH47ASCQ0bYxDQAFzkPwCEIVs9HSFuTUbZM4DJIIixfiyhk 21L51/b1UeJ4zzl5a8ze0l1vtIa0BRIDsk2/O1++YF5lQsRjSNWj2VtOIyq4eN77cHAz hvPX5x48IEI23/l8C8wQdjLYdzzh6ykRo9pWZKv0J6EVqgDnPWyXe8Y3vr4LKF+3rBEF AYLg== X-Received: by 10.66.248.227 with SMTP id yp3mr16055080pac.116.1389415116928; Fri, 10 Jan 2014 20:38:36 -0800 (PST) Original-Received: from Zeuss-MacBook.local ([123.119.85.96]) by mx.google.com with ESMTPSA id dq3sm21187570pbc.35.2014.01.10.20.38.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jan 2014 20:38:36 -0800 (PST) Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoBAMAAAB+0KVeAAAAElBMVEUAAAAAAP+LRRP0pGC+ vr7///+7mT1iAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9cBBwMO DhglKe4AAAEsSURBVCjPbZNBboQwDEV/Cd4X9QJRThApmn0XYW+Jyf2v0m+HhqDBgiAe9rcTG7QH w/1Vn2Ar8gBb/ocywSN3qK9T3z4eFDB4eApocBpeBs1RSykoJd8gQcm8pGmHXFso3ajnmsqV0TnY DQkOfXUfN5NwaI7AWTVOyEhcu1aHmdWItHddUVUcUgUBCkitu8V6ditHVOVdqzl2EQ1ZVGTbdK0V 7cqn8vWzoU5Q/bF9Y/Y0cRU1xwkys5dJ+Dt6pBDWifcNQml8Gh2JVmPSoQzo7en0grswkxrUGYJ7 0hSxxAGr7ZMwYcHIzprpi7TENEE1xtiYxixRlCfPBsUUrwHD7uGIwATrbnODJcVrPpVn3hxiGloe m/S+z3CtuzUSMo83N4DPH+F0evwR3P4A2k+75838OKQAAAAASUVORK5CYII= In-Reply-To: (Stefan Monnier's message of "Fri, 10 Jan 2014 12:20:49 -0500") 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:83270 Archived-At: 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)) + ;;;###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)))) ;;;###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