;ELC   
;;; Compiled by rms@psilocin.gnu.org on Sun Mar  8 18:45:39 1998
;;; from file /gd/gnu/emacs/lisp/tempo.el
;;; in Emacs version 20.2.89.6
;;; with bytecomp version 2.38
;;; with all optimizations.
;;; This file uses opcodes which do not exist in Emacs 18.

(if (and (boundp 'emacs-version)
	 (< (aref emacs-version (1- (length emacs-version))) ?A)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "19.29")))
    (error "`tempo.el' was compiled for Emacs 19.29 or later"))


(custom-declare-group 'tempo nil "Flexible template insertion." :prefix "tempo-" :group 'tools)
#@137 *Prompt user for strings in templates.
If this variable is non-nil, `tempo-insert' prompts the
user for text to insert in the templates
(custom-declare-variable 'tempo-interactive 'nil '(#$ . -622) :type 'boolean :group 'tempo)
#@328 *Automatically insert current region when there is a `r' in the template
If this variable is NIL, `r' elements will be treated just like `p'
elements, unless the template function is given a prefix (or a non-nil
argument). If this variable is non-NIL, the behaviour is reversed.

In Transient Mark mode, this option is unused.
(custom-declare-variable 'tempo-insert-region 'nil '(#$ . -857) :type 'boolean :group 'tempo)
#@99 *If non-NIL, show a buffer with possible completions, when only
a partial completion can be found
(custom-declare-variable 'tempo-show-completion-buffer 't '(#$ . -1284) :type 'boolean :group 'tempo)
#@129 *If NIL, a completion buffer generated by \[tempo-complete-tag]
disappears at the next keypress; otherwise, it remains forever.
(custom-declare-variable 'tempo-leave-completion-buffer 'nil '(#$ . -1491) :type 'boolean :group 'tempo)
#@225 List of functions to run when inserting a string.
Each function is called with a single arg, STRING and should return
another string. This could be used for making all strings upcase by
setting it to '(upcase), for example.
(defvar tempo-insert-string-functions nil (#$ . 1731))
#@59 An association list with tags and corresponding templates
(defvar tempo-tags nil (#$ . 2016))
#@380 A list of locally installed tag completion lists.
It is a association list where the car of every element is a symbol
whose variable value is a template list. The cdr part, if non-nil, is a
function or a regexp that defines the string to match. See the
documentation for the function `tempo-complete-tag' for more info.

`tempo-tags' is always in the last position in this list.
(defvar tempo-local-tags '((tempo-tags)) (#$ . 2117))
#@62 A collection of all the tags defined for the current buffer.
(defvar tempo-collection nil (#$ . 2556))
#@54 Indicates if the tag collection needs to be rebuilt.
(defvar tempo-dirty-collection t (#$ . 2665))
#@87 A list of marks to jump to with `\[tempo-forward-mark]' and `\[tempo-backward-mark]'.
(defvar tempo-marks nil (#$ . 2770))
#@860 The regexp or function used to find the string to match against tags.

If `tempo-match-finder is a string, it should contain a regular
expression with at least one \( \) pair. When searching for tags,
`tempo-complete-tag' calls `re-search-backward' with this string, and
the string between the first \( and \) is used for matching against
each string in the tag list. If one is found, the whole text between
the first \( and the point is replaced with the inserted template.

You will probably want to include \ = at the end of the regexp to
make sure that the string is matched only against text adjacent to the
point.

If `tempo-match-finder' is a symbol, it should be a function that
returns a pair of the form (STRING . POS), where STRING is the string
used for matching and POS is the buffer position after which text
should be replaced with a template.
(defvar tempo-match-finder "\\b\\([^\\b]+\\)\\=" (#$ . 2900))
#@232 Element handlers for user-defined elements.
A list of symbols which are bound to functions that take one argument.
This function should return something to be sent to `tempo-insert' if
it recognizes the argument, and NIL otherwise
(defvar tempo-user-elements nil (#$ . 3828))
#@40 Temporary storage for named insertions
(defvar tempo-named-insertions nil (#$ . 4110))
#@47 Region start when inserting around the region
(defvar tempo-region-start (make-marker) (#$ . 4203))
#@46 Region stop when inserting around the region
(defvar tempo-region-stop (make-marker) (#$ . 4309))
(byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\207" [make-variable-buffer-local tempo-marks tempo-local-tags tempo-match-finder tempo-collection tempo-dirty-collection] 2)
(defalias 'tempo-mapc #[(fun lst) "\205 	@!\210\302	A\"\207" [lst fun tempo-mapc] 3])
(defalias 'tempo-dolist '(macro . #[(il &rest forms) "@A@\304\305\306\307\nCD\"D	E*\207" [il l i forms tempo-mapc function append lambda] 5]))
(put 'tempo-dolist 'lisp-indent-function 1)
#@2918 Define a template.
This function creates a template variable `tempo-template-NAME' and an
interactive function `tempo-template-NAME' that inserts the template
at the point.  The created function is returned.

NAME is a string that contains the name of the template, ELEMENTS is a
list of elements in the template, TAG is the tag used for completion,
DOCUMENTATION is the documentation string for the insertion command
created, and TAGLIST (a symbol) is the tag list that TAG (if provided)
should be added to).  If TAGLIST is nil and TAG is non-nil, TAG is
added to `tempo-tags'

The elements in ELEMENTS can be of several types:

 - A string. It is sent to the hooks in `tempo-insert-string-functions',
   and the result is inserted.
 - The symbol 'p. This position is saved in `tempo-marks'.
 - The symbol 'r. If `tempo-insert' is called with ON-REGION non-nil
   the current region is placed here. Otherwise it works like 'p.
 - (p PROMPT <NAME> <NOINSERT>) If `tempo-interactive' is non-nil, the
   user is prompted in the minbuffer with PROMPT for a string to be
   inserted. If the optional parameter NAME is non-nil, the text is
   saved for later insertion with the `s' tag. If there already is
   something saved under NAME that value is used instead and no
   prompting is made. If NOINSERT is provided and non-nil, nothing is
   inserted, but text is still saved when a NAME is provided. For
   clarity, the symbol 'noinsert should be used as argument.
 - (P PROMPT <NAME> <NOINSERT>) Works just like the previous tag, but
   forces tempo-interactive to be true.
 - (r PROMPT <NAME> <NOINSERT>) like the previous, but if
   `tempo-interactive' is nil and `tempo-insert' is called with
   ON-REGION non-nil, the current region is placed here. This usually
   happens when you call the template function with a prefix argument.
 - (s NAME) Inserts text previously read with the (p ..) construct.
   Finds the insertion saved under NAME and inserts it. Acts like 'p
   if tempo-interactive is nil.
 - '& If there is only whitespace between the line start and point,
   nothing happens. Otherwise a newline is inserted.
 - '% If there is only whitespace between point and end-of-line
   nothing happens. Otherwise a newline is inserted.
 - 'n inserts a newline.
 - '> The line is indented using `indent-according-to-mode'. Note that
   you often should place this item after the text you want on the
   line.
 - 'r> Like r, but it also indents the region.
 - 'n> Inserts a newline and indents line.
 - 'o Like '% but leaves the point before the newline.
 - nil. It is ignored.
 - Anything else. It is evaluated and the result is treated as an
   element to be inserted. One additional tag is useful for these
   cases. If an expression returns a list '(l foo bar), the elements
   after 'l will be inserted according to the usual rules. This makes
   it possible to return several elements from one expression.
(defalias 'tempo-define-template #[(name elements &optional tag documentation taglist) "\306\307P!\211	L\210\n\310\311\312D\f\206 \313\314Q\315\316D\317\320	D\321\322\323\312D\312FE\257M\210\2037 \324	#\210\n*\207" [name template-name command-name elements documentation tag intern "tempo-template-" lambda &optional arg "Insert a " "." interactive "*P" tempo-insert-template quote if tempo-insert-region not tempo-add-tag taglist] 12 (#$ . 4896)])
#@228 Insert a template.
TEMPLATE is the template to be inserted.  If ON-REGION is non-nil the
`r' elements are replaced with the current region. In Transient Mark
mode, ON-REGION is ignored and assumed true if the region is active.
(defalias 'tempo-insert-template #[(template on-region) "\306\216\307\300!\203 \203 	\204 \307\302!\203! \n\203! \310 \203! \311\2037 \f\310 `^\312\223\2037 \310 `]\312\223\210\203> \fb\210\212\313\314 !\210\315\316J\"\210\313\314 !\210)\317 )\207" [transient-mark-mode mark-active zmacs-regions on-region tempo-region-start tempo-region-stop ((byte-code "\302 \210\303\300!\203 \203 \203 \304\305\306!\210\304\207" [transient-mark-mode mark-active tempo-forget-insertions boundp nil run-hooks deactivate-mark-hook] 2)) boundp mark t nil tempo-insert-mark point-marker mapcar #[(elt) "\302	\"\207" [elt on-region tempo-insert] 3] tempo-forward-mark template] 3 (#$ . 8280)])
#@225 Insert a template element.
Insert one element from a template. If ON-REGION is non-nil the `r'
elements are replaced with the current region.

See documentation for `tempo-define-template' for the kind of elements
possible.
(defalias 'tempo-insert #[(element on-region) ";\203	 \304!\207:\203 @\305=\203 \306A!\207:\203. @\307=\203. \310\306A!)\207:\203F @\311=\203F \n\203A b\207\306A!\207:\203X @\312=\203X \313A@!\207:\203j @\314=\203j \315\316A\"\207\305=\203u \317\320 !\207\311=\203\207 \n\203\202 b\207\317\320 !\207\321=\203\240 \n\203\233 b\210\322\323 `\324#\207\317\320 !\207\325=\203\251 \326 \207\327=\203\303 i\330U\206\274 \212\331\332\324\310#)?\205\333c\207\334=\203\333 l\206\324 \212\335\336\324\310#)?\205\333c\207\337=\203\344 \333c\207\340=\203\360 \333c\210\326 \207\341=\203\n\206l\206\212\335\336\324\310#)?\205\342\343!\207?\206\344\345!\206\346!\n\"\207" [element tempo-interactive on-region tempo-region-stop tempo-process-and-insert-string p tempo-insert-prompt-compat P t r s tempo-insert-named l mapcar #[(elt) "\302	\"\207" [elt on-region tempo-insert] 3] tempo-insert-mark point-marker r> indent-region mark nil > indent-according-to-mode & 0 re-search-backward "^\\s-*\\=" "\n" % re-search-forward "\\=\\s-*$" n n> o open-line 1 tempo-insert tempo-is-user-element eval] 4 (#$ . 9206)])
#@138 Compatibility hack for tempo-insert-prompt.
PROMPT can be either a prompt string, or a list of arguments to
tempo-insert-prompt, or nil.
(defalias 'tempo-insert-prompt-compat #[(prompt) ":\203\n \301\302\"\207\302!\207" [prompt apply tempo-insert-prompt] 3 (#$ . 10585)])
#@568 Prompt for a text string and insert it in the current buffer.
If the variable `tempo-interactive' is non-nil the user is prompted
for a string in the minibuffer, which is then inserted in the current
buffer. If `tempo-interactive' is nil, the current point is placed on
`tempo-mark'.

PROMPT is the prompt string, SAVE-NAME is a name to save the inserted
text under. If the optional argument NO-INSERT is non-nil, no text i
inserted. This can be useful when there is a SAVE-NAME.

If there already is a value for SAVE-NAME, it is used and the user is
never prompted.
(defalias 'tempo-insert-prompt #[(prompt &optional save-name no-insert) "\306\205 \307!	\203 \204 \310!\202H 	\203  \306\202H \f\203D ;\204. \311\312\"\210\313!\2049 \nc\210\205H \314\n\"\202H \315\316 !*\207" [save-name previous insertion no-insert tempo-interactive prompt nil tempo-lookup-named tempo-insert-named error "tempo: The prompt (%s) is not a string" read-string tempo-save-named tempo-insert-mark point-marker] 3 (#$ . 10867)])
#@70 Tries all the user-defined element handlers in
`tempo-user-elements'
(defalias 'tempo-is-user-element #[(element) "\300\301\215\207" [found (byte-code "\301\302\"\210\303\304\305\"\207" [tempo-user-elements mapcar #[(handler) "	!\211\205\f \303\304\n\")\207" [handler element result throw found] 4] throw found nil] 3)] 2 (#$ . 11898)])
#@40 Forget all the saved named insertions.
(defalias 'tempo-forget-insertions #[nil "\301\211\207" [tempo-named-insertions nil] 2 (#$ . 12244)])
#@235 Save some data for later insertion
The contents of DATA is saved under the name NAME.

The data can later be retrieved with `tempo-lookup-named'.

This function returns nil, so it can be used in a template without
inserting anything.
(defalias 'tempo-save-named #[(name data) "	B\nB\303\207" [name data tempo-named-insertions nil] 2 (#$ . 12393)])
#@100 Lookup some saved data under the name NAME.
Returns the data if NAME was found, and nil otherwise.
(defalias 'tempo-lookup-named #[(name) "	\236A\207" [name tempo-named-insertions] 2 (#$ . 12750)])
#@213 Insert the previous insertion saved under a named specified in NAME.
If there is no such name saved, a tempo mark is inserted.

Note that if the data is a string, it will not be run through the string
processor.
(defalias 'tempo-insert-named #[(name) "\302!\211\204 \303\304 !\202 	;\203 	c\202 \305	\306\")\207" [name insertion tempo-lookup-named tempo-insert-mark point-marker tempo-insert nil] 4 (#$ . 12956)])
#@132 Insert a string from a template.
Run a string through the preprocessors in `tempo-insert-string-functions'
and insert the results.
(defalias 'tempo-process-and-insert-string #[(string) "\203\" 9\203 	!\202\" <\203 \302\303\"\210\202\" \304\305\"\210	c\207" [tempo-insert-string-functions string tempo-mapc #[(fn) "	!\211\207" [fn string] 2] error "Bogus value in tempo-insert-string-functions: %s"] 3 (#$ . 13383)])
#@53 Insert a mark `tempo-marks' while keeping it sorted
(defalias 'tempo-insert-mark #[(mark) "\204	 	C\211\207	@W\203 	B\211\207\211A\203, \nA@	X\203, \nA\211\202 	\n@U?\205: \n	\nAB\241)\207" [tempo-marks mark lp] 4 (#$ . 13816)])
#@53 Jump to the next mark in `tempo-forward-mark-list'.
(defalias 'tempo-forward-mark #[nil "\301\302\215\211\205\n b)\207" [next-mark found (byte-code "\301\302\"\210\303\207" [tempo-marks mapcar #[(mark) "`W\205\n \301\302\"\207" [mark throw found] 3] nil] 3)] 3 (#$ . 14061) nil])
#@54 Jump to the previous mark in `tempo-back-mark-list'.
(defalias 'tempo-backward-mark #[nil "\301\302\215\211\205\n b)\207" [prev-mark found (byte-code "\302\303\304	\"\210)\207" [last tempo-marks nil mapcar #[(mark) "`X\203 \302\303	\"\210\211\207" [mark last throw found] 3]] 3)] 3 (#$ . 14352) nil])
#@131 Add a template tag.
Add the TAG, that should complete to TEMPLATE to the list in TAG-LIST,
or to `tempo-tags' if TAG-LIST is nil.
(defalias 'tempo-add-tag #[(tag template &optional tag-list) "\204 \303\304	J\"\204 	\nBJBL\210\305 \207" [tag-list tag template tempo-tags assoc tempo-invalidate-collection] 3 (#$ . 14668) "sTag: \nCTemplate: "])
#@488 Install TAG-LIST to be used for template completion in the current buffer.
TAG-LIST is a symbol whose variable value is a tag list created with
`tempo-add-tag'.

COMPLETION-FUNCTION is an obsolete option for specifying an optional
function or string that is used by `\[tempo-complete-tag]' to find a
string to match the tag against. It has the same definition as the
variable `tempo-match-finder'. In this version, supplying a
COMPLETION-FUNCTION just sets `tempo-match-finder' locally.
(defalias 'tempo-use-tag-list #[(tag-list &optional completion-function) "	\236\211\203 \n\241\210\202 B	B)\203 \305 \207" [tag-list tempo-local-tags old completion-function tempo-match-finder tempo-invalidate-collection] 3 (#$ . 15026)])
#@87 Marks the tag collection as obsolete.
Whenever it is needed again it will be rebuilt.
(defalias 'tempo-invalidate-collection #[nil "\301\211\207" [tempo-dirty-collection t] 2 (#$ . 15770)])
#@117 Build a collection of all the tags and return it.
If `tempo-dirty-collection' is NIL, the old collection is reused.
(defalias 'tempo-build-collection #[nil "\204 	\206 \303\304\305\306\n\"\"\211\307\207" [tempo-dirty-collection tempo-collection tempo-local-tags apply append mapcar #[(tag-list) "\301@!\207" [tag-list eval] 2] nil] 5 (#$ . 15968)])
#@148 Find a string to be matched against a tag list.
FINDER is a function or a string. Returns (STRING . POS), or nil
if no reasonable string is found.
(defalias 'tempo-find-match-string #[(finder) ";\203 \302\212\303\302\304#)	\205 \305\224\305\225{\305\224B)\207 \207" [finder successful nil re-search-backward t 1] 4 (#$ . 16330)])
#@704 Look for a tag and expand it.
All the tags in the tag lists in `tempo-local-tags'
(this includes `tempo-tags') are searched for a match for the text
before the point.  The way the string to match for is determined can
be altered with the variable `tempo-match-finder'. If
`tempo-match-finder' returns nil, then the results are the same as
no match at all.

If a single match is found, the corresponding template is expanded in
place of the matching string.

If a partial completion or no match at all is found, and SILENT is
non-NIL, the function will give a signal.

If a partial completion is found and `tempo-show-completion-buffer' is
non-NIL, a buffer containing possible completions is displayed.
(defalias 'tempo-complete-tag #[(&optional silent) "\306 \307	!\211@\nA\310\"\211@\206 \n\205 \311\"\211\203) \f`|\210\n\2047 \206 \312 \202 \204F \206 \312 \202 \313=\203X \314\310\"A\315\"\202 \310\"\211\203j \314A\315\"\202 c\210\204v \312 \210\205 \316\".\207" [collection tempo-match-finder match-info match-string match-start exact tempo-build-collection tempo-find-match-string assoc try-completion ding t tempo-insert-template nil tempo-display-completions compl silent tempo-show-completion-buffer] 5 (#$ . 16674) "*"])
#@59 Show a buffer containing possible completions for STRING.
(defalias 'tempo-display-completions #[(string tag-list) "\203 \303\220\304\305	\n\"!\221\207\306\213\207" [tempo-leave-completion-buffer string tag-list "*Completions*" display-completion-list all-completions ((byte-code "\302\220\303\304	\"!\221\210\305\306!\207" [string tag-list "*Completions*" display-completion-list all-completions sit-for 32767] 5))] 5 (#$ . 17956)])
#@315 Expand the tag before point if it is complete.
Returns non-nil if an expansion was made and nil otherwise.

This could as an example be used in a command that is bound to the
space bar, and looks something like this:

(defun tempo-space ()
  (interactive "*")
  (or (tempo-expand-if-complete)
      (insert " ")))
(defalias 'tempo-expand-if-complete #[nil "\306 \307	!\211@\nA\310\"\211\205! \f`|\210\311A\312\"\210\313-\207" [collection tempo-match-finder match-info match-string match-start exact tempo-build-collection tempo-find-match-string assoc tempo-insert-template nil t] 4 (#$ . 18400) "*"])
(provide 'tempo)
