;ELC ;;; compiled by rms@mole.gnu.ai.mit.edu on Tue Jun 20 14:19:20 1995 ;;; from file /home/fsf/rms/e19/lisp/tempo.el ;;; emacs version 19.28.95.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.28.90"))) (error "`tempo.el' was compiled for Emacs 19.29 or later")) #@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 (defvar tempo-interactive nil (#$ . -472)) #@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. (defvar tempo-insert-region nil (#$ . -658)) #@99 *If non-NIL, show a buffer with possible completions, when only a partial completion can be found (defvar tempo-show-completion-buffer t (#$ . -1036)) #@129 *If NIL, a completion buffer generated by \[tempo-complete-tag] disappears at the next keypress; otherwise, it remains forever. (defvar tempo-leave-completion-buffer nil (#$ . -1194)) #@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 (#$ . 1385)) #@59 An association list with tags and corresponding templates (defvar tempo-tags nil (#$ . 1670)) #@379 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-local-tags (quote ((tempo-tags))) (#$ . 1771)) #@62 A collection of all the tags defined for the current buffer. (defvar tempo-collection nil (#$ . 2216)) #@54 Indicates if the tag collection needs to be rebuilt. (defvar tempo-dirty-collection t (#$ . 2325)) #@87 A list of marks to jump to with `\[tempo-forward-mark]' and `\[tempo-backward-mark]'. (defvar tempo-marks nil (#$ . 2430)) #@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]+\\)\\=" (#$ . 2560)) #@231 Element handlers for user-defined elements. A list of symbols which are bound to functions that take one argument. This function should return somthing to be sent to `tempo-insert' if it recognizes the argument, and NIL otherwise (defvar tempo-user-elements nil (#$ . 3488)) #@40 Temporary storage for named insertions (defvar tempo-named-insertions nil (#$ . 3769)) #@47 Region start when inserting around the region (defvar tempo-region-start (make-marker) (#$ . 3862)) #@46 Region stop when inserting around the region (defvar tempo-region-stop (make-marker) (#$ . 3968)) (byte-code "!!!!!" [make-variable-buffer-local tempo-marks tempo-local-tags tempo-match-finder tempo-collection tempo-dirty-collection] 2) (defalias 'tempo-mapc #[(fun lst) "?? @! A\"" [lst fun tempo-mapc] 3]) (defalias 'tempo-dolist '(macro . #[(il &rest forms) "@A@\nCD\"D E*" [il l i tempo-mapc function append lambda forms] 5])) (put (quote tempo-dolist) (quote 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 ) 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 ) Works just like the previous tag, but forces tempo-interactive to be true. - (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. 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) "\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 (#$ . 4500)]) #@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) "!\n !\"\f\" \"; `^ɓ;\n `]ɓDb !J\" !) )" [((byte-code " !\n\n!Ç" [tempo-forget-insertions boundp transient-mark-mode nil mark-active run-hooks deactivate-mark-hook] 2)) boundp transient-mark-mode mark-active zmacs-regions mark t on-region tempo-region-start nil tempo-region-stop tempo-insert-mark point-marker mapcar #[(elt) " \n\"" [tempo-insert elt on-region] 3] template tempo-forward-mark] 3 (#$ . 7813)]) #@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) "; !:@=A!:/@=/A!):I@=ID bA!:[@=[A@!:m@=mA\"=x != b != b `# != =iU#)?'c=l#)?'c=c=c = l #)?'!?'!$!\"" [element tempo-process-and-insert-string p tempo-insert-prompt-compat P t tempo-interactive r on-region tempo-region-stop s tempo-insert-named l mapcar #[(elt) " \n\"" [tempo-insert elt on-region] 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 (#$ . 8595)]) #@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) ":\n\"!" [prompt apply tempo-insert-prompt] 3 (#$ . 9607)]) #@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) "  !   !L LH;1\"! =\fc L \f\"L !*" [nil save-name tempo-lookup-named previous insertion no-insert tempo-insert-named tempo-interactive prompt error "tempo: The prompt (%s) is not a string" read-string tempo-save-named tempo-insert-mark point-marker] 3 (#$ . 9870)]) #@70 Tries all the user-defined element handlers in `tempo-user-elements' (defalias 'tempo-is-user-element #[(element) "" [found (byte-code "\n\"\"" [mapcar #[(handler) " !\f\n\")" [handler element result throw found] 4] tempo-user-elements throw found nil] 3)] 2 (#$ . 10831)]) #@40 Forget all the saved named insertions. (defalias 'tempo-forget-insertions #[nil "" [nil tempo-named-insertions] 2 (#$ . 11130)]) #@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Ç" [name data tempo-named-insertions nil] 2 (#$ . 11270)]) #@100 Lookup some saved data under the name NAME. Returns the data if NAME was found, and nil otherwise. (defalias 'tempo-lookup-named #[(name) " A" [name tempo-named-insertions] 2 (#$ . 11621)]) #@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) " ! !\n;\nc\n\")" [tempo-lookup-named name insertion tempo-insert-mark point-marker tempo-insert nil] 4 (#$ . 11821)]) #@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) "\"9 !\"<\"\"\" c" [tempo-insert-string-functions string tempo-mapc #[(fn) " !" [fn string] 2] error "Bogus value in tempo-insert-string-functions: %s"] 3 (#$ . 12218)]) #@53 Insert a mark `tempo-marks' while keeping it sorted (defalias 'tempo-insert-mark #[(mark) " C @W BA,\nA@ X,\nA \n@U?:\n \nAB)" [tempo-marks mark lp] 4 (#$ . 12609)]) #@53 Jump to the next mark in `tempo-forward-mark-list'. (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 (#$ . 12812) nil]) #@54 Jump to the previous mark in `tempo-back-mark-list'. (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 (#$ . 13060) 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) " J\" \fBJBL " [tag-list tempo-tags assoc tag template tempo-invalidate-collection] 3 (#$ . 13327) "sTag: \nCTemplate: "]) #@490 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 specifyingis 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) " \n  B B)   " [tag-list tempo-local-tags old completion-function tempo-match-finder tempo-invalidate-collection] 3 (#$ . 13664)]) #@87 Marks the tag collection as obsolete. Whenever it is needed again it will be rebuilt. (defalias 'tempo-invalidate-collection #[nil "" [t tempo-dirty-collection] 2 (#$ . 14383)]) #@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 " \"\"" [tempo-dirty-collection tempo-collection apply append mapcar #[(tag-list) " @!" [eval tag-list] 2] tempo-local-tags nil] 5 (#$ . 14572)]) #@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) ";#)\nŔŕ{ŔB) " [finder nil successful re-search-backward t 1] 4 (#$ . 14901)]) #@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) "  !@\fA \"@!\f! \"\n,`|\f: \nI \n=[ \"A\"\n \"oA\"\nc {  \"." [tempo-build-collection collection tempo-find-match-string tempo-match-finder match-info match-string match-start assoc exact try-completion compl silent ding t tempo-insert-template nil tempo-show-completion-buffer tempo-display-completions] 5 (#$ . 15201) "*"]) #@59 Show a buffer containing possible completions for STRING. (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 (#$ . 16378)]) #@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 "  !@\fA \"%`|A\"-" [tempo-build-collection collection tempo-find-match-string tempo-match-finder match-info match-string match-start assoc exact tempo-insert-template nil t] 4 (#$ . 16766) "*"]) (provide (quote tempo))