aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/elec-pair.el45
2 files changed, 30 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8ebb68622f5..2dad756b618 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12014-02-23 Juanma Barranquero <lekktu@gmail.com>
2
3 * elec-pair.el (electric-pair-text-syntax-table)
4 (electric-pair-syntax-info, electric-pair--syntax-ppss)
5 (electric-pair--balance-info, electric-pair-mode): Fix docstring typos.
6 (electric-pair--looking-at-unterminated-string-p): Doc fix.
7 (electric-pair--inside-string-p): Doc fix. Use `let', not `let*'.
8
12014-02-22 Glenn Morris <rgm@gnu.org> 92014-02-22 Glenn Morris <rgm@gnu.org>
2 10
3 * imenu.el (imenu--generic-function): Doc fix. 11 * imenu.el (imenu--generic-function): Doc fix.
diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index 8562801979d..52ad9bc0249 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -163,7 +163,7 @@ return value is considered instead."
163 "Syntax table used when pairing inside comments and strings. 163 "Syntax table used when pairing inside comments and strings.
164 164
165`electric-pair-mode' considers this syntax table only when point in inside 165`electric-pair-mode' considers this syntax table only when point in inside
166quotes or comments. If lookup fails here, `electric-pair-text-pairs' will 166quotes or comments. If lookup fails here, `electric-pair-text-pairs' will
167be considered.") 167be considered.")
168 168
169(defun electric-pair-backward-delete-char (n &optional killflag untabify) 169(defun electric-pair-backward-delete-char (n &optional killflag untabify)
@@ -214,7 +214,7 @@ SYNTAX is COMMAND-EVENT's syntax character. PAIR is
214COMMAND-EVENT's pair. UNCONDITIONAL indicates the variables 214COMMAND-EVENT's pair. UNCONDITIONAL indicates the variables
215`electric-pair-pairs' or `electric-pair-text-pairs' were used to 215`electric-pair-pairs' or `electric-pair-text-pairs' were used to
216lookup syntax. STRING-OR-COMMENT-START indicates that point is 216lookup syntax. STRING-OR-COMMENT-START indicates that point is
217inside a comment of string." 217inside a comment or string."
218 (let* ((pre-string-or-comment (or (bobp) 218 (let* ((pre-string-or-comment (or (bobp)
219 (nth 8 (save-excursion 219 (nth 8 (save-excursion
220 (syntax-ppss (1- (point))))))) 220 (syntax-ppss (1- (point)))))))
@@ -252,7 +252,7 @@ inside a comment of string."
252(defun electric-pair--syntax-ppss (&optional pos where) 252(defun electric-pair--syntax-ppss (&optional pos where)
253 "Like `syntax-ppss', but sometimes fallback to `parse-partial-sexp'. 253 "Like `syntax-ppss', but sometimes fallback to `parse-partial-sexp'.
254 254
255WHERE is list defaulting to '(string comment) and indicates 255WHERE is a list defaulting to '(string comment) and indicates
256when to fallback to `parse-partial-sexp'." 256when to fallback to `parse-partial-sexp'."
257 (let* ((pos (or pos (point))) 257 (let* ((pos (or pos (point)))
258 (where (or where '(string comment))) 258 (where (or where '(string comment)))
@@ -267,43 +267,42 @@ when to fallback to `parse-partial-sexp'."
267 (parse-partial-sexp (point-min) pos) 267 (parse-partial-sexp (point-min) pos)
268 quick-ppss-at-pos)))) 268 quick-ppss-at-pos))))
269 269
270;; Balancing means controlling pairing and skipping of parentheses so 270;; Balancing means controlling pairing and skipping of parentheses
271;; that, if possible, the buffer ends up at least as balanced as 271;; so that, if possible, the buffer ends up at least as balanced as
272;; before, if not more. The algorithm is slightly complex because some 272;; before, if not more. The algorithm is slightly complex because
273;; situations like "()))" need pairing to occur at the end but not at 273;; some situations like "()))" need pairing to occur at the end but
274;; the beginning. Balancing should also happen independently for 274;; not at the beginning. Balancing should also happen independently
275;; different types of parentheses, so that having your {}'s unbalanced 275;; for different types of parentheses, so that having your {}'s
276;; doesn't keep `electric-pair-mode' from balancing your ()'s and your 276;; unbalanced doesn't keep `electric-pair-mode' from balancing your
277;; []'s. 277;; ()'s and your []'s.
278(defun electric-pair--balance-info (direction string-or-comment) 278(defun electric-pair--balance-info (direction string-or-comment)
279 "Examine lists forward or backward according to DIRECTION's sign. 279 "Examine lists forward or backward according to DIRECTION's sign.
280 280
281STRING-OR-COMMENT is info suitable for running `parse-partial-sexp'. 281STRING-OR-COMMENT is info suitable for running `parse-partial-sexp'.
282 282
283Return a cons of two descriptions (MATCHED-P . PAIR) for the 283Return a cons of two descriptions (MATCHED-P . PAIR) for the
284innermost and outermost lists that enclose point. The outermost 284innermost and outermost lists that enclose point. The outermost
285list enclosing point is either the first top-level or first 285list enclosing point is either the first top-level or first
286mismatched list found by listing up. 286mismatched list found by listing up.
287 287
288If the outermost list is matched, don't rely on its PAIR. If 288If the outermost list is matched, don't rely on its PAIR.
289point is not enclosed by any lists, return ((T) . (T))." 289If point is not enclosed by any lists, return ((t) . (t))."
290 (let* (innermost 290 (let* (innermost
291 outermost 291 outermost
292 (table (if string-or-comment 292 (table (if string-or-comment
293 electric-pair-text-syntax-table 293 electric-pair-text-syntax-table
294 (syntax-table))) 294 (syntax-table)))
295 (at-top-level-or-equivalent-fn 295 (at-top-level-or-equivalent-fn
296 ;; called when `scan-sexps' ran perfectly, when when it 296 ;; called when `scan-sexps' ran perfectly, when it found
297 ;; found a parenthesis pointing in the direction of 297 ;; a parenthesis pointing in the direction of travel.
298 ;; travel. Also when travel started inside a comment and 298 ;; Also when travel started inside a comment and exited it.
299 ;; exited it
300 #'(lambda () 299 #'(lambda ()
301 (setq outermost (list t)) 300 (setq outermost (list t))
302 (unless innermost 301 (unless innermost
303 (setq innermost (list t))))) 302 (setq innermost (list t)))))
304 (ended-prematurely-fn 303 (ended-prematurely-fn
305 ;; called when `scan-sexps' crashed against a parenthesis 304 ;; called when `scan-sexps' crashed against a parenthesis
306 ;; pointing opposite the direction of travel. After 305 ;; pointing opposite the direction of travel. After
307 ;; traversing that character, the idea is to travel one sexp 306 ;; traversing that character, the idea is to travel one sexp
308 ;; in the opposite direction looking for a matching 307 ;; in the opposite direction looking for a matching
309 ;; delimiter. 308 ;; delimiter.
@@ -366,7 +365,7 @@ point is not enclosed by any lists, return ((T) . (T))."
366 (cons innermost outermost))) 365 (cons innermost outermost)))
367 366
368(defun electric-pair--looking-at-unterminated-string-p (char) 367(defun electric-pair--looking-at-unterminated-string-p (char)
369 "Say if following string starts with CHAR and is unterminated." 368 "Return non-nil if following string starts with CHAR and is unterminated."
370 ;; FIXME: ugly/naive 369 ;; FIXME: ugly/naive
371 (save-excursion 370 (save-excursion
372 (skip-chars-forward (format "^%c" char)) 371 (skip-chars-forward (format "^%c" char))
@@ -380,14 +379,14 @@ point is not enclosed by any lists, return ((T) . (T))."
380 (scan-error t))))) 379 (scan-error t)))))
381 380
382(defun electric-pair--inside-string-p (char) 381(defun electric-pair--inside-string-p (char)
383 "Say if point is inside a string started by CHAR. 382 "Return non-nil if point is inside a string started by CHAR.
384 383
385A comments text is parsed with `electric-pair-text-syntax-table'. 384A comments text is parsed with `electric-pair-text-syntax-table'.
386Also consider strings within comments, but not strings within 385Also consider strings within comments, but not strings within
387strings." 386strings."
388 ;; FIXME: could also consider strings within strings by examining 387 ;; FIXME: could also consider strings within strings by examining
389 ;; delimiters. 388 ;; delimiters.
390 (let* ((ppss (electric-pair--syntax-ppss (point) '(comment)))) 389 (let ((ppss (electric-pair--syntax-ppss (point) '(comment))))
391 (memq (nth 3 ppss) (list t char)))) 390 (memq (nth 3 ppss) (list t char))))
392 391
393(defun electric-pair-inhibit-if-helps-balance (char) 392(defun electric-pair-inhibit-if-helps-balance (char)
@@ -549,7 +548,7 @@ the mode if ARG is omitted or nil.
549 548
550Electric Pair mode is a global minor mode. When enabled, typing 549Electric Pair mode is a global minor mode. When enabled, typing
551an open parenthesis automatically inserts the corresponding 550an open parenthesis automatically inserts the corresponding
552closing parenthesis. \(Likewise for brackets, etc.)." 551closing parenthesis. (Likewise for brackets, etc.)."
553 :global t :group 'electricity 552 :global t :group 'electricity
554 (if electric-pair-mode 553 (if electric-pair-mode
555 (progn 554 (progn