Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

* Tweaked autopair-skip-whitespace a bit

git-svn-id: 56c4f94e-c24a-11de-a250-c7f789e21d83
  • Loading branch information...
commit 5410708e8577bb2138529429de83344ff9aef5e4 1 parent f61bdc0
joaotavora authored
Showing with 12 additions and 14 deletions.
  1. +12 −14 autopair.el
26 autopair.el
@@ -426,7 +426,7 @@ A list of four elements is returned:
-(defun autopair-find-pair (delim)
+(defun autopair-find-pair (delim &optional closing)
(when (and delim
(integerp delim))
(let ((syntax-entry (aref (syntax-table) delim)))
@@ -435,7 +435,8 @@ A list of four elements is returned:
((or (eq (syntax-class syntax-entry) (car (string-to-syntax "\"")))
(eq (syntax-class syntax-entry) (car (string-to-syntax "$"))))
- ((eq (syntax-class syntax-entry) (car (string-to-syntax ")")))
+ ((and (not closing)
+ (eq (syntax-class syntax-entry) (car (string-to-syntax ")"))))
(cdr syntax-entry))
(some #'(lambda (pair-list)
@@ -445,13 +446,8 @@ A list of four elements is returned:
(remove-if-not #'listp autopair-extra-pairs)))))))
-(unless (fboundp 'region-active-p)
- (defun region-active-p ()
- "Predicate missing in emacs 22"
- (and transient-mark-mode mark-active)))
(defun autopair-calculate-wrap-action ()
- (when (region-active-p)
+ (when (and transient-mark-mode mark-active)
(when (> (point) (mark))
@@ -499,7 +495,7 @@ Set this to to 'help-balance to be more criterious when wrapping.")
(defvar autopair-skip-whitespace nil
"If non-nil also skip over whitespace when skipping closing delimiters.
-This will be most useful in lisp-like languages where you want
+If set to 'chomp, this will be most useful in lisp-like languages where you want
lots of )))))....")
(defvar autopair-blink (if (boundp 'blink-matching-paren)
@@ -663,7 +659,7 @@ returned) and uplisting stops there."
(setq autopair-inserted (autopair-calculate-inserted))
(when (char-before)
- (setq autopair-action (list 'backspace (autopair-find-pair (char-before)) (point))))
+ (setq autopair-action (list 'backspace (autopair-find-pair (char-before) 'closing) (point))))
(autopair-fallback (kbd "DEL")))
(put 'autopair-backspace 'function-documentation
'(concat "Possibly delete a pair of paired delimiters.\n\n"
@@ -854,11 +850,13 @@ by this command. Then place point after the first, indented.\n\n"
(when autopair-skip-whitespace
(setq skipped (save-excursion (skip-chars-forward "\s\n\t"))))
(when (eq autopair-inserted (char-after (+ (point) skipped)))
+ (backward-delete-char 1)
(unless (zerop skipped) (autopair-blink (+ (point) skipped)))
- (if (zerop skipped)
- (progn (backward-char 1) (delete-char 1) (forward-char))
- (delete-char (1+ skipped)))
- (autopair-blink-matching-open))))
+ (if (eq autopair-skip-whitespace 'chomp)
+ (delete-char skipped)
+ (forward-char skipped))
+ (forward-char))
+ (autopair-blink-matching-open)))
(;; autodelete closing delimiter
(and (eq 'backspace action)
(eq pair (char-after (point))))

0 comments on commit 5410708

Please sign in to comment.
Something went wrong with that request. Please try again.