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 14:11:38 +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 1389420738 29660 80.91.229.3 (11 Jan 2014 06:12:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Jan 2014 06:12:18 +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 07:12:24 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 1W1rnx-0002nr-Oz for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Jan 2014 07:12:21 +0100 Original-Received: from localhost ([::1]:60286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1rnx-0003lF-66 for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Jan 2014 01:12:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1rnm-0003l5-Ot for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 01:12:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1rnf-0000Cl-Ai for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 01:12:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1rnf-0000Ch-7i for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 01:12:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W1rne-0005An-B8 for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 01:12: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 06:12: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.138942070919856 (code B ref 16346); Sat, 11 Jan 2014 06:12:02 +0000 Original-Received: (at 16346) by debbugs.gnu.org; 11 Jan 2014 06:11:49 +0000 Original-Received: from localhost ([127.0.0.1]:45972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1rnQ-0005AC-TJ for submit@debbugs.gnu.org; Sat, 11 Jan 2014 01:11:49 -0500 Original-Received: from mail-pb0-f43.google.com ([209.85.160.43]:45800) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1rnO-0005A2-4N for 16346@debbugs.gnu.org; Sat, 11 Jan 2014 01:11:47 -0500 Original-Received: by mail-pb0-f43.google.com with SMTP id rq2so5331016pbb.2 for <16346@debbugs.gnu.org>; Fri, 10 Jan 2014 22:11:45 -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=mc5Lccsgbxt3PTLRDxqlOJ6fYs+Mx6iwRKo9JUGsrkU=; b=KzCCK5t3L4hWrKXVM1guZQAK3MlJyxshfs4yyM3Nzfyxxvu/JTdX4yO+JWG4vNOw+H Ly//nRo4TK7QiVWxC6DtoMJJ3rCIMaMWIOGsn0vj1kYI81mN0PSzTXtwmWifOuGNNbZn hUsgLoL3viaRXldjChPZ3QeF9UWeYZ1ooaoIZYR7Ly6Gwj58PJ0nC6eFHsudJGXMi0N3 Wg70izlxuNEyHG6rX9hqxisge/NOhrc0Jcb8S/Fb+gZkUD/HPgmnGXmr/d8keDFaHt1Y FlZIWjA+oYDvbAoSPZ7kWyFJaCOR0CC31i8qEYup3nEFODb7vs0wGPG0nq7BfIc8gnwL RBHQ== X-Received: by 10.66.142.233 with SMTP id rz9mr16702920pab.71.1389420705161; Fri, 10 Jan 2014 22:11:45 -0800 (PST) Original-Received: from Zeuss-MacBook.local ([123.119.85.96]) by mx.google.com with ESMTPSA id sy10sm27832699pac.15.2014.01.10.22.11.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jan 2014 22:11:44 -0800 (PST) Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoBAMAAAB+0KVeAAAAG1BMVEUAAAA9Cgm3Hx1WWFWA gn+WmJWsrqv4+vcCAwCRl2MkAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAYoA AAGKATOXMFgAAAAHdElNRQfXAQwDNR+ZJmElAAABIklEQVQoz22SPW+DQAyGWUq65qasd9PNUSX4 AZHK2C1rJy5jpDS4IwRVup9dn7GNafpKIPPgzztXFSujqq1eM2n8h22oMkvxI/i9C97kRfMRUN55 dS3BrsAwBXUtMLAO4lryh8kTjOxKpQNniNxAgZOEe4bZwsDTFhKdqZRLNII4OQNHhEuq/RMkm6Cj TnnEA/fk0BorcYn5qA3oaeAxbaBOLrX+9G48NZ2Fzc2tzDM8Q+tMypEOqYHh8mAWaaK3U/cDMOT5 aMZMABgPXc7zPMs1A8DXO756GFJ/4fMEq47hTsAdn5avoxZ4ywl0c2w4Flu2Ybeyb3S+EqxX2DYA H8veJGEDTnHnrXvRaPyt+2kSfK6rfBZ2tUtfP/mR+pR6sX8BUZ/cDV7tvkoAAAAASUVORK5CYII= In-Reply-To: (Stefan Monnier's message of "Sat, 11 Jan 2014 00:35:24 -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:83273 Archived-At: On 2014-01-11 13:35 +0800, Stefan Monnier wrote: > Looks good from here. How do you like its behavior? > > > Stefan Seems to work well for me. If you have no objection I will install the following final patch. Have to build eldoc-edit-message-commands at the time of enabling eldoc-mode because loading packages may add new edit commands. (time penalty is about 0.03s, hope this isn't too bad.) === 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 06:10:50 +0000 @@ -62,6 +62,12 @@ :type 'number :group 'eldoc) +(defcustom eldoc-print-after-edit nil + "If non-nil eldoc info is only shown when editing. +Changing the value requires toggling `eldoc-mode'." + :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 +156,16 @@ "The function used by `eldoc-message' to display messages. It should receive the same arguments as `message'.") +(defun 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 +184,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 +268,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 +289,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 +313,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/progmodes/octave.el' --- lisp/progmodes/octave.el 2014-01-10 10:35:36 +0000 +++ lisp/progmodes/octave.el 2014-01-11 06:02:44 +0000 @@ -154,12 +154,8 @@ ["Insert Function" octave-insert-defun t] ["Update Function File Comment" octave-update-function-file-comment t] "---" - ["Function Syntax Hints" (call-interactively - (if (fboundp 'eldoc-post-insert-mode) - 'eldoc-post-insert-mode - 'eldoc-mode)) - :style toggle :selected (or (bound-and-true-p eldoc-post-insert-mode) - (bound-and-true-p eldoc-mode)) + ["Function Syntax Hints" (eldoc-mode 'toggle) + :style toggle :selected (bound-and-true-p eldoc-mode) :help "Display function signatures after typing `SPC' or `('"] ["Delimiter Matching" show-paren-mode :style toggle :selected show-paren-mode === 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