guile feature
[bpt/emacs.git] / lisp / skeleton.el
index de0e511..1c6128a 100644 (file)
@@ -62,12 +62,8 @@ region.")
   "If non-nil, make sure that the skeleton inserted ends with a newline.
 This just influences the way the default `skeleton-end-hook' behaves.")
 
-(defvar skeleton-end-hook
-  (lambda ()
-    (or (eolp) (not skeleton-end-newline) (newline-and-indent)))
+(defvar skeleton-end-hook nil
   "Hook called at end of skeleton but before going to point of interest.
-By default this moves out anything following to next line,
-  unless `skeleton-end-newline' is set to nil.
 The variables `v1' and `v2' are still set when calling this.")
 
 
@@ -180,7 +176,7 @@ of `str' whereas the skeleton's interactor is then ignored."
 With optional second argument REGIONS, wrap first interesting point
 \(`_') in skeleton around next REGIONS words, if REGIONS is positive.
 If REGIONS is negative, wrap REGIONS preceding interregions into first
-REGIONS interesting positions \(successive `_'s) in skeleton.
+REGIONS interesting positions (successive `_'s) in skeleton.
 
 An interregion is the stretch of text between two contiguous marked
 points.  If you marked A B C [] (where [] is the cursor) in
@@ -197,7 +193,9 @@ 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-function').  Other possibilities are:
 
-       \\n     go to next line and indent according to mode
+       \\n     go to next line and indent according to mode, unless
+                this is the first/last element of a skeleton and point
+                is at bol/eol
        _       interesting point, interregion here
        -       interesting point, no interregion interaction, overrides
                interesting point set by _
@@ -205,21 +203,26 @@ If ELEMENT is a string or a character it gets inserted (see also
        @       add position to `skeleton-positions'
        &       do next ELEMENT if previous moved point
        |       do next ELEMENT if previous didn't move point
-       -num    delete num preceding characters (see `skeleton-untabify')
+       -NUM    delete NUM preceding characters (see `skeleton-untabify')
        resume: skipped, continue here if quit is signaled
        nil     skipped
 
 After termination, point will be positioned at the last occurrence of -
 or at the first occurrence of _ or at the end of the inserted text.
 
-Further elements can be defined via `skeleton-further-elements'.  ELEMENT may
-itself be a SKELETON with an INTERACTOR.  The user is prompted repeatedly for
-different inputs.  The SKELETON is processed as often as the user enters a
-non-empty string.  \\[keyboard-quit] terminates skeleton insertion, but
-continues after `resume:' and positions at `_' if any.  If INTERACTOR in such
-a subskeleton is a prompt-string which contains a \".. %s ..\" it is
-formatted with `skeleton-subprompt'.  Such an INTERACTOR may also be a list of
-strings with the subskeleton being repeated once for each string.
+Note that \\n as the last element of the skeleton only inserts a
+newline if not at eol.  If you want to unconditionally insert a newline
+at the end of the skeleton, use \"\\n\" instead.  Likewise with \\n
+as the first element when at bol.
+
+Further elements can be defined via `skeleton-further-elements'.
+ELEMENT may itself be a SKELETON with an INTERACTOR.  The user is prompted
+repeatedly for different inputs.  The SKELETON is processed as often as
+the user enters a non-empty string.  \\[keyboard-quit] terminates skeleton insertion, but
+continues after `resume:' and positions at `_' if any.  If INTERACTOR in
+such a subskeleton is a prompt-string which contains a \".. %s ..\" it is
+formatted with `skeleton-subprompt'.  Such an INTERACTOR may also be a list
+of strings with the subskeleton being repeated once for each string.
 
 Quoted Lisp expressions are evaluated for their side-effects.
 Other Lisp expressions are evaluated and the value treated as above.
@@ -261,6 +264,7 @@ When done with skeleton, but before going back to `_'-point call
               (mapcar #'car skeleton-further-elements)
               (mapcar (lambda (x) (eval (cadr x))) skeleton-further-elements)
             (skeleton-internal-list skeleton str))
+       (or (eolp) (not skeleton-end-newline) (newline-and-indent))
        (run-hooks 'skeleton-end-hook)
        (sit-for 0)
        (or (pos-visible-in-window-p beg)