comparison lisp/skeleton.el @ 36967:cebc3019a629

(skeleton-internal-list): Fix bogus logic. (skeleton-pair-insert-maybe): Don't pair after a backslash.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 23 Mar 2001 17:49:58 +0000
parents 1b871d9c3be4
children 153f1b1f2efd
comparison
equal deleted inserted replaced
36966:d672c5699e29 36967:cebc3019a629
262 262
263 \\n go to next line and indent according to mode 263 \\n go to next line and indent according to mode
264 _ interesting point, interregion here 264 _ interesting point, interregion here
265 > indent line (or interregion if > _) according to major mode 265 > indent line (or interregion if > _) according to major mode
266 @ add position to `skeleton-positions' 266 @ add position to `skeleton-positions'
267 & do next ELEMENT if previous moved point 267 & do next ELEMENT iff previous moved point
268 | do next ELEMENT if previous didn't move point 268 | do next ELEMENT iff previous didn't move point
269 -num delete num preceding characters (see `skeleton-untabify') 269 -num delete num preceding characters (see `skeleton-untabify')
270 resume: skipped, continue here if quit is signaled 270 resume: skipped, continue here if quit is signaled
271 nil skipped 271 nil skipped
272 272
273 After termination, point will be positioned at the first occurrence 273 After termination, point will be positioned at the first occurrence
381 (line (buffer-substring start 381 (line (buffer-substring start
382 (save-excursion (end-of-line) (point)))) 382 (save-excursion (end-of-line) (point))))
383 opoint) 383 opoint)
384 (or str 384 (or str
385 (setq str `(setq str (skeleton-read ',(car skeleton) nil ,recursive)))) 385 (setq str `(setq str (skeleton-read ',(car skeleton) nil ,recursive))))
386 (when (and (eq (car skeleton) '\n) 386 (when (and (eq (cadr skeleton) '\n)
387 (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))) 387 (<= (current-column) (current-indentation)))
388 (setq skeleton (cons '> (cdr skeleton)))) 388 (setq skeleton (cons nil (cons '> (cddr skeleton)))))
389 (while (setq skeleton-modified (eq opoint (point)) 389 (while (setq skeleton-modified (eq opoint (point))
390 opoint (point) 390 opoint (point)
391 skeleton (cdr skeleton)) 391 skeleton (cdr skeleton))
392 (condition-case quit 392 (condition-case quit
393 (skeleton-internal-1 (car skeleton)) 393 (skeleton-internal-1 (car skeleton))
507 507
508 (defvar skeleton-pair-on-word nil 508 (defvar skeleton-pair-on-word nil
509 "*If this is nil, paired insertion is inhibited before or inside a word.") 509 "*If this is nil, paired insertion is inhibited before or inside a word.")
510 510
511 511
512 (defvar skeleton-pair-filter (lambda ()) 512 (defvar skeleton-pair-filter (lambda () nil)
513 "Attempt paired insertion if this function returns nil, before inserting. 513 "Attempt paired insertion if this function returns nil, before inserting.
514 This allows for context-sensitive checking whether pairing is appropriate.") 514 This allows for context-sensitive checking whether pairing is appropriate.")
515 515
516 516
517 (defvar skeleton-pair-alist () 517 (defvar skeleton-pair-alist ()
528 528
529 With no ARG, if `skeleton-pair' is non-nil, pairing can occur. If the region 529 With no ARG, if `skeleton-pair' is non-nil, pairing can occur. If the region
530 is visible the pair is wrapped around it depending on `skeleton-autowrap'. 530 is visible the pair is wrapped around it depending on `skeleton-autowrap'.
531 Else, if `skeleton-pair-on-word' is non-nil or we are not before or inside a 531 Else, if `skeleton-pair-on-word' is non-nil or we are not before or inside a
532 word, and if `skeleton-pair-filter' returns nil, pairing is performed. 532 word, and if `skeleton-pair-filter' returns nil, pairing is performed.
533 Pairing is also prohibited if we are right after a quoting character
534 such as backslash.
533 535
534 If a match is found in `skeleton-pair-alist', that is inserted, else 536 If a match is found in `skeleton-pair-alist', that is inserted, else
535 the defaults are used. These are (), [], {}, <> and `' for the 537 the defaults are used. These are (), [], {}, <> and `' for the
536 symmetrical ones, and the same character twice for the others." 538 symmetrical ones, and the same character twice for the others."
537 (interactive "*P") 539 (interactive "*P")
539 (or (eq last-command 'mouse-drag-region) 541 (or (eq last-command 'mouse-drag-region)
540 (and transient-mark-mode mark-active)))) 542 (and transient-mark-mode mark-active))))
541 (skeleton-end-hook)) 543 (skeleton-end-hook))
542 (if (or arg 544 (if (or arg
543 (not skeleton-pair) 545 (not skeleton-pair)
546 (memq (char-syntax (preceding-char)) '(?\\ ?/))
544 (and (not mark) 547 (and (not mark)
545 (or overwrite-mode 548 (or overwrite-mode
546 (if (not skeleton-pair-on-word) (looking-at "\\w")) 549 (if (not skeleton-pair-on-word) (looking-at "\\w"))
547 (funcall skeleton-pair-filter)))) 550 (funcall skeleton-pair-filter))))
548 (self-insert-command (prefix-numeric-value arg)) 551 (self-insert-command (prefix-numeric-value arg))