diff options
author | Taylor R Campbell <campbell@mumble.net> | 2010-09-17 19:39:38 +0000 |
---|---|---|
committer | Taylor R Campbell <campbell@mumble.net> | 2010-09-17 19:39:38 +0000 |
commit | 896c165a67479503df63dc7cf86b2c96cf86c102 (patch) | |
tree | 133057b5264e9c2718b21432d3bc9ec1931d6e1f | |
parent | 929e5471e507f532f59682e54d9bf9a52898f3cf (diff) |
Implement variable `paredit-space-for-delimiter-predicates'.
Ignore-this: 45e159465eb88cd994e493dfccc9e495
darcs-hash:20100917193938-00fcc-8567c43f6d3941b49d5f4d848b292fe35af19d19
-rw-r--r-- | paredit.el | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -756,6 +756,22 @@ If such a comment exists, delete the comment (including all leading (eq (nth 5 beginning-state) ; 5. t if following char (nth 5 end-state))))))) ; quote +(defvar paredit-space-for-delimiter-predicates nil + "List of predicates for whether to put space by delimiter at point. +Each predicate is a function that is is applied to two arguments, ENDP + and DELIMITER, and that returns a boolean saying whether to put a + space next to the delimiter -- before the delimiter if ENDP is false, + after the delimiter if ENDP is true. +If any predicate returns false, no space is inserted: every predicate + has veto power. +Each predicate may assume that the point is not at the beginning of the + buffer, if ENDP is false, or at the end of the buffer, if ENDP is + true; and that the point is not preceded, if ENDP is false, or + followed, if ENDP is true, by a word or symbol constituent, a quote, + or the delimiter matching DELIMITER. +Each predicate should examine only text before the point, if ENDP is + false, or only text after the point, if ENDP is true.") + (defun paredit-space-for-delimiter-p (endp delimiter) ;; If at the buffer limit, don't insert a space. If there is a word, ;; symbol, other quote, or non-matching parenthesis delimiter (i.e. a @@ -768,7 +784,12 @@ If such a comment exists, delete the comment (including all leading (and matching (char-syntax matching))) (and (not endp) (eq ?\" (char-syntax delimiter)) - ?\) ))))) + ?\) ))) + (catch 'exit + (dolist (predicate paredit-space-for-delimiter-predicates) + (if (not (funcall predicate endp delimiter)) + (throw 'exit nil))) + t))) (defun paredit-move-past-close-and-reindent (close) (let ((open (paredit-missing-close))) |