]> code.delx.au - gnu-emacs/blobdiff - lisp/tempo.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / tempo.el
index 282885e2d6557284a2359b4fa5bb391bb6972c13..383dcd40d24c7fba75452f967bac02efe9b841cb 100644 (file)
@@ -1,6 +1,7 @@
 ;;; tempo.el --- Flexible template insertion
 
-;; Copyright (C) 1994, 1995, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: David K}gedal <davidk@lysator.liu.se>
 ;; Created: 16 Feb 1994
@@ -11,7 +12,7 @@
 
 ;; 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)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -265,6 +266,8 @@ The elements in ELEMENTS can be of several types:
    that you often should place this item after the text you want on
    the line.
  - `r>': Like `r', but it also indents the region.
+ - (r> PROMPT <NAME> <NOINSERT>): Like (r ...), but is also indents
+   the region.
  - `n>': Inserts a newline and indents line.
  - `o': Like `%' but leaves the point before the newline.
  - nil: It is ignored.
@@ -312,9 +315,9 @@ mode, ON-REGION is ignored and assumed true if the region is active."
            (goto-char tempo-region-start))
        (save-excursion
          (tempo-insert-mark (point-marker))
-         (mapcar (function (lambda (elt)
-                             (tempo-insert elt on-region)))
-                 (symbol-value template))
+         (mapc (function (lambda (elt)
+                           (tempo-insert elt on-region)))
+               (symbol-value template))
          (tempo-insert-mark (point-marker)))
        (tempo-forward-mark))
     (tempo-forget-insertions)
@@ -351,6 +354,13 @@ possible."
                                         (goto-char tempo-region-stop)
                                       (tempo-insert-prompt-compat
                                        (cdr element))))
+        ((and (consp element)
+              (eq (car element) 'r>)) (if on-region
+                                          (progn
+                                            (goto-char tempo-region-stop)
+                                            (indent-region (mark) (point) nil))
+                                        (tempo-insert-prompt-compat
+                                         (cdr element))))
        ((and (consp element)
              (eq (car element) 's)) (tempo-insert-named (car (cdr element))))
        ((and (consp element)
@@ -450,10 +460,10 @@ never prompted."
   "Tries all the user-defined element handlers in `tempo-user-elements'."
   ;; Sigh... I need (some list)
   (catch 'found
-    (mapcar (function (lambda (handler)
-                       (let ((result (funcall handler element)))
-                         (if result (throw 'found result)))))
-           tempo-user-elements)
+    (mapc (function (lambda (handler)
+                     (let ((result (funcall handler element)))
+                       (if result (throw 'found result)))))
+         tempo-user-elements)
     (throw 'found nil)))
 
 ;;;
@@ -546,7 +556,7 @@ and insert the results."
   "Jump to the next mark in `tempo-forward-mark-list'."
   (interactive)
   (let ((next-mark (catch 'found
-                    (mapcar
+                    (mapc
                      (function
                       (lambda (mark)
                         (if (< (point) mark)
@@ -565,7 +575,7 @@ and insert the results."
   (interactive)
   (let ((prev-mark (catch 'found
                     (let (last)
-                      (mapcar
+                      (mapc
                        (function
                         (lambda (mark)
                           (if (<= (point) mark)
@@ -716,11 +726,13 @@ non-nil, a buffer containing possible completions is displayed."
   (if tempo-leave-completion-buffer
       (with-output-to-temp-buffer "*Completions*"
        (display-completion-list
-        (all-completions string tag-list)))
+        (all-completions string tag-list)
+        string))
     (save-window-excursion
       (with-output-to-temp-buffer "*Completions*"
        (display-completion-list
-        (all-completions string tag-list)))
+        (all-completions string tag-list)
+        string))
       (sit-for 32767))))
 
 ;;;