[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16346: 24.3; electric-pair-mode close-paren issue
From: |
Leo Liu |
Subject: |
bug#16346: 24.3; electric-pair-mode close-paren issue |
Date: |
Sat, 11 Jan 2014 14:11:38 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (OS X 10.9.1) |
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
- bug#16346: 24.3; electric-pair-mode close-paren issue, (continued)
- bug#16346: 24.3; electric-pair-mode close-paren issue, Stefan Monnier, 2014/01/05
- bug#16346: 24.3; electric-pair-mode close-paren issue, Leo Liu, 2014/01/05
- bug#16346: 24.3; electric-pair-mode close-paren issue, Stefan Monnier, 2014/01/09
- bug#16346: 24.3; electric-pair-mode close-paren issue, Leo Liu, 2014/01/09
- bug#16346: 24.3; electric-pair-mode close-paren issue, Leo Liu, 2014/01/09
- bug#16346: 24.3; electric-pair-mode close-paren issue, Stefan Monnier, 2014/01/10
- bug#16346: 24.3; electric-pair-mode close-paren issue, Leo Liu, 2014/01/10
- bug#16346: 24.3; electric-pair-mode close-paren issue, Stefan Monnier, 2014/01/10
- bug#16346: 24.3; electric-pair-mode close-paren issue, Leo Liu, 2014/01/10
- bug#16346: 24.3; electric-pair-mode close-paren issue, Stefan Monnier, 2014/01/11
- bug#16346: 24.3; electric-pair-mode close-paren issue,
Leo Liu <=
- bug#16346: 24.3; electric-pair-mode close-paren issue, Stefan Monnier, 2014/01/11
- bug#16346: 24.3; electric-pair-mode close-paren issue, Leo Liu, 2014/01/11