diff options
| -rw-r--r-- | lisp/skeleton.el | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/skeleton.el b/lisp/skeleton.el index 0b3fc82f025..d51fd91c3b4 100644 --- a/lisp/skeleton.el +++ b/lisp/skeleton.el | |||
| @@ -39,14 +39,15 @@ | |||
| 39 | ;; page 3: mirror-mode, an example for setting up paired insertion | 39 | ;; page 3: mirror-mode, an example for setting up paired insertion |
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | (defvar skeleton-transformation 'identity | 42 | (defvar skeleton-transformation-function 'identity |
| 43 | "*If non-nil, function applied to literal strings before they are inserted. | 43 | "*If non-nil, function applied to literal strings before they are inserted. |
| 44 | It should take strings and characters and return them transformed, or nil | 44 | It should take strings and characters and return them transformed, or nil |
| 45 | which means no transformation. | 45 | which means no transformation. |
| 46 | Typical examples might be `upcase' or `capitalize'.") | 46 | Typical examples might be `upcase' or `capitalize'.") |
| 47 | (defvaralias 'skeleton-transformation 'skeleton-transformation-function) | ||
| 47 | 48 | ||
| 48 | ; this should be a fourth argument to defvar | 49 | ; this should be a fourth argument to defvar |
| 49 | (put 'skeleton-transformation 'variable-interactive | 50 | (put 'skeleton-transformation-function 'variable-interactive |
| 50 | "aTransformation function: ") | 51 | "aTransformation function: ") |
| 51 | 52 | ||
| 52 | 53 | ||
| @@ -75,8 +76,9 @@ The variables `v1' and `v2' are still set when calling this.") | |||
| 75 | 76 | ||
| 76 | 77 | ||
| 77 | ;;;###autoload | 78 | ;;;###autoload |
| 78 | (defvar skeleton-filter 'identity | 79 | (defvar skeleton-filter-function 'identity |
| 79 | "Function for transforming a skeleton proxy's aliases' variable value.") | 80 | "Function for transforming a skeleton proxy's aliases' variable value.") |
| 81 | (defvaralias 'skeleton-filter 'skeleton-filter-function) | ||
| 80 | 82 | ||
| 81 | (defvar skeleton-untabify t | 83 | (defvar skeleton-untabify t |
| 82 | "When non-nil untabifies when deleting backwards with element -ARG.") | 84 | "When non-nil untabifies when deleting backwards with element -ARG.") |
| @@ -157,7 +159,7 @@ This command can also be an abbrev expansion (3rd and 4th columns in | |||
| 157 | 159 | ||
| 158 | Optional second argument STR may also be a string which will be the value | 160 | Optional second argument STR may also be a string which will be the value |
| 159 | of `str' whereas the skeleton's interactor is then ignored." | 161 | of `str' whereas the skeleton's interactor is then ignored." |
| 160 | (skeleton-insert (funcall skeleton-filter skeleton) | 162 | (skeleton-insert (funcall skeleton-filter-function skeleton) |
| 161 | ;; Pretend C-x a e passed its prefix arg to us | 163 | ;; Pretend C-x a e passed its prefix arg to us |
| 162 | (if (or arg current-prefix-arg) | 164 | (if (or arg current-prefix-arg) |
| 163 | (prefix-numeric-value (or arg | 165 | (prefix-numeric-value (or arg |
| @@ -199,7 +201,7 @@ SKELETON is made up as (INTERACTOR ELEMENT ...). INTERACTOR may be nil if | |||
| 199 | not needed, a prompt-string or an expression for complex read functions. | 201 | not needed, a prompt-string or an expression for complex read functions. |
| 200 | 202 | ||
| 201 | If ELEMENT is a string or a character it gets inserted (see also | 203 | If ELEMENT is a string or a character it gets inserted (see also |
| 202 | `skeleton-transformation'). Other possibilities are: | 204 | `skeleton-transformation-function'). Other possibilities are: |
| 203 | 205 | ||
| 204 | \\n go to next line and indent according to mode | 206 | \\n go to next line and indent according to mode |
| 205 | _ interesting point, interregion here | 207 | _ interesting point, interregion here |
| @@ -360,7 +362,7 @@ automatically, and you are prompted to fill in the variable parts."))) | |||
| 360 | (backward-delete-char-untabify (- element)) | 362 | (backward-delete-char-untabify (- element)) |
| 361 | (delete-backward-char (- element))) | 363 | (delete-backward-char (- element))) |
| 362 | (insert (if (not literal) | 364 | (insert (if (not literal) |
| 363 | (funcall skeleton-transformation element) | 365 | (funcall skeleton-transformation-function element) |
| 364 | element)))) | 366 | element)))) |
| 365 | ((or (eq element '\n) ; actually (eq '\n 'n) | 367 | ((or (eq element '\n) ; actually (eq '\n 'n) |
| 366 | ;; The sequence `> \n' is handled specially so as to indent the first | 368 | ;; The sequence `> \n' is handled specially so as to indent the first |
| @@ -464,7 +466,7 @@ will attempt to insert pairs of matching characters.") | |||
| 464 | "*If this is nil, paired insertion is inhibited before or inside a word.") | 466 | "*If this is nil, paired insertion is inhibited before or inside a word.") |
| 465 | 467 | ||
| 466 | 468 | ||
| 467 | (defvar skeleton-pair-filter (lambda () nil) | 469 | (defvar skeleton-pair-filter-function (lambda () nil) |
| 468 | "Attempt paired insertion if this function returns nil, before inserting. | 470 | "Attempt paired insertion if this function returns nil, before inserting. |
| 469 | This allows for context-sensitive checking whether pairing is appropriate.") | 471 | This allows for context-sensitive checking whether pairing is appropriate.") |
| 470 | 472 | ||
| @@ -490,7 +492,7 @@ Elements might be (?` ?` _ \"''\"), (?\\( ? _ \" )\") or (?{ \\n > _ \\n ?} >). | |||
| 490 | With no ARG, if `skeleton-pair' is non-nil, pairing can occur. If the region | 492 | With no ARG, if `skeleton-pair' is non-nil, pairing can occur. If the region |
| 491 | is visible the pair is wrapped around it depending on `skeleton-autowrap'. | 493 | is visible the pair is wrapped around it depending on `skeleton-autowrap'. |
| 492 | Else, if `skeleton-pair-on-word' is non-nil or we are not before or inside a | 494 | Else, if `skeleton-pair-on-word' is non-nil or we are not before or inside a |
| 493 | word, and if `skeleton-pair-filter' returns nil, pairing is performed. | 495 | word, and if `skeleton-pair-filter-function' returns nil, pairing is performed. |
| 494 | Pairing is also prohibited if we are right after a quoting character | 496 | Pairing is also prohibited if we are right after a quoting character |
| 495 | such as backslash. | 497 | such as backslash. |
| 496 | 498 | ||
| @@ -512,7 +514,7 @@ symmetrical ones, and the same character twice for the others." | |||
| 512 | (and (not mark) | 514 | (and (not mark) |
| 513 | (or overwrite-mode | 515 | (or overwrite-mode |
| 514 | (if (not skeleton-pair-on-word) (looking-at "\\w")) | 516 | (if (not skeleton-pair-on-word) (looking-at "\\w")) |
| 515 | (funcall skeleton-pair-filter)))) | 517 | (funcall skeleton-pair-filter-function)))) |
| 516 | (self-insert-command (prefix-numeric-value arg)) | 518 | (self-insert-command (prefix-numeric-value arg)) |
| 517 | (skeleton-insert (cons nil skeleton) (if mark -1)))))) | 519 | (skeleton-insert (cons nil skeleton) (if mark -1)))))) |
| 518 | 520 | ||
| @@ -526,13 +528,13 @@ symmetrical ones, and the same character twice for the others." | |||
| 526 | ;; (kill-all-local-variables) | 528 | ;; (kill-all-local-variables) |
| 527 | ;; (make-local-variable 'skeleton-pair) | 529 | ;; (make-local-variable 'skeleton-pair) |
| 528 | ;; (make-local-variable 'skeleton-pair-on-word) | 530 | ;; (make-local-variable 'skeleton-pair-on-word) |
| 529 | ;; (make-local-variable 'skeleton-pair-filter) | 531 | ;; (make-local-variable 'skeleton-pair-filter-function) |
| 530 | ;; (make-local-variable 'skeleton-pair-alist) | 532 | ;; (make-local-variable 'skeleton-pair-alist) |
| 531 | ;; (setq major-mode 'mirror-mode | 533 | ;; (setq major-mode 'mirror-mode |
| 532 | ;; mode-name "Mirror" | 534 | ;; mode-name "Mirror" |
| 533 | ;; skeleton-pair-on-word t | 535 | ;; skeleton-pair-on-word t |
| 534 | ;; ;; in the middle column insert one or none if odd window-width | 536 | ;; ;; in the middle column insert one or none if odd window-width |
| 535 | ;; skeleton-pair-filter (lambda () | 537 | ;; skeleton-pair-filter-function (lambda () |
| 536 | ;; (if (>= (current-column) | 538 | ;; (if (>= (current-column) |
| 537 | ;; (/ (window-width) 2)) | 539 | ;; (/ (window-width) 2)) |
| 538 | ;; ;; insert both on next line | 540 | ;; ;; insert both on next line |