Add 2010 to copyright years.
[bpt/emacs.git] / lisp / skeleton.el
index 0b3fc82..b228b50 100644 (file)
@@ -1,7 +1,7 @@
-;;; skeleton.el --- Lisp language extension for writing statement skeletons
+;;; skeleton.el --- Lisp language extension for writing statement skeletons -*- coding: utf-8 -*-
 
-;; Copyright (C) 1993, 1994, 1995, 1996, 2002, 2003,
-;;   2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996, 2001, 2002, 2003,
+;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
 ;; Maintainer: FSF
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 ;; page 3:     mirror-mode, an example for setting up paired insertion
 
 
-(defvar skeleton-transformation 'identity
+(defvar skeleton-transformation-function 'identity
   "*If non-nil, function applied to literal strings before they are inserted.
 It should take strings and characters and return them transformed, or nil
 which means no transformation.
 Typical examples might be `upcase' or `capitalize'.")
+(defvaralias 'skeleton-transformation 'skeleton-transformation-function)
 
 ; this should be a fourth argument to defvar
-(put 'skeleton-transformation 'variable-interactive
+(put 'skeleton-transformation-function 'variable-interactive
      "aTransformation function: ")
 
 
@@ -75,8 +74,9 @@ The variables `v1' and `v2' are still set when calling this.")
 
 
 ;;;###autoload
-(defvar skeleton-filter 'identity
+(defvar skeleton-filter-function 'identity
   "Function for transforming a skeleton proxy's aliases' variable value.")
+(defvaralias 'skeleton-filter 'skeleton-filter-function)
 
 (defvar skeleton-untabify t
   "When non-nil untabifies when deleting backwards with element -ARG.")
@@ -157,7 +157,7 @@ This command can also be an abbrev expansion (3rd and 4th columns in
 
 Optional second argument STR may also be a string which will be the value
 of `str' whereas the skeleton's interactor is then ignored."
-  (skeleton-insert (funcall skeleton-filter skeleton)
+  (skeleton-insert (funcall skeleton-filter-function skeleton)
                   ;; Pretend  C-x a e  passed its prefix arg to us
                   (if (or arg current-prefix-arg)
                       (prefix-numeric-value (or arg
@@ -199,7 +199,7 @@ SKELETON is made up as (INTERACTOR ELEMENT ...).  INTERACTOR may be nil if
 not needed, a prompt-string or an expression for complex read functions.
 
 If ELEMENT is a string or a character it gets inserted (see also
-`skeleton-transformation').  Other possibilities are:
+`skeleton-transformation-function').  Other possibilities are:
 
        \\n     go to next line and indent according to mode
        _       interesting point, interregion here
@@ -207,8 +207,8 @@ If ELEMENT is a string or a character it gets inserted (see also
                interesting point set by _
        >       indent line (or interregion if > _) according to major mode
        @       add position to `skeleton-positions'
-       &       do next ELEMENT iff previous moved point
-       |       do next ELEMENT iff previous didn't move point
+       &       do next ELEMENT if previous moved point
+       |       do next ELEMENT if previous didn't move point
        -num    delete num preceding characters (see `skeleton-untabify')
        resume: skipped, continue here if quit is signaled
        nil     skipped
@@ -353,14 +353,14 @@ automatically, and you are prompted to fill in the variable parts.")))
 
 (defun skeleton-internal-1 (element &optional literal recursive)
   (cond
-   ((char-or-string-p element)
+   ((or (integerp element) (stringp element))
     (if (and (integerp element)                ; -num
             (< element 0))
        (if skeleton-untabify
            (backward-delete-char-untabify (- element))
          (delete-backward-char (- element)))
       (insert (if (not literal)
-                 (funcall skeleton-transformation element)
+                 (funcall skeleton-transformation-function element)
                element))))
    ((or (eq element '\n)                       ; actually (eq '\n 'n)
        ;; The sequence `> \n' is handled specially so as to indent the first
@@ -464,13 +464,13 @@ will attempt to insert pairs of matching characters.")
   "*If this is nil, paired insertion is inhibited before or inside a word.")
 
 
-(defvar skeleton-pair-filter (lambda () nil)
+(defvar skeleton-pair-filter-function (lambda () nil)
   "Attempt paired insertion if this function returns nil, before inserting.
 This allows for context-sensitive checking whether pairing is appropriate.")
 
 
 (defvar skeleton-pair-alist ()
-  "An override alist of pairing partners matched against `last-command-char'.
+  "An override alist of pairing partners matched against `last-command-event'.
 Each alist element, which looks like (ELEMENT ...), is passed to
 `skeleton-insert' with no interactor.  Variable `str' does nothing.
 
@@ -480,7 +480,7 @@ Elements might be (?` ?` _ \"''\"), (?\\( ?  _ \" )\") or (?{ \\n > _ \\n ?} >).
                                      (?[ _ ?]) (?\])
                                      (?{ _ ?}) (?\})
                                      (?< _ ?>) (?\>)
-                                     (?« _ ?») (?\»)
+                                     (?« _ ?») (?\»)
                                      (?` _ ?')))
 
 ;;;###autoload
@@ -490,7 +490,7 @@ Elements might be (?` ?` _ \"''\"), (?\\( ?  _ \" )\") or (?{ \\n > _ \\n ?} >).
 With no ARG, if `skeleton-pair' is non-nil, pairing can occur.  If the region
 is visible the pair is wrapped around it depending on `skeleton-autowrap'.
 Else, if `skeleton-pair-on-word' is non-nil or we are not before or inside a
-word, and if `skeleton-pair-filter' returns nil, pairing is performed.
+word, and if `skeleton-pair-filter-function' returns nil, pairing is performed.
 Pairing is also prohibited if we are right after a quoting character
 such as backslash.
 
@@ -504,7 +504,7 @@ symmetrical ones, and the same character twice for the others."
                      (or (eq last-command 'mouse-drag-region)
                          (and transient-mark-mode mark-active))))
           (skeleton-end-hook)
-          (char last-command-char)
+          (char last-command-event)
           (skeleton (or (assq char skeleton-pair-alist)
                         (assq char skeleton-pair-default-alist)
                         `(,char _ ,char))))
@@ -512,13 +512,13 @@ symmetrical ones, and the same character twice for the others."
              (and (not mark)
                   (or overwrite-mode
                       (if (not skeleton-pair-on-word) (looking-at "\\w"))
-                      (funcall skeleton-pair-filter))))
+                      (funcall skeleton-pair-filter-function))))
          (self-insert-command (prefix-numeric-value arg))
        (skeleton-insert (cons nil skeleton) (if mark -1))))))
 
 \f
 ;; A more serious example can be found in sh-script.el
-;;; (defun mirror-mode ()
+;; (defun mirror-mode ()
 ;;  "This major mode is an amusing little example of paired insertion.
 ;;All printable characters do a paired self insert, while the other commands
 ;;work normally."
@@ -526,13 +526,13 @@ symmetrical ones, and the same character twice for the others."
 ;;  (kill-all-local-variables)
 ;;  (make-local-variable 'skeleton-pair)
 ;;  (make-local-variable 'skeleton-pair-on-word)
-;;  (make-local-variable 'skeleton-pair-filter)
+;;  (make-local-variable 'skeleton-pair-filter-function)
 ;;  (make-local-variable 'skeleton-pair-alist)
 ;;  (setq major-mode 'mirror-mode
 ;;     mode-name "Mirror"
 ;;     skeleton-pair-on-word t
 ;;     ;; in the middle column insert one or none if odd window-width
-;;     skeleton-pair-filter (lambda ()
+;;     skeleton-pair-filter-function (lambda ()
 ;;                            (if (>= (current-column)
 ;;                                    (/ (window-width) 2))
 ;;                                ;; insert both on next line
@@ -562,5 +562,5 @@ symmetrical ones, and the same character twice for the others."
 
 (provide 'skeleton)
 
-;;; arch-tag: ccad7bd5-eb5d-40de-9ded-900197215c3e
+;; arch-tag: ccad7bd5-eb5d-40de-9ded-900197215c3e
 ;;; skeleton.el ends here