Mercurial > emacs
annotate lisp/tempo.el @ 10588:2a8f29cd9e9f
(Frassoc): New function.
(syms_of_fns): defsubr it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 29 Jan 1995 22:04:10 +0000 |
parents | 488c5be866c3 |
children | a74358cc05c6 |
rev | line source |
---|---|
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
1 ;;; tempo.el --- Flexible template insertion |
7267 | 2 ;; Copyright (C) 1994 Free Software Foundation, Inc. |
3 | |
7296 | 4 ;; Author: David K}gedal <davidk@lysator.liu.se > |
7267 | 5 ;; Created: 16 Feb 1994 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
6 ;; Version: 1.2 |
7267 | 7 ;; Keywords: extensions, languages, tools |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; This file provides a simple way to define powerful templates, or | |
28 ;; macros, if you wish. It is mainly intended for, but not limited to, | |
29 ;; other programmers to be used for creating shortcuts for editing | |
30 ;; certain kind of documents. It was originally written to be used by | |
31 ;; a HTML editing mode written by Nelson Minar <nelson@reed.edu>, and | |
32 ;; his html-helper-mode.el is probably the best example of how to use | |
33 ;; this program. | |
34 | |
35 ;; A template is defined as a list of items to be inserted in the | |
36 ;; current buffer at point. Some of the items can be simple strings, | |
37 ;; while other can control formatting or define special points of | |
38 ;; interest in the inserted text. | |
39 | |
40 ;; If a template defines a "point of interest" that point is inserted | |
41 ;; in a buffer-local list of "points of interest" that the user can | |
42 ;; jump between with the commands `tempo-backward-mark' and | |
43 ;; `tempo-forward-mark'. If the template definer provides a prompt for | |
44 ;; the point, and the variable `tempo-interactive' is non-nil, the | |
45 ;; user will be prompted for a string to be inserted in the buffer, | |
46 ;; using the minibuffer. | |
47 | |
48 ;; The template can also define one point to be replaced with the | |
49 ;; current region if the template command is called with a prefix (or | |
50 ;; a non-nil argument). | |
51 | |
52 ;; More flexible templates can be created by including lisp symbols, | |
53 ;; which will be evaluated as variables, or lists, which will will be | |
54 ;; evaluated as lisp expressions. | |
55 | |
56 ;; See the documentation for tempo-define-template for the different | |
57 ;; items that can be used to define a tempo template. | |
58 | |
59 ;; One of the more powerful features of tempo templates are automatic | |
60 ;; completion. With every template can be assigned a special tag that | |
61 ;; should be recognized by `tempo-complete-tag' and expanded to the | |
62 ;; complete template. By default the tags are added to a global list | |
63 ;; of template tags, and are matched against the last word before | |
64 ;; point. But if you assign your tags to a specific list, you can also | |
65 ;; specify another method for matching text in the buffer against the | |
66 ;; tags. In the HTML mode, for instance, the tags are matched against | |
67 ;; the text between the last `<' and point. | |
68 | |
69 ;; When defining a template named `foo', a symbol named | |
70 ;; `tempo-template-foo' will be created whose value as a variable will | |
71 ;; be the template definition, and its function value will be an | |
72 ;; interactive function that inserts the template at the point. | |
73 | |
74 ;; The latest tempo.el distribution can be fetched from | |
75 ;; ftp.lysator.liu.se in the directory /pub/emacs | |
76 | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
77 ;;; Known bugs: |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
78 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
79 ;; If the 'o is the first element in a template, strange things can |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
80 ;; happen when the template is inserted at the beginning of a |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
81 ;; line. This is due to strange behaviour in open-line. But it should |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
82 ;; be easily avoided. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
83 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
84 ;; The 'o tag is also a problem when including the region. This will |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
85 ;; be looked into. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
86 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
87 ;; Clicking mouse-2 in the completion buffer gives strange results. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
88 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
89 ;; There is a bug in some emacs versions that prevents completion from |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
90 ;; working. If it doesn't work for you, send me a note indicating your |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
91 ;; emacs version and your problems. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
92 |
7267 | 93 ;;; Code: |
94 | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
95 ;; (provide 'tempo) |
7267 | 96 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
97 ;;; User options |
7267 | 98 |
99 (defvar tempo-interactive nil | |
100 "*Prompt user for strings in templates. | |
101 If this variable is non-nil, `tempo-insert' prompts the | |
102 user for text to insert in the templates") | |
103 | |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
104 (defvar tempo-insert-region nil |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
105 "*Automatically insert current region when there is a `r' in the template |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
106 If this variable is NIL, `r' elements will be treated just like `p' |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
107 elements, unless the template function is given a prefix (or a non-nil |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
108 argument). If this variable is non-NIL, the behaviour is reversed. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
109 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
110 In Transient Mark mode, this option is unused.") |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
111 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
112 (defvar tempo-show-completion-buffer t |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
113 "*If non-NIL, show a buffer with possible completions, when only |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
114 a partial completion can be found") |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
115 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
116 (defvar tempo-leave-completion-buffer nil |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
117 "*If NIL, a completion buffer generated by \\[tempo-complete-tag] |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
118 disappears at the next keypress; otherwise, it remains forever.") |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
119 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
120 ;;; Internal variables |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
121 |
7267 | 122 (defvar tempo-insert-string-functions nil |
123 "List of functions to run when inserting a string. | |
124 Each function is called with a single arg, STRING." ) | |
125 | |
126 (defvar tempo-tags nil | |
127 "An association list with tags and corresponding templates") | |
128 | |
129 (defvar tempo-local-tags '((tempo-tags . nil)) | |
130 "A list of locally installed tag completion lists. | |
131 It is a association list where the car of every element is a symbol | |
132 whose varable value is a template list. The cdr part, if non-nil, is a | |
133 function or a regexp that defines the string to match. See the | |
134 documentation for the function `tempo-complete-tag' for more info. | |
135 | |
136 `tempo-tags' is always in the last position in this list.") | |
137 | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
138 (defvar tempo-collection nil |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
139 "A collection of all the tags defined for the current buffer.") |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
140 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
141 (defvar tempo-dirty-collection t |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
142 "Indicates if the tag collection needs to be rebuilt.") |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
143 |
7267 | 144 (defvar tempo-marks nil |
145 "A list of marks to jump to with `\\[tempo-forward-mark]' and `\\[tempo-backward-mark]'.") | |
146 | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
147 (defvar tempo-match-finder "\\b\\([^\\b]+\\)\\=" |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
148 "The regexp or function used to find the string to match against tags. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
149 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
150 If `tempo-match-finder is a string, it should contain a regular |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
151 expression with at least one \\( \\) pair. When searching for tags, |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
152 `tempo-complete-tag' calls `re-search-backward' with this string, and |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
153 the string between the first \\( and \\) is used for matching against |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
154 each string in the tag list. If one is found, the whole text between |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
155 the first \\( and the point is replaced with the inserted template. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
156 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
157 You will probably want to include \\ \= at the end of the regexp to |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
158 make sure that the string is matched only against text adjacent to the |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
159 point. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
160 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
161 If `tempo-match-finder' is a symbol, it should be a function that |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
162 returns a pair of the form (STRING . POS), where STRING is the string |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
163 used for matching and POS is the buffer position after which text |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
164 should be replaced with a template.") |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
165 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
166 (defvar tempo-user-elements nil |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
167 "Element handlers for user-defined elements. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
168 A list of symbols which are bound to functions that take one argument. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
169 This function should return somthing to be sent to `tempo-insert' if |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
170 it recognizes the argument, and NIL otherwise") |
7267 | 171 |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
172 (defvar tempo-named-insertions nil |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
173 "Temporary storage for named insertions") |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
174 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
175 (defvar tempo-region-start (make-marker) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
176 "Region start when inserting around the region") |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
177 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
178 (defvar tempo-region-stop (make-marker) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
179 "Region stop when inserting around the region") |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
180 |
7267 | 181 ;; Make some variables local to every buffer |
182 | |
183 (make-variable-buffer-local 'tempo-marks) | |
184 (make-variable-buffer-local 'tempo-local-tags) | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
185 (make-variable-buffer-local 'tempo-match-finder) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
186 (make-variable-buffer-local 'tempo-collection) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
187 (make-variable-buffer-local 'tempo-dirty-collection) |
7267 | 188 |
189 ;;; Functions | |
190 | |
191 ;; | |
192 ;; tempo-define-template | |
193 | |
194 (defun tempo-define-template (name elements &optional tag documentation taglist) | |
195 "Define a template. | |
196 This function creates a template variable `tempo-template-NAME' and an | |
197 interactive function `tempo-template-NAME' that inserts the template | |
198 at the point. The created function is returned. | |
199 | |
200 NAME is a string that contains the name of the template, ELEMENTS is a | |
201 list of elements in the template, TAG is the tag used for completion, | |
202 DOCUMENTATION is the documentation string for the insertion command | |
203 created, and TAGLIST (a symbol) is the tag list that TAG (if provided) | |
204 should be added to). If TAGLIST is nil and TAG is non-nil, TAG is | |
205 added to `tempo-tags' | |
206 | |
207 The elements in ELEMENTS can be of several types: | |
208 | |
209 - A string. It is sent to the hooks in `tempo-insert-string-functions', | |
210 and the result is inserted. | |
211 - The symbol 'p. This position is saved in `tempo-marks'. | |
212 - The symbol 'r. If `tempo-insert' is called with ON-REGION non-nil | |
213 the current region is placed here. Otherwise it works like 'p. | |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
214 - (p PROMPT <NAME>) If `tempo-interactive' is non-nil, the user is |
7267 | 215 prompted in the minbuffer with PROMPT for a string to be inserted. |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
216 If the optional parameter NAME is non-nil, the text is saved for |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
217 later insertion with the `s' tag. |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
218 If `tempo-interactive' is nil, it works like 'p. |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
219 - (r PROMPT) like the previous, but if `tempo-interactive' is nil |
7267 | 220 and `tempo-insert' is called with ON-REGION non-nil, the current |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
221 region is placed here. This usually happens when you call the |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
222 template function with a prefix argument. |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
223 - (s NAME) Inserts text previously read with the (p ..) construct. |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
224 Finds the insertion saved under NAME and inserts it. Acts like 'p |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
225 if tempo-interactive is nil. |
7267 | 226 - '& If there is only whitespace between the line start and point, |
227 nothing happens. Otherwise a newline is inserted. | |
228 - '% If there is only whitespace between point and end-of-line | |
229 nothing happens. Otherwise a newline is inserted. | |
230 - 'n inserts a newline. | |
231 - '> The line is indented using `indent-according-to-mode'. Note that | |
232 you often should place this item after the text you want on the | |
233 line. | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
234 - 'n> Inserts a newline and indents line. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
235 - 'o Like '% but leaves the point before the newline. |
7267 | 236 - nil. It is ignored. |
237 - Anything else. It is evaluated and the result is parsed again." | |
238 | |
239 (let* ((template-name (intern (concat "tempo-template-" | |
240 name))) | |
241 (command-name template-name)) | |
242 (set template-name elements) | |
243 (fset command-name (list 'lambda (list '&optional 'arg) | |
244 (or documentation | |
245 (concat "Insert a " name ".")) | |
246 (list 'interactive "*P") | |
247 (list 'tempo-insert-template (list 'quote | |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
248 template-name) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
249 (list 'if 'tempo-insert-region |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
250 (list 'not 'arg) 'arg)))) |
7267 | 251 (and tag |
252 (tempo-add-tag tag template-name taglist)) | |
253 command-name)) | |
254 | |
255 ;;; | |
256 ;;; tempo-insert-template | |
257 | |
258 (defun tempo-insert-template (template on-region) | |
259 "Insert a template. | |
260 TEMPLATE is the template to be inserted. If ON-REGION is non-nil the | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
261 `r' elements are replaced with the current region. In Transient Mark |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
262 mode, ON-REGION is ignored and assumed true if the region is active." |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
263 (if (and (boundp 'transient-mark-mode) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
264 transient-mark-mode |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
265 mark-active) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
266 (setq on-region t)) |
7267 | 267 (and on-region |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
268 (set-marker tempo-region-start (min (mark) (point))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
269 (set-marker tempo-region-stop (max (mark) (point)))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
270 (if on-region |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
271 (goto-char tempo-region-start)) |
7267 | 272 (save-excursion |
273 (tempo-insert-mark (point-marker)) | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
274 (mapcar (function (lambda (elt) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
275 (tempo-insert elt on-region))) |
7267 | 276 (symbol-value template)) |
277 (tempo-insert-mark (point-marker))) | |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
278 (tempo-forward-mark) |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
279 (tempo-forget-insertions) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
280 (and (boundp 'transient-mark-mode) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
281 transient-mark-mode |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
282 (deactivate-mark))) |
7267 | 283 |
284 ;;; | |
285 ;;; tempo-insert | |
286 | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
287 (defun tempo-insert (element on-region) |
7267 | 288 "Insert a template element. |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
289 Insert one element from a template. If ON-REGION is non-nil the `r' |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
290 elements are replaced with the current region. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
291 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
292 See documentation for `tempo-define-template' for the kind of elements |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
293 possible." |
7267 | 294 (cond ((stringp element) (tempo-process-and-insert-string element)) |
295 ((and (consp element) (eq (car element) 'p)) | |
296 (tempo-insert-prompt (cdr element))) | |
297 ((and (consp element) (eq (car element) 'r)) | |
298 (if on-region | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
299 (goto-char tempo-region-stop) |
7267 | 300 (tempo-insert-prompt (cdr element)))) |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
301 ((and (consp element) (eq (car element) 's)) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
302 (if tempo-interactive |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
303 (tempo-insert-named (cdr element)) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
304 (tempo-insert-mark (point-marker)))) |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
305 ((and (consp element) (eq (car element) 'l)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
306 (mapcar (function (lambda (elt) (tempo-insert elt on-region))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
307 (cdr element))) |
7267 | 308 ((eq element 'p) (tempo-insert-mark (point-marker))) |
309 ((eq element 'r) (if on-region | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
310 (goto-char tempo-region-stop) |
7267 | 311 (tempo-insert-mark (point-marker)))) |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
312 ((eq element 'r>) (if on-region |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
313 (progn |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
314 (goto-char tempo-region-stop) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
315 (indent-region (mark) (point) nil)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
316 (tempo-insert-mark (point-marker)))) |
7267 | 317 ((eq element '>) (indent-according-to-mode)) |
318 ((eq element '&) (if (not (or (= (current-column) 0) | |
319 (save-excursion | |
320 (re-search-backward | |
321 "^\\s-*\\=" nil t)))) | |
322 (insert "\n"))) | |
323 ((eq element '%) (if (not (or (eolp) | |
324 (save-excursion | |
325 (re-search-forward | |
326 "\\=\\s-*$" nil t)))) | |
327 (insert "\n"))) | |
328 ((eq element 'n) (insert "\n")) | |
329 ((eq element 'n>) (insert "\n") (indent-according-to-mode)) | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
330 ;; Bug: If the 'o is the first element in a template, strange |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
331 ;; things can happen when the template is inserted at the |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
332 ;; beginning of a line. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
333 ((eq element 'o) (if (not (or on-region |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
334 (eolp) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
335 (save-excursion |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
336 (re-search-forward |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
337 "\\=\\s-*$" nil t)))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
338 (open-line 1))) |
7267 | 339 ((null element)) |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
340 (t (tempo-insert (or (tempo-is-user-element element) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
341 (eval element)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
342 on-region)))) |
7267 | 343 |
344 ;;; | |
345 ;;; tempo-insert-prompt | |
346 | |
347 (defun tempo-insert-prompt (prompt) | |
348 "Prompt for a text string and insert it in the current buffer. | |
349 If the variable `tempo-interactive' is non-nil the user is prompted | |
350 for a string in the minibuffer, which is then inserted in the current | |
351 buffer. If `tempo-interactive' is nil, the current point is placed on | |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
352 `tempo-mark'. |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
353 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
354 PROMPT is the prompt string or a list containing the prompt string and |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
355 a name to save the inserted text under." |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
356 (if tempo-interactive |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
357 (let ((prompt-string (if (listp prompt) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
358 (car prompt) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
359 prompt)) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
360 (save-name (and (listp prompt) (nth 1 prompt))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
361 inserted-text) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
362 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
363 (progn |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
364 (setq inserted-text (read-string prompt-string)) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
365 (insert inserted-text) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
366 (if save-name |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
367 (tempo-remember-insertion save-name inserted-text)))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
368 (tempo-insert-mark (point-marker)))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
369 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
370 ;;; |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
371 ;;; tempo-is-user-element |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
372 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
373 (defun tempo-is-user-element (element) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
374 "Tries all the user-defined element handlers in |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
375 `tempo-user-elements'" |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
376 ;; Sigh... I need (some list) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
377 (catch 'found |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
378 (mapcar (function (lambda (handler) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
379 (let ((result (funcall handler element))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
380 (if result (throw 'found result))))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
381 tempo-user-elements) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
382 (throw 'found nil))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
383 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
384 ;;; |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
385 ;;; tempo-remember-insertion |
7267 | 386 |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
387 (defun tempo-remember-insertion (save-name string) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
388 "Save the text in STRING under the name SAVE-NAME for later retrieval." |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
389 (setq tempo-named-insertions (cons (cons save-name string) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
390 tempo-named-insertions))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
391 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
392 ;;; |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
393 ;;; tempo-forget-insertions |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
394 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
395 (defun tempo-forget-insertions () |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
396 "Forget all the saved named insertions." |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
397 (setq tempo-named-insertions nil)) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
398 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
399 ;;; |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
400 ;;; tempo-insert-named |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
401 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
402 (defun tempo-insert-named (elt) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
403 "Insert the previous insertion saved under a named specified in ELT. |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
404 The name is in the car of ELT." |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
405 (let* ((name (car elt)) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
406 (insertion (cdr (assq name tempo-named-insertions)))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
407 (if insertion |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
408 (insert insertion) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
409 (error "Named insertion not found")))) |
7267 | 410 |
411 ;;; | |
412 ;;; tempo-process-and-insert-string | |
413 | |
414 (defun tempo-process-and-insert-string (string) | |
415 "Insert a string from a template. | |
416 Run a string through the preprocessors in `tempo-insert-string-functions' | |
417 and insert the results." | |
418 (cond ((null tempo-insert-string-functions) | |
419 nil) | |
420 ((symbolp tempo-insert-string-functions) | |
421 (setq string | |
422 (apply tempo-insert-string-functions (list string)))) | |
423 ((listp tempo-insert-string-functions) | |
424 (mapcar (function (lambda (fn) | |
425 (setq string (apply fn string)))) | |
426 tempo-insert-string-functions)) | |
427 (t | |
428 (error "Bogus value in tempo-insert-string-functions: %s" | |
429 tempo-insert-string-functions))) | |
430 (insert string)) | |
431 | |
432 ;;; | |
433 ;;; tempo-insert-mark | |
434 | |
435 (defun tempo-insert-mark (mark) | |
436 "Insert a mark `tempo-marks' while keeping it sorted" | |
437 (cond ((null tempo-marks) (setq tempo-marks (list mark))) | |
438 ((< mark (car tempo-marks)) (setq tempo-marks (cons mark tempo-marks))) | |
439 (t (let ((lp tempo-marks)) | |
440 (while (and (cdr lp) | |
441 (<= (car (cdr lp)) mark)) | |
442 (setq lp (cdr lp))) | |
443 (if (not (= mark (car lp))) | |
444 (setcdr lp (cons mark (cdr lp)))))))) | |
445 | |
446 ;;; | |
447 ;;; tempo-forward-mark | |
448 | |
449 (defun tempo-forward-mark () | |
450 "Jump to the next mark in `tempo-forward-mark-list'." | |
451 (interactive) | |
452 (let ((next-mark (catch 'found | |
453 (mapcar | |
454 (function | |
455 (lambda (mark) | |
456 (if (< (point) mark) | |
457 (throw 'found mark)))) | |
458 tempo-marks) | |
459 ;; return nil if not found | |
460 nil))) | |
461 (if next-mark | |
462 (goto-char next-mark)))) | |
463 | |
464 ;;; | |
465 ;;; tempo-backward-mark | |
466 | |
467 (defun tempo-backward-mark () | |
468 "Jump to the previous mark in `tempo-back-mark-list'." | |
469 (interactive) | |
470 (let ((prev-mark (catch 'found | |
471 (let (last) | |
472 (mapcar | |
473 (function | |
474 (lambda (mark) | |
475 (if (<= (point) mark) | |
476 (throw 'found last)) | |
477 (setq last mark))) | |
478 tempo-marks) | |
479 last)))) | |
480 (if prev-mark | |
481 (goto-char prev-mark)))) | |
482 | |
483 ;;; | |
484 ;;; tempo-add-tag | |
485 | |
486 (defun tempo-add-tag (tag template &optional tag-list) | |
487 "Add a template tag. | |
488 Add the TAG, that should complete to TEMPLATE to the list in TAG-LIST, | |
489 or to `tempo-tags' if TAG-LIST is nil." | |
490 | |
491 (interactive "sTag: \nCTemplate: ") | |
492 (if (null tag-list) | |
493 (setq tag-list 'tempo-tags)) | |
494 (if (not (assoc tag (symbol-value tag-list))) | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
495 (set tag-list (cons (cons tag template) (symbol-value tag-list)))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
496 (tempo-invalidate-collection)) |
7267 | 497 |
498 ;;; | |
499 ;;; tempo-use-tag-list | |
500 | |
501 (defun tempo-use-tag-list (tag-list &optional completion-function) | |
502 "Install TAG-LIST to be used for template completion in the current buffer. | |
503 TAG-LIST is a symbol whose variable value is a tag list created with | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
504 `tempo-add-tag'. |
7267 | 505 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
506 COMPLETION-FUNCTION is an obsolete option for specifyingis an optional |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
507 function or string that is used by `\\[tempo-complete-tag]' to find a |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
508 string to match the tag against. It has the same definition as the |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
509 variable `tempo-match-finder'. In this version, supplying a |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
510 COMPLETION-FUNCTION just sets `tempo-match-finder' locally." |
7267 | 511 (let ((old (assq tag-list tempo-local-tags))) |
512 (if old | |
513 (setcdr old completion-function) | |
514 (setq tempo-local-tags (cons (cons tag-list completion-function) | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
515 tempo-local-tags)))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
516 (if completion-function |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
517 (setq tempo-match-finder completion-function)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
518 (tempo-invalidate-collection)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
519 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
520 ;;; |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
521 ;;; tempo-invalidate-collection |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
522 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
523 (defun tempo-invalidate-collection () |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
524 "Marks the tag collection as obsolete. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
525 Whenever it is needed again it will be rebuilt." |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
526 (setq tempo-dirty-collection t)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
527 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
528 ;;; |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
529 ;;; tempo-build-collection |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
530 |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
531 (defun tempo-build-collection () |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
532 "Build a collection of all the tags and return it. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
533 If `tempo-dirty-collection' is NIL, the old collection is reused." |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
534 (setq tempo-dirty nil) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
535 (or (and (not tempo-dirty-collection) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
536 tempo-collection) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
537 (setq tempo-collection |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
538 (apply (function append) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
539 (mapcar (function (lambda (tag-list) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
540 ; If the format for |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
541 ; tempo-local-tags changes, |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
542 ; change this |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
543 (eval (car tag-list)))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
544 tempo-local-tags))))) |
7267 | 545 |
546 ;;; | |
547 ;;; tempo-find-match-string | |
548 | |
549 (defun tempo-find-match-string (finder) | |
550 "Find a string to be matched against a tag list. | |
551 FINDER is a function or a string. Returns (STRING . POS)." | |
552 (cond ((stringp finder) | |
553 (save-excursion | |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
554 (or (re-search-backward finder nil t) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
555 0)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
556 (cons (buffer-substring (match-beginning 1) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
557 (match-end 1)) ; This seems to be a |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
558 ; bug in emacs |
7267 | 559 (match-beginning 1))) |
560 (t | |
561 (funcall finder)))) | |
562 | |
563 ;;; | |
564 ;;; tempo-complete-tag | |
565 | |
566 (defun tempo-complete-tag (&optional silent) | |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
567 "Look for a tag and expand it. |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
568 All the tags in the tag lists in `tempo-local-tags' (this includes |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
569 `tempo-tags') are searched for a match for the text before the point. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
570 The way the string to match for is determined can be altered with the |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
571 variable `tempo-match-finder' |
7267 | 572 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
573 If a single match is found, the corresponding template is expanded in |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
574 place of the matching string. |
7267 | 575 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
576 If a partial completion or no match at all is found, and SILENT is |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
577 non-NIL, the function will give a signal. |
7267 | 578 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
579 If a partial completion is found and `tempo-show-completion-buffer' is |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
580 non-NIL, a buffer containing possible completions is displayed." |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
581 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
582 ;; This function may look like a hack, but this is how I want it to |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
583 ;; work. |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
584 (interactive "*") |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
585 (let* ((collection (tempo-build-collection)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
586 (match-info (tempo-find-match-string tempo-match-finder)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
587 (match-string (car match-info)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
588 (match-start (cdr match-info)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
589 (exact (assoc match-string collection)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
590 (compl (or (car exact) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
591 (try-completion match-string collection)))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
592 (if compl (delete-region match-start (point))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
593 (cond ((null compl) (or silent (ding))) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
594 ((eq compl t) (tempo-insert-template |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
595 (cdr (assoc match-string |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
596 collection)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
597 nil)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
598 (t (if (setq exact (assoc compl collection)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
599 (tempo-insert-template (cdr exact) nil) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
600 (insert compl) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
601 (or silent (ding)) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
602 (if tempo-show-completion-buffer |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
603 (tempo-display-completions match-string |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
604 collection))))))) |
7267 | 605 |
606 | |
7410
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
607 ;;; |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
608 ;;; tempo-display-completions |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
609 |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
610 (defun tempo-display-completions (string tag-list) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
611 "Show a buffer containing possible completions for STRING." |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
612 (if tempo-leave-completion-buffer |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
613 (with-output-to-temp-buffer "*Completions*" |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
614 (display-completion-list |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
615 (all-completions string tag-list))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
616 (save-window-excursion |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
617 (with-output-to-temp-buffer "*Completions*" |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
618 (display-completion-list |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
619 (all-completions string tag-list))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
620 (sit-for 32767)))) |
4eca60cb3c4d
(tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents:
7296
diff
changeset
|
621 |
10516
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
622 (provide 'tempo) |
488c5be866c3
(tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents:
7410
diff
changeset
|
623 |
7267 | 624 ;;; tempo.el ends here |