aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-05-26 01:02:31 +0000
committerStefan Monnier2003-05-26 01:02:31 +0000
commitc93992b3835dcd9f7ceea9ea0c6c50dc4ab14f47 (patch)
tree11030e16502afd8c5da05e059e30a1e52200ce10
parent01e1a81920aa4e805b1c2ab0e13472094e991979 (diff)
downloademacs-c93992b3835dcd9f7ceea9ea0c6c50dc4ab14f47.tar.gz
emacs-c93992b3835dcd9f7ceea9ea0c6c50dc4ab14f47.zip
(skeleton-internal-1): Don't loop if interactor of subskeleton is nil.
(skeleton-pair-default-alist): New var. (skeleton-pair-insert-maybe): Use it.
-rw-r--r--lisp/skeleton.el54
1 files changed, 29 insertions, 25 deletions
diff --git a/lisp/skeleton.el b/lisp/skeleton.el
index aea5aa77236..9c018ac7b25 100644
--- a/lisp/skeleton.el
+++ b/lisp/skeleton.el
@@ -399,10 +399,13 @@ automatically, and you are prompted to fill in the variable parts.")))
399 (push (point) skeleton-positions)) 399 (push (point) skeleton-positions))
400 ((eq 'quote (car-safe element)) 400 ((eq 'quote (car-safe element))
401 (eval (nth 1 element))) 401 (eval (nth 1 element)))
402 ((or (stringp (car-safe element)) 402 ((and (consp element)
403 (consp (car-safe element))) 403 (or (stringp (car element)) (listp (car element))))
404 ;; Don't forget: `symbolp' is also true for nil.
404 (if (symbolp (car-safe (car element))) 405 (if (symbolp (car-safe (car element)))
405 (while (skeleton-internal-list element nil t)) 406 (while (and (skeleton-internal-list element nil t)
407 ;; If the interactor is nil, don't infinite loop.
408 (car element)))
406 (setq literal (car element)) 409 (setq literal (car element))
407 (while literal 410 (while literal
408 (skeleton-internal-list element (car literal)) 411 (skeleton-internal-list element (car literal))
@@ -462,6 +465,12 @@ Each alist element, which looks like (ELEMENT ...), is passed to
462 465
463Elements might be (?` ?` _ \"''\"), (?\\( ? _ \" )\") or (?{ \\n > _ \\n ?} >).") 466Elements might be (?` ?` _ \"''\"), (?\\( ? _ \" )\") or (?{ \\n > _ \\n ?} >).")
464 467
468(defvar skeleton-pair-default-alist '((?( _ ?)) (?\))
469 (?[ _ ?]) (?\])
470 (?{ _ ?}) (?\})
471 (?< _ ?>) (?\>)
472 (?« _ ?») (?\»)
473 (?` _ ?')))
465 474
466;;;###autoload 475;;;###autoload
467(defun skeleton-pair-insert-maybe (arg) 476(defun skeleton-pair-insert-maybe (arg)
@@ -478,28 +487,23 @@ If a match is found in `skeleton-pair-alist', that is inserted, else
478the defaults are used. These are (), [], {}, <> and `' for the 487the defaults are used. These are (), [], {}, <> and `' for the
479symmetrical ones, and the same character twice for the others." 488symmetrical ones, and the same character twice for the others."
480 (interactive "*P") 489 (interactive "*P")
481 (let ((mark (and skeleton-autowrap 490 (if (or arg (not skeleton-pair))
482 (or (eq last-command 'mouse-drag-region) 491 (self-insert-command (prefix-numeric-value arg))
483 (and transient-mark-mode mark-active)))) 492 (let* ((mark (and skeleton-autowrap
484 (skeleton-end-hook)) 493 (or (eq last-command 'mouse-drag-region)
485 (if (or arg 494 (and transient-mark-mode mark-active))))
486 (not skeleton-pair) 495 (skeleton-end-hook)
487 (memq (char-syntax (preceding-char)) '(?\\ ?/)) 496 (char last-command-char)
488 (and (not mark) 497 (skeleton (or (assq char skeleton-pair-alist)
489 (or overwrite-mode 498 (assq char skeleton-pair-default-alist)
490 (if (not skeleton-pair-on-word) (looking-at "\\w")) 499 `(,char _ ,char))))
491 (funcall skeleton-pair-filter)))) 500 (if (or (memq (char-syntax (preceding-char)) '(?\\ ?/))
492 (self-insert-command (prefix-numeric-value arg)) 501 (and (not mark)
493 (setq last-command-char (logand last-command-char 255)) 502 (or overwrite-mode
494 (skeleton-insert 503 (if (not skeleton-pair-on-word) (looking-at "\\w"))
495 (cons nil (or (assq last-command-char skeleton-pair-alist) 504 (funcall skeleton-pair-filter))))
496 (assq last-command-char '((?( _ ?)) 505 (self-insert-command (prefix-numeric-value arg))
497 (?[ _ ?]) 506 (skeleton-insert (cons nil skeleton) (if mark -1))))))
498 (?{ _ ?})
499 (?< _ ?>)
500 (?` _ ?')))
501 `(,last-command-char _ ,last-command-char)))
502 (if mark -1)))))
503 507
504 508
505;; A more serious example can be found in sh-script.el 509;; A more serious example can be found in sh-script.el