annotate lisp/tempo.el @ 68465:37d03b3298bf

The Great Cleanup Remove circular dependencies. mh-e.el now includes few require statements and stands alone. Other files should need to require mh-e.el, which requires mh-loaddefs.el, plus variable-only files such as mh-scan.el. Remove unneeded require statements. Remove unneeded load statements, or replace them with non-fatal require statements. Break out components into their own files that were often spread between many files. As a result, many functions that are now only used within a single file no longer need to be autoloaded. Rearrange and provide consistent headings. Untabify. * mh-acros.el: Update commentary to reflect current usage. Add autoload cookies to all macros. (mh-require-cl): Merge docstring and comment. (mh-do-in-xemacs): Fix typo in docstring. (assoc-string): Move to new file mh-compat.el. (with-mh-folder-updating, mh-in-show-buffer) (mh-do-at-event-location, mh-seq-msgs): Move here from mh-utils.el. (mh-iterate-on-messages-in-region, mh-iterate-on-range): Move here from mh-seq.el. * mh-alias.el (mh-address-mail-regexp) (mh-goto-address-find-address-at-point): Move here from mh-utils.el. (mh-folder-line-matches-show-buffer-p): Move here from mh-e.el. * mh-buffers.el: Update descriptive text. * mh-comp.el (mh-note-repl, mh-note-forw, mh-note-dist): Move to new file mh-scan.el. (mh-yank-hooks, mh-to-field-choices, mh-position-on-field) (mh-letter-menu, mh-letter-mode-help-messages) (mh-letter-buttons-init-flag, mh-letter-mode) (mh-font-lock-field-data, mh-letter-header-end) (mh-auto-fill-for-letter, mh-to-field, mh-to-fcc) (mh-file-is-vcard-p, mh-insert-signature, mh-check-whom) (mh-insert-letter, mh-extract-from-attribution, mh-yank-cur-msg) (mh-filter-out-non-text, mh-insert-prefix-string) (mh-current-fill-prefix, mh-open-line, mh-complete-word) (mh-folder-expand-at-point, mh-letter-complete-function-alist) (mh-letter-complete, mh-letter-complete-or-space) (mh-letter-confirm-address, mh-letter-header-field-at-point) (mh-letter-next-header-field-or-indent) (mh-letter-next-header-field, mh-letter-previous-header-field) (mh-letter-skipped-header-field-p) (mh-letter-skip-leading-whitespace-in-header-field) (mh-hidden-header-keymap) (mh-letter-toggle-header-field-display-button) (mh-letter-toggle-header-field-display) (mh-letter-truncate-header-field, mh-letter-mode-map): Move to new file mh-letter.el. (mh-letter-mode-map, mh-sent-from-folder, mh-send-args) (mh-pgp-support-flag, mh-x-mailer-string) (mh-letter-header-field-regexp): Move to mh-e.el. (mh-goto-header-field, mh-goto-header-end) (mh-extract-from-header-value, mh-beginning-of-word): Move to mh-utils.el. (mh-insert-header-separator): Move to mh-comp.el. (mh-display-completion-list-compat): Move to new file mh-compat.el. * mh-compat.el: New file. (assoc-string): Move here from mh-acros.el. (mh-display-completion-list): Move here from mh-comp.el. * mh-customize.el: Move content into mh-e.el and remove. * mh-e.el (mh-folder-mode-map, mh-folder-seq-tool-bar-map) (mh-folder-tool-bar-map, mh-inc-spool-map, mh-letter-mode-map) (mh-letter-tool-bar-map, mh-search-mode-map, mh-show-mode-map) (mh-show-seq-tool-bar-map, mh-show-tool-bar-map): All maps now declared here so that they can be used in docstrings. (mh-sent-from-folder, mh-sent-from-msg) (mh-letter-header-field-regexp, mh-pgp-support-flag) (mh-x-mailer-string): Move here from mh-comp.el. (mh-folder-line-matches-show-buffer-p): Move to mh-alias.el. (mh-thread-scan-line-map, mh-thread-scan-line-map-stack): Move here from mh-seq.el. (mh-draft-folder, mh-inbox, mh-user-path, mh-current-folder) (mh-previous-window-config, mh-seen-list, mh-seq-list) (mh-show-buffer, mh-showing-mode, mh-globals-hash) (mh-show-folder-buffer, mh-mail-header-separator) (mh-unseen-seq, mh-previous-seq, mh-page-to-next-msg-flag) (mh-signature-separator, mh-signature-separator-regexp) (mh-list-to-string, mh-list-to-string-1): Move here from mh-utils.el. (mh-index-max-cmdline-args, mh-xargs, mh-quote-for-shell) (mh-exec-cmd, mh-exec-cmd-error, mh-exec-cmd-daemon) (mh-exec-cmd-env-daemon, mh-process-daemon, mh-exec-cmd-quiet) (mh-exec-cmd-output) (mh-exchange-point-and-mark-preserving-active-mark) (mh-exec-lib-cmd-output, mh-handle-process-error): Move here from deprecated file mh-exec.el. (mh-path): Move here from deprecated file mh-customize.el. (mh-sys-path, mh-variants, mh-variant-in-use, mh-progs, mh-lib) (mh-flists-present-flag, mh-variants, mh-variant-mh-info) (mh-variant-mu-mh-info, mh-variant-nmh-info, mh-file-command-p) (mh-variant-set-variant, mh-variant-p, mh-profile-component) (mh-profile-component-value, mh-defface-compat): Move here from deprecated file mh-init.el. (mh-goto-next-button, mh-folder-mime-action) (mh-folder-toggle-mime-part, mh-folder-inline-mime-part) (mh-folder-save-mime-part, mh-toggle-mime-buttons): Move to to mh-mime.el. (mh-scan-format-mh, mh-scan-format-nmh, mh-note-deleted) (mh-note-refiled, mh-note-cur, mh-scan-good-msg-regexp) (mh-scan-deleted-msg-regexp, mh-scan-refiled-msg-regexp) (mh-scan-valid-regexp, mh-scan-cur-msg-number-regexp) (mh-scan-date-regexp, mh-scan-rcpt-regexp, mh-scan-body-regexp) (mh-scan-subject-regexp, mh-scan-sent-to-me-sender-regexp) (mh-scan-cmd-note-width, mh-scan-destination-width) (mh-scan-date-width, mh-scan-date-flag-width) (mh-scan-from-mbox-width, mh-scan-from-mbox-sep-width) (mh-scan-field-destination-offset) (mh-scan-field-from-start-offset, mh-scan-field-from-end-offset) (mh-scan-field-subject-start-offset, mh-scan-format) (mh-msg-num-width-to-column, mh-set-cmd-note): Move to new file mh-scan.el. (mh-partial-folder-mode-line-annotation) (mh-folder-font-lock-keywords, mh-folder-font-lock-subject) (mh-generate-sequence-font-lock, mh-last-destination) (mh-last-destination-write, mh-first-msg-num, mh-last-msg-num) (mh-rmail, mh-nmail, mh-delete-msg, mh-delete-msg-no-motion) (mh-execute-commands, mh-first-msg, mh-header-display) (mh-inc-folder, mh-last-msg, mh-next-undeleted-msg) (mh-folder-from-address, mh-prompt-for-refile-folder) (mh-refile-msg, mh-refile-or-write-again, mh-quit, mh-page-msg) (mh-previous-page, mh-previous-undeleted-msg) (mh-previous-unread-msg, mh-next-button, mh-prev-button) (mh-reset-threads-and-narrowing, mh-rescan-folder) (mh-write-msg-to-file, mh-toggle-showing, mh-undo) (mh-visit-folder, mh-update-sequences, mh-delete-a-msg) (mh-refile-a-msg, mh-next-msg, mh-next-unread-msg) (mh-set-scan-mode, mh-undo-msg, mh-make-folder) (mh-folder-sequence-menu, mh-folder-message-menu) (mh-folder-folder-menu, mh-remove-xemacs-horizontal-scrollbar) (mh-write-file-functions-compat, mh-folder-mode) (mh-restore-desktop-buffer, mh-scan-folder) (mh-regenerate-headers, mh-generate-new-cmd-note) (mh-get-new-mail, mh-make-folder-mode-line, mh-goto-cur-msg) (mh-process-or-undo-commands, mh-process-commands) (mh-update-unseen, mh-delete-scan-msgs) (mh-outstanding-commands-p): Move to new file mh-folder.el. (mh-mapc, mh-colors-available-p, mh-colors-in-use-p) (mh-make-local-vars, mh-coalesce-msg-list, mh-greaterp) (mh-lessp): Move to mh-utils.el. (mh-parse-flist-output-line, mh-folder-size-folder) (mh-folder-size-flist, mh-folder-size, mh-add-sequence-notation) (mh-remove-sequence-notation, mh-remove-cur-notation) (mh-remove-all-notation, mh-delete-seq-locally) (mh-read-folder-sequences, mh-read-msg-list) (mh-notate-user-sequences, mh-internal-seqs, mh-internal-seq) (mh-valid-seq-p, mh-delete-msg-from-seq, mh-catchup) (mh-delete-a-msg-from-seq, mh-undefine-sequence) (mh-define-sequence, mh-seq-containing-msg): Move to mh-seq.el. (mh-xemacs-flag) (mh-customize, mh-e, mh-alias, mh-folder, mh-folder-selection) (mh-identity, mh-inc, mh-junk, mh-letter, mh-ranges) (mh-scan-line-formats, mh-search, mh-sending-mail, mh-sequences) (mh-show, mh-speedbar, mh-thread, mh-tool-bar, mh-hooks) (mh-faces, mh-alias-completion-ignore-case-flag) (mh-alias-expand-aliases-flag, mh-alias-flash-on-comma) (mh-alias-insert-file, mh-alias-insertion-location) (mh-alias-local-users, mh-alias-local-users-prefix) (mh-alias-passwd-gecos-comma-separator-flag) (mh-new-messages-folders, mh-ticked-messages-folders) (mh-large-folder, mh-recenter-summary-flag) (mh-recursive-folders-flag, mh-sortm-args) (mh-default-folder-for-message-function, mh-default-folder-list) (mh-default-folder-must-exist-flag, mh-default-folder-prefix) (mh-identity-list, mh-auto-fields-list) (mh-auto-fields-prompt-flag, mh-identity-default) (mh-identity-handlers, mh-inc-prog, mh-inc-spool-list) (mh-junk-choice, mh-junk-function-alist, mh-junk-choose) (mh-junk-background, mh-junk-disposition, mh-junk-program) (mh-compose-insertion, mh-compose-skipped-header-fields) (mh-compose-space-does-completion-flag) (mh-delete-yanked-msg-window-flag) (mh-extract-from-attribution-verb, mh-ins-buf-prefix) (mh-letter-complete-function, mh-letter-fill-column) (mh-mml-method-default, mh-signature-file-name) (mh-signature-separator-flag, mh-x-face-file, mh-yank-behavior) (mh-interpret-number-as-range-flag, mh-adaptive-cmd-note-flag) (mh-scan-format-file-check, mh-scan-format-file) (mh-adaptive-cmd-note-flag-check, mh-scan-prog) (mh-search-program, mh-compose-forward-as-mime-flag) (mh-compose-letter-function, mh-compose-prompt-flag) (mh-forward-subject-format, mh-insert-x-mailer-flag) (mh-redist-full-contents-flag, mh-reply-default-reply-to) (mh-reply-show-message-flag, mh-refile-preserves-sequences-flag) (mh-tick-seq, mh-update-sequences-after-mh-show-flag) (mh-bury-show-buffer-flag, mh-clean-message-header-flag) (mh-decode-mime-flag, mh-display-buttons-for-alternatives-flag) (mh-display-buttons-for-inline-parts-flag) (mh-do-not-confirm-flag, mh-fetch-x-image-url) (mh-graphical-smileys-flag, mh-graphical-emphasis-flag) (mh-highlight-citation-style) (mh-invisible-header-fields-internal) (mh-delay-invisible-header-generation-flag) (mh-invisible-header-fields, mh-invisible-header-fields-default) (mh-invisible-header-fields-compiled, mh-invisible-headers) (mh-lpr-command-format, mh-max-inline-image-height) (mh-max-inline-image-width, mh-mhl-format-file) (mh-mime-save-parts-default-directory, mh-print-background-flag) (mh-show-maximum-size, mh-show-use-goto-addr-flag) (mh-show-use-xface-flag, mh-store-default-directory) (mh-summary-height, mh-speed-update-interval) (mh-show-threads-flag, mh-tool-bar-search-function) (mh-after-commands-processed-hook, mh-alias-reloaded-hook) (mh-before-commands-processed-hook, mh-before-quit-hook) (mh-before-send-letter-hook, mh-delete-msg-hook) (mh-find-path-hook, mh-folder-mode-hook, mh-forward-hook) (mh-inc-folder-hook, mh-insert-signature-hook) (mh-kill-folder-suppress-prompt-hooks, mh-letter-mode-hook) (mh-mh-to-mime-hook, mh-search-mode-hook, mh-quit-hook) (mh-refile-msg-hook, mh-show-hook, mh-show-mode-hook) (mh-unseen-updated-hook, mh-min-colors-defined-flag) (mh-folder-address, mh-folder-body) (mh-folder-cur-msg-number, mh-folder-date, mh-folder-deleted) (mh-folder-followup, mh-folder-msg-number, mh-folder-refiled) (mh-folder-sent-to-me-hint, mh-folder-sent-to-me-sender) (mh-folder-subject, mh-folder-tick, mh-folder-to) (mh-search-folder, mh-letter-header-field, mh-show-cc) (mh-show-date, mh-show-from, mh-show-header, mh-show-pgg-bad) (mh-show-pgg-good, mh-show-pgg-unknown, mh-show-signature) (mh-show-subject, mh-show-to, mh-show-xface, mh-speedbar-folder) (mh-speedbar-folder-with-unseen-messages) (mh-speedbar-selected-folder) (mh-speedbar-selected-folder-with-unseen-messages): Move here from deprecated file mh-customize.el. * mh-exec.el: Move content into mh-e.el and remove. * mh-folder.el: New file. Contains mh-folder-mode from mh-e.el * mh-funcs.el (mh-note-copied, mh-note-printed): Move to new file mh-scan.el. (mh-ephem-message, mh-help, mh-prefix-help): Move to mh-utils.el. * mh-gnus.el (mm-uu-dissect-text-parts): Add. (mh-mail-abbrev-make-syntax-table): Move to mh-utils.el and rename to mail-abbrev-make-syntax-table. * mh-identity.el (mh-identity-menu): New variable for existing menu. (mh-identity-make-menu-no-autoload): New alias for mh-identity-make-menu which can be called from mh-e.el. (mh-identity-list-set): Move to mh-e.el. (mh-identity-add-menu): New function (mh-insert-identity): Add optional argument maybe-insert so that local variable mh-identity-local does not have to be visible. (mh-identity-handler-default): * mh-inc.el (mh-inc-spool-map): Move declaration to mh-e.el (with rest of keymaps). Update key binding for ? to call mh-help with help messages in new argument. (mh-inc-spool-make-no-autoload): New alias for mh-inc-spool-make which can be called from mh-e.el. (mh-inc-spool-list-set): Simplify update of mh-inc-spool-map-help. * mh-init.el: Move content into mh-e.el and remove. * mh-junk.el: Update requires, untabify, and add mh-autoload cookies. * mh-letter.el: New file. Contains mh-letter-mode from mh-comp.el. * mh-limit.el: New file. Contains display limit commands from mh-mime.el. * mh-mime.el: Rearrange for consistency with other files. (mh-buffer-data, mh-mm-inline-media-tests): Move here from mh-utils.el. (mh-folder-inline-mime-part, mh-folder-save-mime-part) (mh-folder-toggle-mime-part, mh-toggle-mime-buttons) (mh-goto-next-button): Move here from mh-e.el. * mh-print.el: Rearrange for consistency with other files. * mh-scan.el: New file. Contains scan line constants and utilities from XXX, mh-funcs, mh-utils.el. * mh-search.el: Rearrange for consistency with other files. (mh-search-mode-map): Drop C-c C-f {dr} bindings since these fields which don't exist in the saved header. Replace C-c C-f f with C-c C-f m per mail-mode consistency. (mh-search-mode): Use mh-set-help instead of setting mh-help-messages. * mh-seq.el (mh-thread-message, mh-thread-container) (mh-thread-id-hash, mh-thread-subject-hash, mh-thread-id-table) (mh-thread-id-index-map, mh-thread-index-id-map) (mh-thread-scan-line-map, mh-thread-scan-line-map-stack) (mh-thread-subject-container-hash, mh-thread-duplicates) (mh-thread-history, mh-thread-body-width) (mh-thread-find-msg-subject mh-thread-initialize-hash) (mh-thread-initialize, mh-thread-id-container) (mh-thread-remove-parent-link, mh-thread-add-link) (mh-thread-ancestor-p, mh-thread-get-message-container) (mh-thread-get-message, mh-thread-canonicalize-id) (mh-thread-prune-subject, mh-thread-container-subject) (mh-thread-rewind-pruning, mh-thread-prune-containers) (mh-thread-sort-containers, mh-thread-group-by-subject) (mh-thread-process-in-reply-to, mh-thread-set-tables) (mh-thread-update-id-index-maps, mh-thread-generate) (mh-thread-inc, mh-thread-generate-scan-lines) (mh-thread-parse-scan-line, mh-thread-update-scan-line-map) (mh-thread-add-spaces, mh-thread-print-scan-lines) (mh-thread-folder, mh-toggle-threads, mh-thread-forget-message) (mh-thread-current-indentation-level, mh-thread-next-sibling) (mh-thread-previous-sibling, mh-thread-immediate-ancestor) (mh-thread-ancestor, mh-thread-find-children) (mh-message-id-regexp, mh-thread-delete, mh-thread-refile): Move to new file mh-thread.el. (mh-subject-to-sequence, mh-subject-to-sequence-unthreaded) (mh-subject-to-sequence-threaded, mh-edit-pick-expr) (mh-pick-args-list, mh-narrow-to-subject, mh-narrow-to-from) (mh-narrow-to-cc, mh-narrow-to-to, mh-narrow-to-header-field) (mh-current-message-header-field, mh-narrow-to-range) (mh-delete-subject, mh-delete-subject-or-thread): Move to new file mh-limit.el. (mh-iterate-on-messages-in-region, mh-iterate-on-range): Move to mh-acros.el. (mh-internal-seqs, mh-catchup, mh-delete-msg-from-seq) (mh-internal-seq, mh-valid-seq-p, mh-seq-containing-msg) (mh-define-sequence, mh-undefine-sequence) (mh-delete-a-msg-from-seq, mh-delete-seq-locally) (mh-folder-size, mh-folder-size-flist, mh-folder-size-folder) (mh-parse-flist-output-line, mh-read-folder-sequences) (mh-read-msg-list, mh-notate-user-sequences) (mh-remove-cur-notation, mh-add-sequence-notation) (mh-remove-sequence-notation, mh-remove-all-notation): Move here from mh-e.el. (mh-make-seq, mh-seq-name, mh-find-seq, mh-seq-to-msgs) (mh-add-msgs-to-seq, mh-notate): Move here from mh-utils.el. * mh-show.el: New file. Contains mh-show-mode from mh-utils.el. * mh-speed.el: Rearrange for consistency with other files. * mh-thread.el: New file. Contains threading code from mh-seq.el. * mh-tool-bar.el: New file. Contains tool bar creation code from deprecated file mh-customize.el. * mh-utils.el (recursive-load-depth-limit): Remove setting. No longer needed. (mh-scan-msg-number-regexp, mh-scan-msg-overflow-regexp) (mh-scan-msg-format-regexp, mh-scan-msg-format-string) (mh-scan-msg-search-regexp, mh-cmd-note, mh-note-seq) (mh-update-scan-format, mh-msg-num-width): Move to new file mh-scan.el. (mh-show-buffer-mode-line-buffer-id, mh-letter-header-font-lock) (mh-header-field-font-lock, mh-header-to-font-lock) (mh-header-cc-font-lock, mh-header-subject-font-lock) (mh-show-font-lock-keywords) (mh-show-font-lock-keywords-with-cite) (mh-show-font-lock-fontify-region) (mh-gnus-article-highlight-citation, mh-showing-with-headers) (mh-start-of-uncleaned-message, mh-invalidate-show-buffer) (mh-unvisit-file, mh-defun-show-buffer, mh-show-mode-map) (mh-show-sequence-menu, mh-show-message-menu) (mh-show-folder-menu, mh-show-mode, mh-show-addr) (mh-maybe-show, mh-show, mh-show-msg, mh-show-unquote-From) (mh-msg-folder, mh-display-msg, mh-clean-msg-header): Move to new file mh-show.el. (mh-mail-header-separator, mh-signature-separator-regexp) (mh-signature-separator, mh-globals-hash, mh-user-path) (mh-draft-folder, mh-unseen-seq, mh-previous-seq, mh-inbox) (mh-previous-window-config, mh-current-folder mh-show-buffer) (mh-showing-mode, mh-show-mode-map, mh-show-folder-buffer) (mh-showing-mode, mh-seq-list, mh-seen-list, mh-summary-height) (mh-list-to-string, mh-list-to-string-1): Move to mh-e.el. (mh-buffer-data, mh-mm-inline-media-tests): Move to mh-mime.el. (mh-address-mail-regexp, mh-goto-address-find-address-at-point): Move to mh-alias.el. (mh-letter-font-lock-keywords): Move to new file mh-letter.el. (mh-folder-filename, mh-msg-count, mh-recenter, mh-msg-filename) (mh-show-mouse, mh-modify, mh-goto-msg, mh-set-folder-modified-p): Move to new file mh-folder.el. (with-mh-folder-updating, mh-in-show-buffer) (mh-do-at-event-location, mh-seq-msgs): Moved to mh-acros.el. (mh-make-seq, mh-seq-name, mh-notate, mh-find-seq) (mh-seq-to-msgs, mh-add-msgs-to-seq, mh-canonicalize-sequence): Moved to mh-seq.el. (mh-show-xface-function, mh-uncompface-executable, mh-face-to-png) (mh-uncompface, mh-icontopbm, mh-face-foreground-compat) (mh-face-background-compat, mh-face-display-function) (mh-show-xface, mh-picon-directory-list) (mh-picon-existing-directory-list) (mh-picon-cache, mh-picon-image-types) (mh-picon-set-directory-list, mh-picon-get-image) (mh-picon-file-contents, mh-picon-generate-path) (mh-x-image-cache-directory, mh-x-image-scaling-function) (mh-wget-executable, mh-wget-choice, mh-wget-option) (mh-x-image-temp-file, mh-x-image-url, mh-x-image-marker) (mh-x-image-url-cache-file, mh-x-image-scale-with-pnm) (mh-x-image-scale-with-convert) (url-unreserved-chars, url-hexify-string) (mh-x-image-url-cache-canonicalize) (mh-x-image-set-download-state, mh-x-image-get-download-state) (mh-x-image-url-fetch-image, mh-x-image-display) (mh-x-image-scale-and-display, mh-x-image-url-sane-p) (mh-x-image-url-display): Move to new file mh-xface.el. (mh-logo-display): Call mh-image-load-path. (mh-find-path-run, mh-find-path): Move here from deprecated file mh-init.el. (mh-help-messages): Now an alist of modes to an alist of messages. (mh-set-help): New function used to set mh-help-messages (mh-help): Adjust for new format of mh-help-messages. Add help-messages argument. (mh-prefix-help): Refactor to use mh-help. (mh-coalesce-msg-list, mh-greaterp, mh-lessp): Move here from mh-e.el. (mh-clear-sub-folders-cache): New function added to avoid exposing mh-sub-folders-cache variable. * mh-xface.el: New file. Contains X-Face and Face header field display routines from mh-utils.el.
author Bill Wohler <wohler@newt.com>
date Sun, 29 Jan 2006 19:34:57 +0000
parents 13abee3a9bc6
children 3bd95f4f2941 0ca0d9181b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14008
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64600
diff changeset
3 ;; Copyright (C) 1994, 1995, 2002, 2003, 2004,
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64600
diff changeset
4 ;; 2005 Free Software Foundation, Inc.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
43349
53fdd9b8a568 Remove commented provide statement.
Pavel Janík <Pavel@Janik.cz>
parents: 42855
diff changeset
6 ;; Author: David K}gedal <davidk@lysator.liu.se>
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Created: 16 Feb 1994
12333
5364f0b969f3 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 12321
diff changeset
8 ;; K}gedal's last version number: 1.2.4
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; Keywords: extensions, languages, tools
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; any later version.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14008
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63259
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63259
diff changeset
26 ;; Boston, MA 02110-1301, USA.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; This file provides a simple way to define powerful templates, or
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; macros, if you wish. It is mainly intended for, but not limited to,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; other programmers to be used for creating shortcuts for editing
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; certain kind of documents. It was originally written to be used by
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
34 ;; a HTML editing mode written by Nelson Minar <nelson@santafe.edu>,
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
35 ;; and his html-helper-mode.el is probably the best example of how to
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
36 ;; use this program.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; A template is defined as a list of items to be inserted in the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; current buffer at point. Some of the items can be simple strings,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; while other can control formatting or define special points of
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; interest in the inserted text.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; If a template defines a "point of interest" that point is inserted
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; in a buffer-local list of "points of interest" that the user can
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; jump between with the commands `tempo-backward-mark' and
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; `tempo-forward-mark'. If the template definer provides a prompt for
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; the point, and the variable `tempo-interactive' is non-nil, the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; user will be prompted for a string to be inserted in the buffer,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; using the minibuffer.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; The template can also define one point to be replaced with the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; current region if the template command is called with a prefix (or
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; a non-nil argument).
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; More flexible templates can be created by including lisp symbols,
31657
58e2bb13d72e (tempo-expand-if-complete): Quote paren in docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27684
diff changeset
56 ;; which will be evaluated as variables, or lists, which will be
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; evaluated as lisp expressions.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; See the documentation for tempo-define-template for the different
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; items that can be used to define a tempo template.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; One of the more powerful features of tempo templates are automatic
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; completion. With every template can be assigned a special tag that
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; should be recognized by `tempo-complete-tag' and expanded to the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; complete template. By default the tags are added to a global list
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; of template tags, and are matched against the last word before
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; point. But if you assign your tags to a specific list, you can also
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; specify another method for matching text in the buffer against the
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; tags. In the HTML mode, for instance, the tags are matched against
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; the text between the last `<' and point.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; When defining a template named `foo', a symbol named
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; `tempo-template-foo' will be created whose value as a variable will
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; be the template definition, and its function value will be an
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; interactive function that inserts the template at the point.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; The latest tempo.el distribution can be fetched from
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; ftp.lysator.liu.se in the directory /pub/emacs
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
80 ;; There is also a WWW page at
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
81 ;; http://www.lysator.liu.se/~davidk/elisp/ which has some information
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
82
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
83 ;;; Known bugs:
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
84
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
85 ;; 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
86 ;; 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
87 ;; 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
88 ;; be easily avoided.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
89
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
90 ;; 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
91 ;; be looked into.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
92
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
93 ;; 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
94
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
95 ;; 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
96 ;; 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
97 ;; emacs version and your problems.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
98
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
99 ;;; Contributors:
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
100
14008
f8a4126da2c8 (tempo-local-tags, tempo-user-elements, tempo-use-tag-list):
Karl Heuer <kwzh@gnu.org>
parents: 12333
diff changeset
101 ;; These people have given me important feedback and new ideas for
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
102 ;; tempo.el. Thanks.
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
103
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
104 ;; Nelson Minar <nelson@santafe.edu>
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 21088
diff changeset
105 ;; Richard Stallman <rms@gnu.org>
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
106 ;; Lars Lindberg <Lars.Lindberg@sypro.cap.se>
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
107 ;; Glen Whitney <Glen.Whitney@math.lsa.umich.edu>
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
108
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;;; Code:
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
111 ;;; User options
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
113 (defgroup tempo nil
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
114 "Flexible template insertion."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
115 :prefix "tempo-"
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
116 :group 'tools)
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
117
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
118 (defcustom tempo-interactive nil
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 "*Prompt user for strings in templates.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 If this variable is non-nil, `tempo-insert' prompts the
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
121 user for text to insert in the templates."
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
122 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
123 :group 'tempo)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
125 (defcustom tempo-insert-region nil
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
126 "*Automatically insert current region when there is a `r' in the template
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
127 If this variable is nil, `r' elements will be treated just like `p'
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
128 elements, unless the template function is given a prefix (or a non-nil
63259
fa1c7a31ac5d (tempo-insert-region): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 57980
diff changeset
129 argument). If this variable is non-nil, the behavior is reversed.
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
130
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
131 In Transient Mark mode, this option is unused."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
132 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
133 :group 'tempo)
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
134
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
135 (defcustom tempo-show-completion-buffer t
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
136 "*If non-nil, show a buffer with possible completions, when only
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
137 a partial completion can be found."
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
138 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
139 :group 'tempo)
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
140
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
141 (defcustom tempo-leave-completion-buffer nil
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
142 "*If nil, a completion buffer generated by \\[tempo-complete-tag]
21088
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
143 disappears at the next keypress; otherwise, it remains forever."
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
144 :type 'boolean
ac1673121774 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 14169
diff changeset
145 :group 'tempo)
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
146
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
147 ;;; Internal variables
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
148
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (defvar tempo-insert-string-functions nil
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 "List of functions to run when inserting a string.
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
151 Each function is called with a single arg, STRING and should return
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
152 another string. This could be used for making all strings upcase by
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
153 setting it to '(upcase), for example.")
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (defvar tempo-tags nil
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
156 "An association list with tags and corresponding templates.")
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (defvar tempo-local-tags '((tempo-tags . nil))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 "A list of locally installed tag completion lists.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 It is a association list where the car of every element is a symbol
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
161 whose variable value is a template list. The cdr part, if non-nil,
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
162 is a function or a regexp that defines the string to match. See the
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 documentation for the function `tempo-complete-tag' for more info.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 `tempo-tags' is always in the last position in this list.")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
167 (defvar tempo-collection nil
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
168 "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
169
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
170 (defvar tempo-dirty-collection t
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
171 "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
172
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (defvar tempo-marks nil
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 "A list of marks to jump to with `\\[tempo-forward-mark]' and `\\[tempo-backward-mark]'.")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175
57967
5c8dcdd5f8bc (tempo-match-finder): Use [:word:] instead of "^\\b",
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
176 (defvar tempo-match-finder "\\b\\([[:word:]]+\\)\\="
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
177 "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
178
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
179 If `tempo-match-finder' is a string, it should contain a regular
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
180 expression with at least one \\( \\) pair. When searching for tags,
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
181 `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
182 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
183 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
184 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
185
57980
7863c0adc838 (tempo-match-finder): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 57967
diff changeset
186 You will probably want to include \\=\\= at the end of the regexp to
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
187 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
188 point.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
189
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
190 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
191 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
192 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
193 should be replaced with a template.")
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
194
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
195 (defvar tempo-user-elements nil
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
196 "Element handlers for user-defined elements.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
197 A list of symbols which are bound to functions that take one argument.
14008
f8a4126da2c8 (tempo-local-tags, tempo-user-elements, tempo-use-tag-list):
Karl Heuer <kwzh@gnu.org>
parents: 12333
diff changeset
198 This function should return something to be sent to `tempo-insert' if
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
199 it recognizes the argument, and nil otherwise.")
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
201 (defvar tempo-named-insertions nil
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
202 "Temporary storage for named insertions.")
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
203
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
204 (defvar tempo-region-start (make-marker)
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
205 "Region start when inserting around the region.")
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
206
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
207 (defvar tempo-region-stop (make-marker)
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
208 "Region stop when inserting around the region.")
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
209
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;; Make some variables local to every buffer
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (make-variable-buffer-local 'tempo-marks)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (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
214 (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
215 (make-variable-buffer-local 'tempo-collection)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
216 (make-variable-buffer-local 'tempo-dirty-collection)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ;;; Functions
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 ;; tempo-define-template
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (defun tempo-define-template (name elements &optional tag documentation taglist)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 "Define a template.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 This function creates a template variable `tempo-template-NAME' and an
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 interactive function `tempo-template-NAME' that inserts the template
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 at the point. The created function is returned.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 NAME is a string that contains the name of the template, ELEMENTS is a
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 list of elements in the template, TAG is the tag used for completion,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 DOCUMENTATION is the documentation string for the insertion command
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 created, and TAGLIST (a symbol) is the tag list that TAG (if provided)
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
233 should be added to. If TAGLIST is nil and TAG is non-nil, TAG is
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
234 added to `tempo-tags'.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 The elements in ELEMENTS can be of several types:
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
238 - A string: It is sent to the hooks in `tempo-insert-string-functions',
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 and the result is inserted.
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
240 - The symbol `p': This position is saved in `tempo-marks'.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
241 - The symbol `r': If `tempo-insert' is called with ON-REGION non-nil
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
242 the current region is placed here. Otherwise it works like `p'.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
243 - (p PROMPT <NAME> <NOINSERT>): If `tempo-interactive' is non-nil, the
42855
d20e97a1bd5a (tempo-define-template): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 42205
diff changeset
244 user is prompted in the minibuffer with PROMPT for a string to be
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
245 inserted. If the optional parameter NAME is non-nil, the text is
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
246 saved for later insertion with the `s' tag. If there already is
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
247 something saved under NAME that value is used instead and no
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
248 prompting is made. If NOINSERT is provided and non-nil, nothing is
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
249 inserted, but text is still saved when a NAME is provided. For
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
250 clarity, the symbol `noinsert' should be used as argument.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
251 - (P PROMPT <NAME> <NOINSERT>): Works just like the previous tag, but
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
252 forces `tempo-interactive' to be true.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
253 - (r PROMPT <NAME> <NOINSERT>): Like the previous tag, but if
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
254 `tempo-interactive' is nil and `tempo-insert' is called with
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
255 ON-REGION non-nil, the current region is placed here. This usually
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
256 happens when you call the template function with a prefix argument.
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
257 - (s NAME): Inserts text previously read with the (p ..) construct.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
258 Finds the insertion saved under NAME and inserts it. Acts like `p'
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
259 if tempo-interactive is nil.
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
260 - `&': If there is only whitespace between the line start and point,
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
261 nothing happens. Otherwise a newline is inserted.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
262 - `%': If there is only whitespace between point and end of line,
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
263 nothing happens. Otherwise a newline is inserted.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
264 - `n': Inserts a newline.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
265 - `>': The line is indented using `indent-according-to-mode'. Note
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
266 that you often should place this item after the text you want on
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
267 the line.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
268 - `r>': Like `r', but it also indents the region.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
269 - `n>': Inserts a newline and indents line.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
270 - `o': Like `%' but leaves the point before the newline.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
271 - nil: It is ignored.
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
272 - Anything else: It is evaluated and the result is treated as an
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
273 element to be inserted. One additional tag is useful for these
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
274 cases. If an expression returns a list '(l foo bar), the elements
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
275 after `l' will be inserted according to the usual rules. This makes
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
276 it possible to return several elements from one expression."
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (let* ((template-name (intern (concat "tempo-template-"
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 name)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (command-name template-name))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (set template-name elements)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (fset command-name (list 'lambda (list '&optional 'arg)
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43349
diff changeset
282 (or documentation
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (concat "Insert a " name "."))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (list 'interactive "*P")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (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
286 template-name)
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
287 (list 'if 'tempo-insert-region
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
288 (list 'not 'arg) 'arg))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (and tag
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (tempo-add-tag tag template-name taglist))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 command-name))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 ;;; tempo-insert-template
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (defun tempo-insert-template (template on-region)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 "Insert a template.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 TEMPLATE is the template to be inserted. If ON-REGION is non-nil the
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
299 `r' elements are replaced with the current region. In Transient Mark
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
300 mode, ON-REGION is ignored and assumed true if the region is active."
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
301 (unwind-protect
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
302 (progn
12333
5364f0b969f3 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 12321
diff changeset
303 (if (or (and (boundp 'transient-mark-mode) ; For Emacs
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
304 transient-mark-mode
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
305 mark-active)
64377
8b63c8dfb728 (tempo-insert-template): Suppress warning.
Richard M. Stallman <rms@gnu.org>
parents: 64091
diff changeset
306 (if (featurep 'xemacs)
64600
07e5e0169359 (tempo-insert-template): Fix 2005-07-16 change.
Juri Linkov <juri@jurta.org>
parents: 64561
diff changeset
307 (and zmacs-regions (mark))))
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
308 (setq on-region t))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
309 (and on-region
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
310 (set-marker tempo-region-start (min (mark) (point)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
311 (set-marker tempo-region-stop (max (mark) (point))))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
312 (if on-region
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
313 (goto-char tempo-region-start))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
314 (save-excursion
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
315 (tempo-insert-mark (point-marker))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
316 (mapcar (function (lambda (elt)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
317 (tempo-insert elt on-region)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
318 (symbol-value template))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
319 (tempo-insert-mark (point-marker)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
320 (tempo-forward-mark))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
321 (tempo-forget-insertions)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
322 ;; Should I check for zmacs here too???
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
323 (and (boundp 'transient-mark-mode)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
324 transient-mark-mode
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
325 (deactivate-mark))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ;;; tempo-insert
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
330 (defun tempo-insert (element on-region)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 "Insert a template element.
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
332 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
333 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
334
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
335 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
336 possible."
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (cond ((stringp element) (tempo-process-and-insert-string element))
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
338 ((and (consp element)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
339 (eq (car element) 'p)) (tempo-insert-prompt-compat
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
340 (cdr element)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
341 ((and (consp element)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
342 (eq (car element) 'P)) (let ((tempo-interactive t))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
343 (tempo-insert-prompt-compat
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
344 (cdr element))))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
345 ;;; ((and (consp element)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
346 ;;; (eq (car element) 'v)) (tempo-save-named
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
347 ;;; (nth 1 element)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
348 ;;; nil
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
349 ;;; (nth 2 element)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
350 ((and (consp element)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
351 (eq (car element) 'r)) (if on-region
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
352 (goto-char tempo-region-stop)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
353 (tempo-insert-prompt-compat
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
354 (cdr element))))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
355 ((and (consp element)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
356 (eq (car element) 's)) (tempo-insert-named (car (cdr element))))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
357 ((and (consp element)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
358 (eq (car element) 'l)) (mapcar (function
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
359 (lambda (elt)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
360 (tempo-insert elt on-region)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
361 (cdr element)))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 ((eq element 'p) (tempo-insert-mark (point-marker)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 ((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
364 (goto-char tempo-region-stop)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (tempo-insert-mark (point-marker))))
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
366 ((eq element 'r>) (if on-region
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
367 (progn
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
368 (goto-char tempo-region-stop)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
369 (indent-region (mark) (point) nil))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
370 (tempo-insert-mark (point-marker))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 ((eq element '>) (indent-according-to-mode))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 ((eq element '&) (if (not (or (= (current-column) 0)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (save-excursion
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (re-search-backward
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 "^\\s-*\\=" nil t))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (insert "\n")))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ((eq element '%) (if (not (or (eolp)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (save-excursion
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (re-search-forward
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 "\\=\\s-*$" nil t))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (insert "\n")))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 ((eq element 'n) (insert "\n"))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ((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
384 ;; 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
385 ;; 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
386 ;; beginning of a line.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
387 ((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
388 (eolp)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
389 (save-excursion
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
390 (re-search-forward
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
391 "\\=\\s-*$" nil t))))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
392 (open-line 1)))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 ((null element))
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
394 (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
395 (eval element))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
396 on-region))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 ;;; tempo-insert-prompt
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
401 (defun tempo-insert-prompt-compat (prompt)
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
402 "Compatibility hack for `tempo-insert-prompt'.
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
403 PROMPT can be either a prompt string, or a list of arguments to
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
404 `tempo-insert-prompt', or nil."
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
405 (if (consp prompt) ; not nil either
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
406 (apply 'tempo-insert-prompt prompt)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
407 (tempo-insert-prompt prompt)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
408
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
409 (defun tempo-insert-prompt (prompt &optional save-name no-insert)
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 "Prompt for a text string and insert it in the current buffer.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 If the variable `tempo-interactive' is non-nil the user is prompted
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 for a string in the minibuffer, which is then inserted in the current
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
413 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
414 `tempo-mark'.
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
415
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
416 PROMPT is the prompt string, SAVE-NAME is a name to save the inserted
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
417 text under. If the optional argument NO-INSERT is non-nil, no text is
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
418 inserted. This can be useful when there is a SAVE-NAME.
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
419
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
420 If there already is a value for SAVE-NAME, it is used and the user is
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
421 never prompted."
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
422 (let (insertion
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
423 (previous (and save-name
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
424 (tempo-lookup-named save-name))))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
425 (cond
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
426 ;; Insert previous value, unless no-insert is non-nil
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
427 ((and previous
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
428 (not no-insert))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
429 (tempo-insert-named save-name)) ; A double lookup here, but who
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
430 ; cares
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
431 ;; If no-insert is non-nil, don't insert the previous value. Just
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
432 ;; keep it
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
433 (previous
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
434 nil)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
435 ;; No previous value. Prompt or insert mark
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
436 (tempo-interactive
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
437 (if (not (stringp prompt))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
438 (error "tempo: The prompt (%s) is not a string" prompt))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
439 (setq insertion (read-string prompt))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
440 (or no-insert
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
441 (insert insertion))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
442 (if save-name
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
443 (tempo-save-named save-name insertion)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
444 (t
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
445 (tempo-insert-mark (point-marker))))))
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
446
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
447 ;;;
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
448 ;;; tempo-is-user-element
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
449
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
450 (defun tempo-is-user-element (element)
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
451 "Tries all the user-defined element handlers in `tempo-user-elements'."
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
452 ;; Sigh... I need (some list)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
453 (catch 'found
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
454 (mapcar (function (lambda (handler)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
455 (let ((result (funcall handler element)))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
456 (if result (throw 'found result)))))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
457 tempo-user-elements)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
458 (throw 'found nil)))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
459
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
460 ;;;
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
461 ;;; tempo-forget-insertions
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
462
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
463 (defun tempo-forget-insertions ()
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
464 "Forget all the saved named insertions."
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
465 (setq tempo-named-insertions nil))
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
466
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
467 ;;;
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
468 ;;; tempo-save-named
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
469
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
470 (defun tempo-save-named (name data) ; Had an optional prompt for 'v
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
471 "Save some data for later insertion
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
472 The contents of DATA is saved under the name NAME.
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
473
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
474 The data can later be retrieved with `tempo-lookup-named'.
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
475
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
476 This function returns nil, so it can be used in a template without
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
477 inserting anything."
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
478 (setq tempo-named-insertions
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
479 (cons (cons name data)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
480 tempo-named-insertions))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
481 nil)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
482
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
483 ;;;
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
484 ;;; tempo-lookup-named
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
485
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
486 (defun tempo-lookup-named (name)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
487 "Lookup some saved data under the name NAME.
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
488 Returns the data if NAME was found, and nil otherwise."
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
489 (cdr (assq name tempo-named-insertions)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
490
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
491 ;;;
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
492 ;;; tempo-insert-named
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
493
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
494 (defun tempo-insert-named (name)
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
495 "Insert the previous insertion saved under a named specified in NAME.
12321
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
496 If there is no such name saved, a tempo mark is inserted.
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
497
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
498 Note that if the data is a string, it will not be run through the string
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
499 processor."
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
500 (let* ((insertion (tempo-lookup-named name)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
501 (cond ((null insertion)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
502 (tempo-insert-mark (point-marker)))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
503 ((stringp insertion)
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
504 (insert insertion))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
505 (t
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
506 (tempo-insert insertion nil)))))
35899872cb3f Documented the `l' tag.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
507
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 ;;; tempo-process-and-insert-string
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (defun tempo-process-and-insert-string (string)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 "Insert a string from a template.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 Run a string through the preprocessors in `tempo-insert-string-functions'
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 and insert the results."
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (cond ((null tempo-insert-string-functions)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 nil)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 ((symbolp tempo-insert-string-functions)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (setq string
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
520 (funcall tempo-insert-string-functions string)))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 ((listp tempo-insert-string-functions)
27684
db5b16cdb88d (tempo-dolist, tempo-mapc): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
522 (dolist (fn tempo-insert-string-functions)
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
523 (setq string (funcall fn string))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (t
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (error "Bogus value in tempo-insert-string-functions: %s"
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 tempo-insert-string-functions)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (insert string))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 ;;; tempo-insert-mark
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (defun tempo-insert-mark (mark)
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
533 "Insert a mark `tempo-marks' while keeping it sorted."
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (cond ((null tempo-marks) (setq tempo-marks (list mark)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ((< mark (car tempo-marks)) (setq tempo-marks (cons mark tempo-marks)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (t (let ((lp tempo-marks))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (while (and (cdr lp)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (<= (car (cdr lp)) mark))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (setq lp (cdr lp)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (if (not (= mark (car lp)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (setcdr lp (cons mark (cdr lp))))))))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43349
diff changeset
542
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 ;;; tempo-forward-mark
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (defun tempo-forward-mark ()
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 "Jump to the next mark in `tempo-forward-mark-list'."
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (interactive)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (let ((next-mark (catch 'found
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (mapcar
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (function
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (lambda (mark)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (if (< (point) mark)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (throw 'found mark))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 tempo-marks)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 ;; return nil if not found
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 nil)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (if next-mark
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (goto-char next-mark))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 ;;; tempo-backward-mark
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (defun tempo-backward-mark ()
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 "Jump to the previous mark in `tempo-back-mark-list'."
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (interactive)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (let ((prev-mark (catch 'found
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (let (last)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (mapcar
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (function
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (lambda (mark)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (if (<= (point) mark)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (throw 'found last))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (setq last mark)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 tempo-marks)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 last))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (if prev-mark
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (goto-char prev-mark))))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43349
diff changeset
579
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 ;;; tempo-add-tag
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (defun tempo-add-tag (tag template &optional tag-list)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 "Add a template tag.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 Add the TAG, that should complete to TEMPLATE to the list in TAG-LIST,
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 or to `tempo-tags' if TAG-LIST is nil."
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (interactive "sTag: \nCTemplate: ")
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (if (null tag-list)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (setq tag-list 'tempo-tags))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (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
592 (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
593 (tempo-invalidate-collection))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 ;;; tempo-use-tag-list
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (defun tempo-use-tag-list (tag-list &optional completion-function)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 "Install TAG-LIST to be used for template completion in the current buffer.
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 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
601 `tempo-add-tag'.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602
14008
f8a4126da2c8 (tempo-local-tags, tempo-user-elements, tempo-use-tag-list):
Karl Heuer <kwzh@gnu.org>
parents: 12333
diff changeset
603 COMPLETION-FUNCTION is an obsolete option for specifying an optional
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
604 function or string that is used by `\\[tempo-complete-tag]' to find a
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
605 string to match the tag against. It has the same definition as the
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
606 variable `tempo-match-finder'. In this version, supplying a
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
607 COMPLETION-FUNCTION just sets `tempo-match-finder' locally."
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (let ((old (assq tag-list tempo-local-tags)))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (if old
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (setcdr old completion-function)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (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
612 tempo-local-tags))))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
613 (if completion-function
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
614 (setq tempo-match-finder completion-function))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
615 (tempo-invalidate-collection))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
616
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
617 ;;;
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
618 ;;; tempo-invalidate-collection
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
619
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
620 (defun tempo-invalidate-collection ()
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
621 "Marks the tag collection as obsolete.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
622 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
623 (setq tempo-dirty-collection t))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
624
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
625 ;;;
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
626 ;;; tempo-build-collection
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
627
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
628 (defun tempo-build-collection ()
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
629 "Build a collection of all the tags and return it.
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
630 If `tempo-dirty-collection' is nil, the old collection is reused."
11208
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
631 (prog1
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
632 (or (and (not tempo-dirty-collection)
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
633 tempo-collection)
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
634 (setq tempo-collection
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
635 (apply (function append)
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
636 (mapcar (function (lambda (tag-list)
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
637 ; If the format for
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
638 ; tempo-local-tags changes,
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
639 ; change this
11208
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
640 (eval (car tag-list))))
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
641 tempo-local-tags))))
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
642 (setq tempo-dirty-collection nil)))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 ;;; tempo-find-match-string
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (defun tempo-find-match-string (finder)
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 "Find a string to be matched against a tag list.
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
649 FINDER is a function or a string. Returns (STRING . POS), or nil
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
650 if no reasonable string is found."
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (cond ((stringp finder)
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
652 (let (successful)
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
653 (save-excursion
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
654 (or (setq successful (re-search-backward finder nil t))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
655 0))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
656 (if successful
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
657 (cons (buffer-substring (match-beginning 1)
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
658 (match-end 1)) ; This seems to be a
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
659 ; bug in emacs
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
660 (match-beginning 1))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
661 nil)))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (t
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (funcall finder))))
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 ;;;
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 ;;; tempo-complete-tag
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (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
669 "Look for a tag and expand it.
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
670 All the tags in the tag lists in `tempo-local-tags'
11208
18107abf5df3 (tempo-build-collection): Clear flag after computing
Karl Heuer <kwzh@gnu.org>
parents: 11202
diff changeset
671 \(this includes `tempo-tags') are searched for a match for the text
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
672 before the point. The way the string to match for is determined can
64561
dc9ffd263776 (tempo-insert-prompt, tempo-interactive, tempo-show-completion-buffer,
Juanma Barranquero <lekktu@gmail.com>
parents: 64377
diff changeset
673 be altered with the variable `tempo-match-finder'. If
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
674 `tempo-match-finder' returns nil, then the results are the same as
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
675 no match at all.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
677 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
678 place of the matching string.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
680 If a partial completion or no match at all is found, and SILENT is
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
681 non-nil, the function will give a signal.
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
683 If a partial completion is found and `tempo-show-completion-buffer' is
42205
7308bbc423d5 Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 31657
diff changeset
684 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
685
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
686 ;; 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
687 ;; work.
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
688 (interactive "*")
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
689 (let* ((collection (tempo-build-collection))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
690 (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
691 (match-string (car match-info))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
692 (match-start (cdr match-info))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
693 (exact (assoc match-string collection))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
694 (compl (or (car exact)
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
695 (and match-info (try-completion match-string collection)))))
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
696 (if compl (delete-region match-start (point)))
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
697 (cond ((null match-info) (or silent (ding)))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
698 ((null compl) (or silent (ding)))
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
699 ((eq compl t) (tempo-insert-template
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
700 (cdr (assoc match-string
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
701 collection))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
702 nil))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
703 (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
704 (tempo-insert-template (cdr exact) nil)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
705 (insert compl)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
706 (or silent (ding))
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
707 (if tempo-show-completion-buffer
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
708 (tempo-display-completions match-string
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
709 collection)))))))
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
712 ;;;
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
713 ;;; tempo-display-completions
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
714
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
715 (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
716 "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
717 (if tempo-leave-completion-buffer
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
718 (with-output-to-temp-buffer "*Completions*"
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
719 (display-completion-list
66114
13abee3a9bc6 * message.el (message-expand-group): Pass the common
Masatake YAMATO <jet@gyve.org>
parents: 64762
diff changeset
720 (all-completions string tag-list)
13abee3a9bc6 * message.el (message-expand-group): Pass the common
Masatake YAMATO <jet@gyve.org>
parents: 64762
diff changeset
721 string))
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
722 (save-window-excursion
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
723 (with-output-to-temp-buffer "*Completions*"
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
724 (display-completion-list
66114
13abee3a9bc6 * message.el (message-expand-group): Pass the common
Masatake YAMATO <jet@gyve.org>
parents: 64762
diff changeset
725 (all-completions string tag-list)
13abee3a9bc6 * message.el (message-expand-group): Pass the common
Masatake YAMATO <jet@gyve.org>
parents: 64762
diff changeset
726 string))
7410
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
727 (sit-for 32767))))
4eca60cb3c4d (tempo-insert-region, tempo-show-completion-buffer,
Richard M. Stallman <rms@gnu.org>
parents: 7296
diff changeset
728
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
729 ;;;
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
730 ;;; tempo-expand-if-complete
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
731
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
732 (defun tempo-expand-if-complete ()
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
733 "Expand the tag before point if it is complete.
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
734 Returns non-nil if an expansion was made and nil otherwise.
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
735
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
736 This could as an example be used in a command that is bound to the
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
737 space bar, and looks something like this:
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
738
31657
58e2bb13d72e (tempo-expand-if-complete): Quote paren in docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27684
diff changeset
739 \(defun tempo-space ()
11196
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
740 (interactive \"*\")
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
741 (or (tempo-expand-if-complete)
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
742 (insert \" \")))"
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
743
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
744 (interactive "*")
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
745 (let* ((collection (tempo-build-collection))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
746 (match-info (tempo-find-match-string tempo-match-finder))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
747 (match-string (car match-info))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
748 (match-start (cdr match-info))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
749 (exact (assoc match-string collection)))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
750 (if exact
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
751 (progn
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
752 (delete-region match-start (point))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
753 (tempo-insert-template (cdr exact) nil)
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
754 t)
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
755 nil)))
a74358cc05c6 (tempo-insert): Added the P tag and modified the s tag accordingly
Richard M. Stallman <rms@gnu.org>
parents: 10516
diff changeset
756
10516
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
757 (provide 'tempo)
488c5be866c3 (tempo-insert-template): Quoted transient-mark-mode
Richard M. Stallman <rms@gnu.org>
parents: 7410
diff changeset
758
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49597
diff changeset
759 ;;; arch-tag: b3c0ee36-db3b-47bc-875f-091b4e27a063
7267
4aa70d4d981c Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 ;;; tempo.el ends here