;ELC ;;; compiled by kwzh@hal.gnu.ai.mit.edu on Wed May 11 00:13:34 1994 ;;; from file /gd/gnu/emacs/19.0/lisp/tempo.el ;;; emacs version 19.22.93.3. ;;; bytecomp version FSF 2.10 ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) (error "`/gd/gnu/emacs/19.0/lisp/tempo.el' was compiled for Emacs 19")) (provide (quote tempo)) (defvar tempo-interactive nil "\ *Prompt user for strings in templates. If this variable is non-nil, `tempo-insert' prompts the user for text to insert in the templates") (defvar tempo-insert-region nil "\ *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.") (defvar tempo-show-completion-buffer t "\ *If non-NIL, show a buffer with possible completions, when only a partial completion can be found") (defvar tempo-leave-completion-buffer nil "\ *If NIL, a completion buffer generated by \\[tempo-complete-tag] disappears at the next keypress; otherwise, it remains forever.") (defvar tempo-insert-string-functions nil "\ List of functions to run when inserting a string. Each function is called with a single arg, STRING.") (defvar tempo-tags nil "\ An association list with tags and corresponding templates") (defvar tempo-local-tags (quote ((tempo-tags))) "\ A list of locally installed tag completion lists. It is a association list where the car of every element is a symbol whose varable 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-marks nil "\ A list of marks to jump to with `\\[tempo-forward-mark]' and `\\[tempo-backward-mark]'.") (defvar tempo-default-match-finder "\\b\\([^\\b]*\\)\\=" "\ The default regexp used to find the string to match against the tags.") (defvar tempo-named-insertions nil "\ Temporary storage for named insertions") (byte-code "!!" [make-variable-buffer-local tempo-marks tempo-local-tags] 2) (defalias 'tempo-define-template #[(name elements &optional tag documentation taglist) "\nP! L\fD \nQD DDFEM: #\f*" [intern "tempo-template-" name template-name command-name elements lambda &optional arg documentation "Insert a " "." interactive "*P" tempo-insert-template quote if tempo-insert-region not tag tempo-add-tag taglist] 12 "\ 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 ) 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 `tempo-interactive is nil, it works like 'p. - (r PROMPT) 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. - (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. - 'n> inserts a newline and indents line. - nil. It is ignored. - Anything else. It is evaluated and the result is parsed again."]) (defalias 'tempo-insert-template #[(template on-region) " `W !J\" !) " [on-region mark exchange-point-and-mark tempo-insert-mark point-marker mapcar tempo-insert template tempo-forward-mark tempo-forget-insertions] 3 "\ 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."]) (defalias 'tempo-insert #[(element) "; !:@=A!:2@=2 - A!:M@=MHA! !=X !=j e !=s =iU#)?c=l#)?c=c=c ?!!" [element tempo-process-and-insert-string p tempo-insert-prompt r on-region exchange-point-and-mark s tempo-interactive tempo-insert-named tempo-insert-mark point-marker > indent-according-to-mode & 0 re-search-backward "^\\s-*\\=" nil t "\n" % re-search-forward "\\=\\s-*$" n n> tempo-insert eval] 4 "\ Insert a template element. Insert one element from a template. See documentation for `tempo-define-template' for the kind of elements possible."]) (defalias 'tempo-insert-prompt #[(prompt) ", < @ < A@ !c\f*\f \"+ !" [tempo-interactive prompt nil inserted-text save-name prompt-string read-string tempo-remember-insertion tempo-insert-mark point-marker] 4 "\ 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 or a list containing the prompt string and a name to save the inserted text under."]) (defalias 'tempo-remember-insertion #[(save-name string) " B\nB" [save-name string tempo-named-insertions] 2 "\ Save the text in STRING under the name SAVE-NAME for later retrieval."]) (defalias 'tempo-forget-insertions #[nil "" [nil tempo-named-insertions] 2 "\ Forget all the saved named insertions."]) (defalias 'tempo-insert-named #[(elt) "@\nA c!*" [elt name tempo-named-insertions insertion error "Named insertion not found"] 3 "\ Insert the previous insertion saved under a named specified in ELT. The name is in the car of ELT."]) (defalias 'tempo-process-and-insert-string #[(string) "$9\nC\"$<\"$\"\nc" [tempo-insert-string-functions apply string mapcar #[(fn) " \n\"" [apply fn string] 3] error "Bogus value in tempo-insert-string-functions: %s"] 3 "\ Insert a string from a template. Run a string through the preprocessors in `tempo-insert-string-functions' and insert the results."]) (defalias 'tempo-insert-mark #[(mark) " C @W BA,\nA@ X,\nA \n@U?:\n \nAB)" [tempo-marks mark lp] 4 "\ Insert a mark `tempo-marks' while keeping it sorted"]) (defalias 'tempo-forward-mark #[nil "\n\nb)" [found (byte-code "\n\"Ç" [mapcar #[(mark) "`W\n\"" [mark throw found] 3] tempo-marks nil] 3) next-mark] 3 "\ Jump to the next mark in `tempo-forward-mark-list'." nil]) (defalias 'tempo-backward-mark #[nil "\n\nb)" [found (byte-code "\f\" )" [nil last mapcar #[(mark) "`X \"" [mark throw found last] 3] tempo-marks] 3) prev-mark] 3 "\ Jump to the previous mark in `tempo-back-mark-list'." nil]) (defalias 'tempo-add-tag #[(tag template &optional tag-list) " J\"? \fBJBL" [tag-list tempo-tags assoc tag template] 3 "\ 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." "sTag: \nCTemplate: "]) (defalias 'tempo-use-tag-list #[(tag-list &optional completion-function) " \n  B B)" [tag-list tempo-local-tags old completion-function] 3 "\ 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' and COMPLETION-FUNCTION is an optional function or string that is used by `\\[tempo-complete-tag]' to find a string to match the tag against. If COMPLETION-FUNCTION 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 COPMLETION-FUNCTION is a symbol, it should be a function that returns a cons cell 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."]) (defalias 'tempo-find-match-string #[(finder) ";#)ĔĕT{ĔB " [finder re-search-backward nil t 1] 4 "\ Find a string to be matched against a tag list. FINDER is a function or a string. Returns (STRING . POS)."]) (defalias 'tempo-complete-tag #[(&optional silent) "‡  Ň" [completed (byte-code "\n\"Ç" [mapcar #[(tag-list-a) "@JA\n\n !@ A \"A% \"\n0`|\n9˂\n9L\n\"\"\n=d \"A\"\"\n;\n \"A\"\nc \" )\"." [tag-list-a tag-list tempo-default-match-finder match-string-finder tempo-find-match-string match-info match-string match-start assoc try-completion compl nil tempo-insert-template throw completed t compl2 tempo-show-completion-buffer tempo-display-completions silent ding] 5] tempo-local-tags nil] 3) t silent ding nil] 2 "\ Look for a tag and expand it. It goes through the tag lists in `tempo-local-tags' (this includes `tempo-tags') and for each list it uses the corresponding match-finder function, or `tempo-default-match-finder' if none is given, and tries to match the match string against the tags in the list using `try-completion'. If none is found it proceeds to the next list until one is found. If a partial completion is found, it is replaced by the template if it can be completed uniquely, or completed as far as possible. When doing partial completion, only tags in the currently examined list are considered, so if you provide similar tags in different lists in `tempo-local-tags', the result may not be desirable. If no match is found or a partial match is found, and SILENT is non-nil, the function will give a signal. If tempo-show-completion-buffer is non-NIL, a buffer containing possible completions is displayed when a partial completion is found." nil]) (defalias 'tempo-display-completions #[(string tag-list) "\f \"!Ƌ" [tempo-leave-completion-buffer "*Completions*" display-completion-list all-completions string tag-list ((byte-code " \f\"!!" ["*Completions*" display-completion-list all-completions string tag-list sit-for 32767] 5))] 5 "\ Show a buffer containing possible completions for STRING."])