aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2010-09-01 16:41:17 +0200
committerStefan Monnier <[email protected]>2010-09-01 16:41:17 +0200
commit8f4e9110cad4aa7fbbfa4765221f4a6392ca7af3 (patch)
tree3dee31a308543acddc9363cd2e6638f962f8c695 /lisp/simple.el
parent4de81ee0d223f3ffda6c22ac630ace93f0fc47f7 (diff)
* lisp/simple.el (blink-paren-function): Move from C to here.
(blink-paren-post-self-insert-function): New function. (post-self-insert-hook): Use it. * src/cmds.c (Vblink_paren_function): Remove. (internal_self_insert): Make it insert N chars at a time. Don't call blink-paren-function. (Fself_insert_command): Adjust accordingly. (syms_of_cmds): Don't declare blink-paren-function.
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 6a99f78585..610698cc09 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5607,7 +5607,23 @@ it skips the contents of comments that end before point."
(message "Matches %s"
(substring-no-properties open-paren-line-string)))))))))
-(setq blink-paren-function 'blink-matching-open)
+(defvar blink-paren-function 'blink-matching-open
+ "Function called, if non-nil, whenever a close parenthesis is inserted.
+More precisely, a char with closeparen syntax is self-inserted.")
+
+(defun blink-paren-post-self-insert-function ()
+ (when (and (eq (char-before) last-command-event) ; Sanity check.
+ (memq (char-syntax last-command-event) '(?\) ?\$))
+ blink-paren-function
+ (not executing-kbd-macro)
+ (not noninteractive))
+ (funcall blink-paren-function)))
+
+(add-hook 'post-self-insert-hook #'blink-paren-post-self-insert-function
+ ;; Most likely, this hook is nil, so this arg doesn't matter,
+ ;; but I use it as a reminder that this function usually
+ ;; likes to be run after others since it does `sit-for'.
+ 'append)
;; This executes C-g typed while Emacs is waiting for a command.
;; Quitting out of a program does not go through here;