comparison lisp/hm--html-menus/tmpl-minor-mode.el @ 42:8b8b7f3559a2 r19-15b104

Import from CVS: tag r19-15b104
author cvs
date Mon, 13 Aug 2007 08:54:51 +0200
parents 1917ad0d78d7
children 6a22abad6937
comparison
equal deleted inserted replaced
41:5d6df4963a99 42:8b8b7f3559a2
1 ;;; tmpl-minor-mode.el --- Template Minor Mode 1 ;;; tmpl-minor-mode.el --- Template Minor Mode
2 ;;; 2 ;;;
3 ;;; $Id: tmpl-minor-mode.el,v 1.3 1997/03/04 08:44:56 steve Exp $ 3 ;;; $Id: tmpl-minor-mode.el,v 1.4 1997/03/24 01:26:54 steve Exp $
4 ;;; 4 ;;;
5 ;;; Copyright (C) 1993 - 1997 Heiko Muenkel 5 ;;; Copyright (C) 1993 - 1997 Heiko Muenkel
6 ;;; email: muenkel@tnt.uni-hannover.de 6 ;;; email: muenkel@tnt.uni-hannover.de
7 ;;; 7 ;;;
8 ;;; Keywords: data tools 8 ;;; Keywords: data tools
59 (require 'adapt) 59 (require 'adapt)
60 60
61 61
62 (defvar tmpl-template-dir-list nil 62 (defvar tmpl-template-dir-list nil
63 "*A list of directories with the template files. 63 "*A list of directories with the template files.
64 If it is nil, then the default-directory is used. 64 If it is nil, then the default-directory will be used.
65 If more the one directories are given, then the 65 If more than one directory is given, then the
66 template filenames should differ in all directories. 66 template filenames should differ in all directories.
67 67
68 This variable is used in the commands for inserting templates. 68 This variable is used in the commands for inserting templates.
69 Look at `tmpl-insert-template-file-from-fixed-dirs' and 69 Look at `tmpl-insert-template-file-from-fixed-dirs' and
70 at `tmpl-insert-template-file'. The command `tmpl-insert-template-file' 70 at `tmpl-insert-template-file'. The command `tmpl-insert-template-file'
387 (error "ERROR In Line %d: Wrong Template Name (%s) !" 387 (error "ERROR In Line %d: Wrong Template Name (%s) !"
388 (tmpl-current-line) template-name))))))) 388 (tmpl-current-line) template-name)))))))
389 389
390 ;;;###autoload 390 ;;;###autoload
391 (defun tmpl-expand-templates-in-region (&optional begin end) 391 (defun tmpl-expand-templates-in-region (&optional begin end)
392 "Expand the templates in the region from BEGIN to END. 392 "Expands the templates in the region from BEGIN to END.
393 If BEGIN and and are nil, then the current region is used." 393 If BEGIN and END are nil, then the current region is used."
394 (interactive) 394 (interactive)
395 (tmpl-save-excursion 395 (tmpl-save-excursion
396 (narrow-to-region (or begin (region-beginning)) 396 (narrow-to-region (or begin (region-beginning))
397 (or end (region-end))) 397 (or end (region-end)))
398 (goto-char (point-min)) 398 (goto-char (point-min))
401 (widen))) 401 (widen)))
402 402
403 403
404 ;;;###autoload 404 ;;;###autoload
405 (defun tmpl-expand-templates-in-buffer () 405 (defun tmpl-expand-templates-in-buffer ()
406 "Expand all templates in the current buffer." 406 "Expands all templates in the current buffer."
407 (interactive) 407 (interactive)
408 (tmpl-expand-templates-in-region (point-min) (point-max))) 408 (tmpl-expand-templates-in-region (point-min) (point-max)))
409 409
410 410
411 (defun tmpl-escape-tmpl-sign-in-region (&optional begin end) 411 (defun tmpl-escape-tmpl-sign-in-region (&optional begin end)
412 "Escape all `tmpl-sign' with a `tmpl-sign' in the region from BEGIN to END. 412 "Escapes all `tmpl-sign' with a `tmpl-sign' in the region from BEGIN to END.
413 If BEGIN and END are nil, then the active region between mark and point is 413 If BEGIN and END are nil, then the active region between mark and point is
414 used." 414 used."
415 (interactive) 415 (interactive)
416 (save-excursion 416 (save-excursion
417 (narrow-to-region (or begin (region-beginning)) 417 (narrow-to-region (or begin (region-beginning))
521 521
522 ;;;###autoload 522 ;;;###autoload
523 (defun tmpl-insert-template-file-from-fixed-dirs (file) 523 (defun tmpl-insert-template-file-from-fixed-dirs (file)
524 "Inserts a template FILE and expands it, if `tmpl-automatic-expand' is t. 524 "Inserts a template FILE and expands it, if `tmpl-automatic-expand' is t.
525 This command tries to read the template file from a list of 525 This command tries to read the template file from a list of
526 predefined directries (look at `tmpl-template-dir-list') and it filters 526 predefined directories (look at `tmpl-template-dir-list') and it filters
527 the contents of this directories with the regular expression 527 the contents of these directories with the regular expression
528 `tmpl-filter-regexp' (look also at this variable). 528 `tmpl-filter-regexp' (look also at this variable).
529 The command uses a history variable, which could be changed with the 529 The command uses a history variable, which could be changed with the
530 variable `tmpl-history-variable-name'. 530 variable `tmpl-history-variable-name'.
531 531
532 The user of the command is able to change interactive to another 532 The user of the command is able to change interactively to another
533 directory by entering at first the string \"Change the directory\". 533 directory by entering at first the string \"Change the directory\".
534 This maybe to difficult for the user. Therefore another command 534 This may be too difficult for the user. Therefore another command
535 called `tmpl-insert-template-file' exist, which doesn't use fixed 535 called `tmpl-insert-template-file' exist, which doesn't use fixed
536 directories and filters." 536 directories and filters."
537 (interactive 537 (interactive
538 (list (tmpl-read-template-filename tmpl-template-dir-list 538 (list (tmpl-read-template-filename tmpl-template-dir-list
539 tmpl-filter-regexp 539 tmpl-filter-regexp
544 file) 544 file)
545 545
546 546
547 ;;;###autoload 547 ;;;###autoload
548 (defun tmpl-insert-template-file (file) 548 (defun tmpl-insert-template-file (file)
549 "Insert a template FILE and expand it, if `tmpl-automatic-expand' is t. 549 "Inserts a template FILE and expand it, if `tmpl-automatic-expand' is t.
550 Look also at `tmpl-template-dir-list', to specify a default template directory. 550 Look also at `tmpl-template-dir-list', to specify a default template directory.
551 You should also take a look at `tmpl-insert-template-file-from-fixed-dirs' 551 You should also take a look at `tmpl-insert-template-file-from-fixed-dirs'
552 which has additional advantages (and disadvantages :-). 552 which has additional advantages (and disadvantages :-).
553 553
554 ATTENTION: The interface of this function has changed. The old 554 ATTENTION: The interface of this function has changed. The old
621 621
622 622
623 (if (adapt-xemacsp) 623 (if (adapt-xemacsp)
624 (defun tmpl-define-minor-mode-keymap () 624 (defun tmpl-define-minor-mode-keymap ()
625 "Defines the minor mode keymap." 625 "Defines the minor mode keymap."
626 (define-key tmpl-minor-mode-map [(control c) x] 626 (define-key tmpl-minor-mode-map [(control c) (control c) x]
627 'tmpl-expand-templates-in-region) 627 'tmpl-expand-templates-in-region)
628 (define-key tmpl-minor-mode-map [(control c) (control x)] 628 (define-key tmpl-minor-mode-map [(control c) (control c) (control x)]
629 'tmpl-expand-templates-in-buffer) 629 'tmpl-expand-templates-in-buffer)
630 (define-key tmpl-minor-mode-map [(control c) escape] 630 (define-key tmpl-minor-mode-map [(control c) (control c) e]
631 'tmpl-escape-tmpl-sign-in-region) 631 'tmpl-escape-tmpl-sign-in-region)
632 (define-key tmpl-minor-mode-map [(control c) (control escape)] 632 (define-key tmpl-minor-mode-map
633 [(control c) (control c) (control e)]
633 'tmpl-escape-tmpl-sign-in-buffer)) 634 'tmpl-escape-tmpl-sign-in-buffer))
634 (defun tmpl-define-minor-mode-keymap () 635 (defun tmpl-define-minor-mode-keymap ()
635 "Defines the minor mode keymap." 636 "Defines the minor mode keymap."
636 (define-key tmpl-minor-mode-map [?\C-c ?x] 637 (define-key tmpl-minor-mode-map [?\C-c ?\C-c ?x]
637 'tmpl-expand-templates-in-region) 638 'tmpl-expand-templates-in-region)
638 (define-key tmpl-minor-mode-map [?\C-c ?\C-x] 639 (define-key tmpl-minor-mode-map [?\C-c ?\C-c ?\C-x]
639 'tmpl-expand-templates-in-buffer) 640 'tmpl-expand-templates-in-buffer)
640 (define-key tmpl-minor-mode-map [?\C-c escape] 641 (define-key tmpl-minor-mode-map [?\C-c ?\C-c ?e]
641 'tmpl-escape-tmpl-sign-in-region) 642 'tmpl-escape-tmpl-sign-in-region)
642 (define-key tmpl-minor-mode-map [?\C-c C-escape] 643 (define-key tmpl-minor-mode-map [?\C-c ?\C-c ?\C-e]
643 'tmpl-escape-tmpl-sign-in-buffer)) 644 'tmpl-escape-tmpl-sign-in-buffer))
644 ) 645 )
645 646
646 647
647 (defun tmpl-minor-mode () 648 (defun tmpl-minor-mode ()