Mercurial > emacs
comparison lisp/skeleton.el @ 7393:e4a565cee722
(mirror-mode): Commented out.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 07 May 1994 05:30:31 +0000 |
parents | 380e8fcde9a2 |
children | 6106d22ab2ca |
comparison
equal
deleted
inserted
replaced
7392:04308c8b8791 | 7393:e4a565cee722 |
---|---|
190 (if recursive (signal 'quit 'recursive))))))) | 190 (if recursive (signal 'quit 'recursive))))))) |
191 | 191 |
192 | 192 |
193 | 193 |
194 (defun skeleton-internal-1 (element) | 194 (defun skeleton-internal-1 (element) |
195 (cond ( (and (integerp element) | 195 (cond ((and (integerp element) |
196 (< element 0)) | 196 (< element 0)) |
197 (delete-char element)) | 197 (delete-char element)) |
198 ( (char-or-string-p element) | 198 ((char-or-string-p element) |
199 (insert (if skeleton-transformation | 199 (insert (if skeleton-transformation |
200 (funcall skeleton-transformation element) | 200 (funcall skeleton-transformation element) |
201 element)) ) | 201 element)) ) |
202 ( (eq element '\n) ; actually (eq '\n 'n) | 202 ((eq element '\n) ; actually (eq '\n 'n) |
203 (newline) | 203 (newline) |
204 (indent-relative t) ) | 204 (indent-relative t) ) |
205 ( (eq element '>) | 205 ((eq element '>) |
206 (indent-for-tab-command) ) | 206 (indent-for-tab-command) ) |
207 ( (eq element '<) | 207 ((eq element '<) |
208 (backward-delete-char-untabify (min tab-width (current-column))) ) | 208 (backward-delete-char-untabify (min tab-width (current-column))) ) |
209 ( (eq element '_) | 209 ((eq element '_) |
210 (or point | 210 (or point |
211 (setq point (point))) ) | 211 (setq point (point))) ) |
212 ( (eq element '&) | 212 ((eq element '&) |
213 (if modified | 213 (if modified |
214 (setq definition (cdr definition))) ) | 214 (setq definition (cdr definition))) ) |
215 ( (eq element '|) | 215 ((eq element '|) |
216 (or modified | 216 (or modified |
217 (setq definition (cdr definition))) ) | 217 (setq definition (cdr definition))) ) |
218 ( (if (consp element) | 218 ((if (consp element) |
219 (or (stringp (car element)) | 219 (or (stringp (car element)) |
220 (consp (car element)))) | 220 (consp (car element)))) |
221 (while (skeleton-internal-list element (car element) t)) ) | 221 (while (skeleton-internal-list element (car element) t)) ) |
222 ( (null element) ) | 222 ((null element) ) |
223 ( (skeleton-internal-1 (eval element)) ))) | 223 ((skeleton-internal-1 (eval element)) ))) |
224 | 224 |
225 | 225 |
226 ;; variables and command for automatically inserting pairs like () or "" | 226 ;; variables and command for automatically inserting pairs like () or "" |
227 | 227 |
228 (defvar pair nil | 228 (defvar pair nil |
278 (?< . ?>) | 278 (?< . ?>) |
279 (?` . ?')))) | 279 (?` . ?')))) |
280 last-command-char)))))) | 280 last-command-char)))))) |
281 | 281 |
282 | 282 |
283 | |
284 ;;;###autoload | |
285 ;; a more serious example can be found in shell-script.el | 283 ;; a more serious example can be found in shell-script.el |
286 (defun mirror-mode () | 284 ;;;(defun mirror-mode () |
287 "This major mode is an amusing little example of paired insertion. | 285 ;;; "This major mode is an amusing little example of paired insertion. |
288 All printable characters do a paired self insert, while the other commands | 286 ;;;All printable characters do a paired self insert, while the other commands |
289 work normally." | 287 ;;;work normally." |
290 (interactive) | 288 ;;; (interactive) |
291 (kill-all-local-variables) | 289 ;;; (kill-all-local-variables) |
292 (make-local-variable 'pair) | 290 ;;; (make-local-variable 'pair) |
293 (make-local-variable 'pair-on-word) | 291 ;;; (make-local-variable 'pair-on-word) |
294 (make-local-variable 'pair-filter) | 292 ;;; (make-local-variable 'pair-filter) |
295 (make-local-variable 'pair-alist) | 293 ;;; (make-local-variable 'pair-alist) |
296 (setq major-mode 'mirror-mode | 294 ;;; (setq major-mode 'mirror-mode |
297 mode-name "Mirror" | 295 ;;; mode-name "Mirror" |
298 pair-on-word t | 296 ;;; pair-on-word t |
299 ;; in the middle column insert one or none if odd window-width | 297 ;;; ;; in the middle column insert one or none if odd window-width |
300 pair-filter (lambda () | 298 ;;; pair-filter (lambda () |
301 (if (>= (current-column) | 299 ;;; (if (>= (current-column) |
302 (/ (window-width) 2)) | 300 ;;; (/ (window-width) 2)) |
303 ;; insert both on next line | 301 ;;; ;; insert both on next line |
304 (next-line 1) | 302 ;;; (next-line 1) |
305 ;; insert one or both? | 303 ;;; ;; insert one or both? |
306 (= (* 2 (1+ (current-column))) | 304 ;;; (= (* 2 (1+ (current-column))) |
307 (window-width)))) | 305 ;;; (window-width)))) |
308 ;; mirror these the other way round as well | 306 ;;; ;; mirror these the other way round as well |
309 pair-alist '((?) _ ?() | 307 ;;; pair-alist '((?) _ ?() |
310 (?] _ ?[) | 308 ;;; (?] _ ?[) |
311 (?} _ ?{) | 309 ;;; (?} _ ?{) |
312 (?> _ ?<) | 310 ;;; (?> _ ?<) |
313 (?/ _ ?\\) | 311 ;;; (?/ _ ?\\) |
314 (?\\ _ ?/) | 312 ;;; (?\\ _ ?/) |
315 (?` ?` _ "''") | 313 ;;; (?` ?` _ "''") |
316 (?' ?' _ "``")) | 314 ;;; (?' ?' _ "``")) |
317 ;; in this mode we exceptionally ignore the user, else it's no fun | 315 ;;; ;; in this mode we exceptionally ignore the user, else it's no fun |
318 pair t) | 316 ;;; pair t) |
319 (let ((map (make-keymap)) | 317 ;;; (let ((map (make-keymap)) |
320 (i ? )) | 318 ;;; (i ? )) |
321 (use-local-map map) | 319 ;;; (use-local-map map) |
322 (setq map (car (cdr map))) | 320 ;;; (setq map (car (cdr map))) |
323 (while (< i ?\^?) | 321 ;;; (while (< i ?\^?) |
324 (aset map i 'pair-insert-maybe) | 322 ;;; (aset map i 'pair-insert-maybe) |
325 (setq i (1+ i)))) | 323 ;;; (setq i (1+ i)))) |
326 (run-hooks 'mirror-mode-hook)) | 324 ;;; (run-hooks 'mirror-mode-hook)) |
327 | 325 |
328 ;; skeleton.el ends here | 326 ;; skeleton.el ends here |