2021-03-11 14:32:42 -05:00
|
|
|
|
;;; mailabbrev.el --- abbrev-expansion of mail aliases -*- lexical-binding: t; -*-
|
1992-09-15 19:38:02 +00:00
|
|
|
|
|
2021-01-01 01:13:56 -08:00
|
|
|
|
;; Copyright (C) 1985-1987, 1992-1993, 1996-1997, 2000-2021 Free
|
2013-01-01 09:11:05 +00:00
|
|
|
|
;; Software Foundation, Inc.
|
1992-09-15 19:38:02 +00:00
|
|
|
|
|
2008-12-19 05:29:04 +00:00
|
|
|
|
;; Author: Jamie Zawinski <jwz@lucid.com; now jwz@jwz.org>
|
2019-05-25 13:43:06 -07:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;; Created: 19 Oct 90
|
|
|
|
|
;; Keywords: mail
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2018-05-20 10:47:32 -07:00
|
|
|
|
;; This file ensures that, when the point is in a To:, Cc:, Bcc:, or From:
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; field, word-abbrevs are defined for each of your mail aliases. These
|
|
|
|
|
;; aliases will be defined from your .mailrc file (or the file specified by
|
2003-09-30 12:44:53 +00:00
|
|
|
|
;; `mail-personal-alias-file') if it exists. Your mail aliases will
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; expand any time you type a word-delimiter at the end of an abbreviation.
|
|
|
|
|
;;
|
|
|
|
|
;; What you see is what you get: if mailabbrev is in use when you type
|
|
|
|
|
;; a name, and the name does not expand, you know it is not an abbreviation.
|
|
|
|
|
;; However, if you yank abbreviations into the headers
|
|
|
|
|
;; in a way that bypasses the check for abbreviations,
|
|
|
|
|
;; they are expanded (but not visibly) when you send the message.
|
|
|
|
|
;;
|
|
|
|
|
;; Your mail alias abbrevs will be in effect only when the point is in an
|
|
|
|
|
;; appropriate header field. When in the body of the message, or other
|
|
|
|
|
;; header fields, the mail aliases will not expand. Rather, the normal
|
2002-04-19 00:08:19 +00:00
|
|
|
|
;; mode-specific abbrev table will be used if
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; defined. So if you use mail-mode specific abbrevs, this code will not
|
|
|
|
|
;; adversely affect you. You can control which header fields the abbrevs
|
|
|
|
|
;; are used in by changing the variable mail-abbrev-mode-regexp.
|
|
|
|
|
;;
|
|
|
|
|
;; If auto-fill mode is on, abbrevs will wrap at commas instead of at word
|
|
|
|
|
;; boundaries; also, header continuation-lines will be properly indented.
|
|
|
|
|
;;
|
2000-05-03 19:25:07 +00:00
|
|
|
|
;; You can also insert a mail alias with mail-abbrev-insert-alias
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; (bound to C-c C-a), which prompts you for an alias (with completion)
|
|
|
|
|
;; and inserts its expansion at point.
|
|
|
|
|
;;
|
|
|
|
|
;; This file fixes a bug in the old system which prohibited your .mailrc
|
|
|
|
|
;; file from having lines like
|
|
|
|
|
;;
|
|
|
|
|
;; alias someone "John Doe <doe@quux.com>"
|
|
|
|
|
;;
|
|
|
|
|
;; That is, if you want an address to have embedded spaces, simply surround it
|
|
|
|
|
;; with double-quotes. This is necessary because the format of the .mailrc
|
|
|
|
|
;; file bogusly uses spaces as address delimiters. The following line defines
|
|
|
|
|
;; an alias which expands to three addresses:
|
|
|
|
|
;;
|
|
|
|
|
;; alias foobar addr-1 addr-2 "address three <addr-3>"
|
|
|
|
|
;;
|
|
|
|
|
;; (This is bogus because mail-delivery programs want commas, not spaces,
|
|
|
|
|
;; but that's what the file format is, so we have to live with it.)
|
|
|
|
|
;;
|
|
|
|
|
;; If you like, you can call the function define-mail-abbrev to define your
|
|
|
|
|
;; mail aliases instead of using a .mailrc file. When you call it in this
|
|
|
|
|
;; way, addresses are separated by commas.
|
|
|
|
|
;;
|
|
|
|
|
;; CAVEAT: This works on most Sun systems; I have been told that some versions
|
|
|
|
|
;; of /bin/mail do not understand double-quotes in the .mailrc file. So you
|
|
|
|
|
;; should make sure your version does before including verbose addresses like
|
|
|
|
|
;; this. One solution to this, if you are on a system whose /bin/mail doesn't
|
|
|
|
|
;; work that way, (and you still want to be able to /bin/mail to send mail in
|
|
|
|
|
;; addition to emacs) is to define minimal aliases (without full names) in
|
|
|
|
|
;; your .mailrc file, and use define-mail-abbrev to redefine them when sending
|
|
|
|
|
;; mail from emacs; this way, mail sent from /bin/mail will work, and mail
|
|
|
|
|
;; sent from emacs will be pretty.
|
|
|
|
|
;;
|
|
|
|
|
;; Aliases in the mailrc file may be nested. If you define aliases like
|
|
|
|
|
;; alias group1 fred ethel
|
|
|
|
|
;; alias group2 larry curly moe
|
|
|
|
|
;; alias everybody group1 group2
|
|
|
|
|
;; Then when you type "everybody" on the To: line, it will be expanded to
|
|
|
|
|
;; fred, ethyl, larry, curly, moe
|
|
|
|
|
;;
|
|
|
|
|
;; Aliases may also contain forward references; the alias of "everybody" can
|
|
|
|
|
;; precede the aliases of "group1" and "group2".
|
|
|
|
|
;;
|
|
|
|
|
;; This code also understands the "source" .mailrc command, for reading
|
|
|
|
|
;; aliases from some other file as well.
|
|
|
|
|
;;
|
|
|
|
|
;; Aliases may contain hyphens, as in "alias foo-bar foo@bar"; word-abbrevs
|
|
|
|
|
;; normally cannot contain hyphens, but this code works around that for the
|
|
|
|
|
;; specific case of mail-alias word-abbrevs.
|
|
|
|
|
;;
|
|
|
|
|
;; To read in the contents of another .mailrc-type file from emacs, use the
|
|
|
|
|
;; command Meta-X merge-mail-abbrevs. The rebuild-mail-abbrevs command is
|
|
|
|
|
;; similar, but will delete existing aliases first.
|
|
|
|
|
;;
|
|
|
|
|
;; If you would like your aliases to be expanded when you type M-> or ^N to
|
|
|
|
|
;; move out of the mail-header into the message body (instead of having to
|
|
|
|
|
;; type SPC at the end of the abbrev before moving away) then you can do
|
|
|
|
|
;;
|
|
|
|
|
;; (add-hook
|
2000-12-29 12:19:28 +00:00
|
|
|
|
;; 'mail-mode-hook
|
2000-08-16 21:05:37 +00:00
|
|
|
|
;; (lambda ()
|
2003-01-12 20:48:49 +00:00
|
|
|
|
;; (define-key mail-mode-map [remap next-line] 'mail-abbrev-next-line)
|
|
|
|
|
;; (define-key mail-mode-map [remap end-of-buffer] 'mail-abbrev-end-of-buffer)))
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
|
|
|
|
;; If you want multiple addresses separated by a string other than ", " then
|
|
|
|
|
;; you can set the variable mail-alias-separator-string to it. This has to
|
|
|
|
|
;; be a comma bracketed by whitespace if you want any kind of reasonable
|
2008-06-27 07:34:53 +00:00
|
|
|
|
;; behavior.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Thanks to Harald Hanche-Olsen, Michael Ernst, David Loeffler, and
|
|
|
|
|
;; Noah Friedman for suggestions and bug reports.
|
|
|
|
|
|
2000-12-29 12:19:28 +00:00
|
|
|
|
;; To use this package, do (add-hook 'mail-mode-hook 'mail-abbrevs-setup).
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1992-09-15 19:38:02 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2002-02-06 15:42:34 +00:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'sendmail))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(defgroup mail-abbrev nil
|
|
|
|
|
"Expand mail aliases as abbrevs, in certain mail headers."
|
|
|
|
|
:group 'abbrev-mode)
|
|
|
|
|
|
2007-10-31 20:30:28 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-minor-mode mail-abbrevs-mode
|
2011-10-19 20:26:14 -04:00
|
|
|
|
"Toggle abbrev expansion of mail aliases (Mail Abbrevs mode).
|
|
|
|
|
|
|
|
|
|
Mail Abbrevs mode is a global minor mode. When enabled,
|
|
|
|
|
abbrev-like expansion is performed when editing certain mail
|
|
|
|
|
headers (those specified by `mail-abbrev-mode-regexp'), based on
|
|
|
|
|
the entries in your `mail-personal-alias-file'."
|
2007-10-31 20:30:28 +00:00
|
|
|
|
:global t
|
|
|
|
|
:version "20.3"
|
|
|
|
|
(if mail-abbrevs-mode (mail-abbrevs-enable) (mail-abbrevs-disable)))
|
1997-10-21 02:54:50 +00:00
|
|
|
|
|
|
|
|
|
(defcustom mail-abbrevs-only nil
|
2007-10-31 20:30:28 +00:00
|
|
|
|
"Non-nil means only mail abbrevs should expand automatically.
|
1997-10-21 02:54:50 +00:00
|
|
|
|
Other abbrevs expand only when you explicitly use `expand-abbrev'."
|
2021-03-11 14:32:42 -05:00
|
|
|
|
:type 'boolean)
|
1997-10-21 02:54:50 +00:00
|
|
|
|
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; originally defined in sendmail.el - used to be an alist, now is a table.
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defvar mail-abbrevs nil
|
1992-03-24 04:22:48 +00:00
|
|
|
|
"Word-abbrev table of mail address aliases.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
If this is nil, it means the aliases have not yet been initialized and
|
|
|
|
|
should be read from the .mailrc file. (This is distinct from there being
|
|
|
|
|
no aliases, which is represented by this being a table with no entries.)")
|
|
|
|
|
|
1996-03-09 08:48:56 +00:00
|
|
|
|
(defvar mail-abbrev-modtime nil
|
|
|
|
|
"The modification time of your mail alias file when it was last examined.")
|
|
|
|
|
|
|
|
|
|
(defun mail-abbrevs-sync-aliases ()
|
2003-08-29 16:12:38 +00:00
|
|
|
|
(when mail-personal-alias-file
|
|
|
|
|
(if (file-exists-p mail-personal-alias-file)
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(let ((modtime (file-attribute-modification-time
|
|
|
|
|
(file-attributes mail-personal-alias-file))))
|
2003-08-29 16:12:38 +00:00
|
|
|
|
(if (not (equal mail-abbrev-modtime modtime))
|
|
|
|
|
(progn
|
|
|
|
|
(setq mail-abbrev-modtime modtime)
|
|
|
|
|
(build-mail-abbrevs)))))))
|
1996-03-09 08:48:56 +00:00
|
|
|
|
|
1991-12-21 09:14:03 +00:00
|
|
|
|
;;;###autoload
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun mail-abbrevs-setup ()
|
1996-03-05 22:04:03 +00:00
|
|
|
|
"Initialize use of the `mailabbrev' package."
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (and (not (vectorp mail-abbrevs))
|
1995-01-03 23:44:25 +00:00
|
|
|
|
(file-exists-p mail-personal-alias-file))
|
1996-03-09 08:48:56 +00:00
|
|
|
|
(progn
|
1996-05-26 23:12:01 +00:00
|
|
|
|
(setq mail-abbrev-modtime
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
(file-attribute-modification-time
|
|
|
|
|
(file-attributes mail-personal-alias-file)))
|
1996-03-09 08:48:56 +00:00
|
|
|
|
(build-mail-abbrevs)))
|
|
|
|
|
(mail-abbrevs-sync-aliases)
|
2013-04-17 20:12:33 -04:00
|
|
|
|
(add-function :around (local 'abbrev-expand-function)
|
|
|
|
|
#'mail-abbrev-expand-wrapper)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(abbrev-mode 1))
|
|
|
|
|
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(defun mail-abbrevs-enable ()
|
2021-03-11 14:32:42 -05:00
|
|
|
|
(add-hook 'mail-mode-hook #'mail-abbrevs-setup))
|
1997-10-21 02:54:50 +00:00
|
|
|
|
|
|
|
|
|
(defun mail-abbrevs-disable ()
|
|
|
|
|
"Turn off use of the `mailabbrev' package."
|
2021-03-11 14:32:42 -05:00
|
|
|
|
(remove-hook 'mail-mode-hook #'mail-abbrevs-setup)
|
1997-10-21 02:54:50 +00:00
|
|
|
|
(abbrev-mode (if (default-value 'abbrev-mode) 1 -1)))
|
|
|
|
|
|
1992-03-24 04:22:48 +00:00
|
|
|
|
;;;###autoload
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun build-mail-abbrevs (&optional file recursivep)
|
1995-01-03 23:44:25 +00:00
|
|
|
|
"Read mail aliases from personal mail alias file and set `mail-abbrevs'.
|
|
|
|
|
By default this is the file specified by `mail-personal-alias-file'."
|
|
|
|
|
(setq file (expand-file-name (or file mail-personal-alias-file)))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (vectorp mail-abbrevs)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
nil
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(setq mail-abbrevs nil)
|
|
|
|
|
(define-abbrev-table 'mail-abbrevs '()))
|
1992-04-05 23:25:04 +00:00
|
|
|
|
(message "Parsing %s..." file)
|
2007-10-31 20:30:28 +00:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(buffer-disable-undo)
|
|
|
|
|
(cond ((get-file-buffer file)
|
|
|
|
|
(insert (with-current-buffer (get-file-buffer file)
|
|
|
|
|
(buffer-substring (point-min) (point-max)))))
|
|
|
|
|
((not (file-exists-p file)))
|
|
|
|
|
(t (insert-file-contents file)))
|
|
|
|
|
;; Don't lose if no final newline.
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(or (eq (preceding-char) ?\n) (newline))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
;; Delete comments from the file
|
|
|
|
|
(while (search-forward "# " nil t)
|
|
|
|
|
(let ((p (- (point) 2)))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(delete-region p (point))))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
;; handle "\\\n" continuation lines
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(if (= (preceding-char) ?\\)
|
|
|
|
|
(progn (delete-char -1) (delete-char 1) (insert ?\ ))
|
|
|
|
|
(forward-char 1)))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (re-search-forward
|
|
|
|
|
"^\\(a\\(lias\\)?\\|g\\(roup\\)?\\|source\\)[ \t]+" nil t)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if (looking-at "source[ \t]+\\([^ \t\n]+\\)")
|
|
|
|
|
(progn
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(build-mail-abbrevs
|
|
|
|
|
(substitute-in-file-name
|
|
|
|
|
(buffer-substring (match-beginning 1) (match-end 1)))
|
|
|
|
|
t))
|
|
|
|
|
(re-search-forward "[ \t]+\\([^ \t\n]+\\)")
|
|
|
|
|
(let* ((name (buffer-substring
|
|
|
|
|
(match-beginning 1) (match-end 1)))
|
|
|
|
|
(start (progn (skip-chars-forward " \t") (point))))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
;; (message "** %s \"%s\"" name (buffer-substring start (point)))(sit-for 1)
|
|
|
|
|
(define-mail-abbrev
|
|
|
|
|
name
|
|
|
|
|
(buffer-substring start (point))
|
|
|
|
|
t))))
|
|
|
|
|
;; Resolve forward references in .mailrc file.
|
|
|
|
|
;; This would happen automatically before the first abbrev was
|
|
|
|
|
;; expanded, but why not do it now.
|
|
|
|
|
(or recursivep (mail-resolve-all-aliases))
|
|
|
|
|
mail-abbrevs)
|
|
|
|
|
(message "Parsing %s... done" file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
2012-05-04 13:14:14 +08:00
|
|
|
|
(defcustom mail-alias-separator-string ", "
|
|
|
|
|
"String inserted between addresses in multi-address mail aliases.
|
1996-05-26 23:12:01 +00:00
|
|
|
|
This has to contain a comma, so \", \" is a reasonable value. You might
|
2012-05-04 13:14:14 +08:00
|
|
|
|
also want something like \",\\n \" to get each address on its own line."
|
2021-03-11 14:32:42 -05:00
|
|
|
|
:type 'string)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1993-06-15 20:50:11 +00:00
|
|
|
|
;; define-mail-abbrev sets this flag, which causes mail-resolve-all-aliases
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; to be called before expanding abbrevs if it's necessary.
|
|
|
|
|
(defvar mail-abbrev-aliases-need-to-be-resolved t)
|
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
;; originally defined in mailalias.el ; build-mail-abbrevs calls this with
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; stuff parsed from the .mailrc file.
|
|
|
|
|
;;
|
1991-12-21 09:14:03 +00:00
|
|
|
|
;;;###autoload
|
1993-06-15 20:50:11 +00:00
|
|
|
|
(defun define-mail-abbrev (name definition &optional from-mailrc-file)
|
1995-03-18 07:14:50 +00:00
|
|
|
|
"Define NAME as a mail alias abbrev that translates to DEFINITION.
|
2008-11-25 22:58:01 +00:00
|
|
|
|
If DEFINITION contains multiple addresses, separate them with commas.
|
|
|
|
|
|
|
|
|
|
Optional argument FROM-MAILRC-FILE means that DEFINITION comes
|
|
|
|
|
from a mailrc file. In that case, addresses are separated with
|
|
|
|
|
spaces and addresses with embedded spaces are surrounded by
|
|
|
|
|
double-quotes."
|
1992-10-18 22:20:07 +00:00
|
|
|
|
;; When this is called from build-mail-abbrevs, the third argument is
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; true, and we do some evil space->comma hacking like /bin/mail does.
|
|
|
|
|
(interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
|
|
|
|
|
;; Read the defaults first, if we have not done so.
|
2007-10-31 20:30:28 +00:00
|
|
|
|
(unless (vectorp mail-abbrevs) (build-mail-abbrevs))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
;; strip garbage from front and end
|
|
|
|
|
(if (string-match "\\`[ \t\n,]+" definition)
|
|
|
|
|
(setq definition (substring definition (match-end 0))))
|
|
|
|
|
(if (string-match "[ \t\n,]+\\'" definition)
|
|
|
|
|
(setq definition (substring definition 0 (match-beginning 0))))
|
2008-11-25 22:58:01 +00:00
|
|
|
|
(let* ((L (length definition))
|
1994-07-12 02:16:57 +00:00
|
|
|
|
(start (if (> L 0) 0))
|
2008-11-25 22:58:01 +00:00
|
|
|
|
end this-entry result)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(while start
|
2008-11-25 22:58:01 +00:00
|
|
|
|
(cond
|
|
|
|
|
(from-mailrc-file
|
|
|
|
|
;; If we're reading from the mailrc file, addresses are
|
|
|
|
|
;; delimited by spaces, and addresses with embedded spaces are
|
|
|
|
|
;; surrounded by non-escaped double-quotes.
|
|
|
|
|
(if (eq ?\" (aref definition start))
|
|
|
|
|
(setq start (1+ start)
|
|
|
|
|
end (and (string-match
|
|
|
|
|
"[^\\]\\(\\([\\][\\]\\)*\\)\"[ \t,]*"
|
|
|
|
|
definition start)
|
|
|
|
|
(match-end 1)))
|
|
|
|
|
(setq end (string-match "[ \t,]+" definition start)))
|
|
|
|
|
;; Extract the address and advance the loop past it.
|
|
|
|
|
(setq this-entry (substring definition start end)
|
|
|
|
|
start (and end (/= (match-end 0) L) (match-end 0)))
|
|
|
|
|
;; If the full name contains a problem character, quote it.
|
|
|
|
|
(and (string-match "\\(.+?\\)[ \t]*\\(<.*>\\)" this-entry)
|
|
|
|
|
(string-match "[^- !#$%&'*+/0-9=?A-Za-z^_`{|}~]"
|
|
|
|
|
(match-string 1 this-entry))
|
|
|
|
|
(setq this-entry (replace-regexp-in-string
|
|
|
|
|
"\\(.+?\\)[ \t]*\\(<.*>\\)"
|
|
|
|
|
"\"\\1\" \\2"
|
|
|
|
|
this-entry)))
|
|
|
|
|
(push this-entry result))
|
|
|
|
|
;; When we are not reading from .mailrc, addresses are
|
|
|
|
|
;; separated by commas. Try to accept a rfc822-like syntax.
|
|
|
|
|
;; (Todo: extend rfc822.el to do the work for us.)
|
|
|
|
|
((equal (string-match
|
|
|
|
|
"[ \t,]*\\(\"\\(?:[^\"]\\|[^\\]\\(?:[\\][\\]\\)*\"\\)*\"[ \t]*\
|
|
|
|
|
<[-.!#$%&'*+/0-9=?A-Za-z^_`{|}~@]+>\\)[ \t,]*"
|
|
|
|
|
definition start)
|
|
|
|
|
start)
|
|
|
|
|
;; If an entry has a valid [ "foo bar" <foo@example.com> ]
|
|
|
|
|
;; form, use it literally . This also allows commas in the
|
|
|
|
|
;; quoted string, e.g. [ "foo bar, jr" <foo@example.com> ]
|
|
|
|
|
(push (match-string 1 definition) result)
|
|
|
|
|
(setq start (and (/= (match-end 0) L) (match-end 0))))
|
|
|
|
|
(t
|
|
|
|
|
;; Otherwise, read the next address by looking for a comma.
|
|
|
|
|
(setq end (string-match "[ \t\n,]*,[ \t\n]*" definition start))
|
|
|
|
|
(setq this-entry (substring definition start end))
|
2005-01-04 14:59:47 +00:00
|
|
|
|
;; Advance the loop past this address.
|
2008-11-25 22:58:01 +00:00
|
|
|
|
(setq start (and end (/= (match-end 0) L) (match-end 0)))
|
2005-01-04 14:59:47 +00:00
|
|
|
|
;; If the full name contains a problem character, quote it.
|
2008-11-25 22:58:01 +00:00
|
|
|
|
(and (string-match "\\(.+?\\)[ \t]*\\(<.*>\\)" this-entry)
|
|
|
|
|
(string-match "[^- !#$%&'*+/0-9=?A-Za-z^_`{|}~]"
|
|
|
|
|
(match-string 1 this-entry))
|
|
|
|
|
(setq this-entry (replace-regexp-in-string
|
|
|
|
|
"\\(.+?\\)[ \t]*\\(<.*>\\)" "\"\\1\" \\2"
|
|
|
|
|
this-entry)))
|
|
|
|
|
(push this-entry result))))
|
|
|
|
|
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(setq definition (mapconcat (function identity)
|
|
|
|
|
(nreverse result)
|
1992-05-03 21:16:09 +00:00
|
|
|
|
mail-alias-separator-string)))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(setq mail-abbrev-aliases-need-to-be-resolved t)
|
|
|
|
|
(setq name (downcase name))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
;; use an abbrev table instead of an alist for mail-abbrevs.
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(let ((abbrevs-changed abbrevs-changed)) ; protect this from being changed.
|
2002-02-13 15:59:53 +00:00
|
|
|
|
(define-abbrev mail-abbrevs name definition 'mail-abbrev-expand-hook 0 t)))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun mail-resolve-all-aliases ()
|
|
|
|
|
"Resolve all forward references in the mail aliases table."
|
|
|
|
|
(if mail-abbrev-aliases-need-to-be-resolved
|
|
|
|
|
(progn
|
|
|
|
|
;; (message "Resolving mail aliases...")
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (vectorp mail-abbrevs)
|
|
|
|
|
(mapatoms (function mail-resolve-all-aliases-1) mail-abbrevs))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(setq mail-abbrev-aliases-need-to-be-resolved nil)
|
|
|
|
|
;; (message "Resolving mail aliases... done.")
|
|
|
|
|
)))
|
|
|
|
|
|
1992-06-15 21:06:57 +00:00
|
|
|
|
(defun mail-resolve-all-aliases-1 (sym &optional so-far)
|
|
|
|
|
(if (memq sym so-far)
|
|
|
|
|
(error "mail alias loop detected: %s"
|
2021-03-11 14:32:42 -05:00
|
|
|
|
(mapconcat #'symbol-name (cons sym so-far) " <- ")))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(let ((definition (and (boundp sym) (symbol-value sym))))
|
|
|
|
|
(if definition
|
|
|
|
|
(let ((result '())
|
|
|
|
|
(start 0))
|
|
|
|
|
(while start
|
|
|
|
|
(let ((end (string-match "[ \t\n]*,[, \t\n]*" definition start)))
|
|
|
|
|
(setq result (cons (substring definition start end) result)
|
|
|
|
|
start (and end (match-end 0)))))
|
|
|
|
|
(setq definition
|
2020-11-12 22:06:47 +01:00
|
|
|
|
(mapconcat (lambda (x)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(or (mail-resolve-all-aliases-1
|
2020-11-12 22:06:47 +01:00
|
|
|
|
(intern-soft (downcase x) mail-abbrevs)
|
|
|
|
|
(cons sym so-far))
|
|
|
|
|
x))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(nreverse result)
|
1992-05-03 21:16:09 +00:00
|
|
|
|
mail-alias-separator-string))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(set sym definition))))
|
|
|
|
|
(symbol-value sym))
|
|
|
|
|
|
|
|
|
|
|
1992-05-03 21:16:09 +00:00
|
|
|
|
(defun mail-abbrev-expand-hook ()
|
1995-03-18 07:14:50 +00:00
|
|
|
|
"For use as the fourth arg to `define-abbrev'.
|
|
|
|
|
After expanding a mail-abbrev, if Auto Fill mode is on and we're past the
|
2012-09-16 23:16:15 +00:00
|
|
|
|
fill-column, break the line at the previous comma, and indent the next line
|
|
|
|
|
with a space."
|
|
|
|
|
(when auto-fill-function
|
|
|
|
|
(let (p)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (>= (current-column) fill-column)
|
|
|
|
|
(while (and (search-backward "," (point-at-bol) 'move)
|
|
|
|
|
(>= (current-column) (1- fill-column))
|
|
|
|
|
(setq p (point))))
|
|
|
|
|
(when (or (not (bolp))
|
|
|
|
|
(and p (goto-char p)))
|
|
|
|
|
(setq p nil)
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(insert "\n")
|
|
|
|
|
(when (looking-at "[\t ]+")
|
|
|
|
|
(delete-region (point) (match-end 0)))
|
|
|
|
|
(insert " ")
|
|
|
|
|
(end-of-line)))))))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
|
|
|
|
;;; Syntax tables and abbrev-expansion
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
2012-05-04 13:14:14 +08:00
|
|
|
|
(defcustom mail-abbrev-mode-regexp
|
2018-05-20 10:47:32 -07:00
|
|
|
|
"^\\(Resent-\\)?\\(To\\|From\\|Cc\\|Bcc\\|Reply-To\\):"
|
2012-05-04 13:14:14 +08:00
|
|
|
|
"Regexp matching mail headers in which mail abbrevs should be expanded.
|
1995-02-17 18:31:47 +00:00
|
|
|
|
This string will be handed to `looking-at' with point at the beginning
|
1991-12-17 03:37:43 +00:00
|
|
|
|
of the current line; if it matches, abbrev mode will be turned on, otherwise
|
|
|
|
|
it will be turned off. (You don't need to worry about continuation lines.)
|
|
|
|
|
This should be set to match those mail fields in which you want abbreviations
|
2012-05-04 13:14:14 +08:00
|
|
|
|
turned on."
|
2021-03-11 14:32:42 -05:00
|
|
|
|
:type 'regexp)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
2002-02-06 15:42:34 +00:00
|
|
|
|
(defvar mail-abbrev-syntax-table nil
|
1995-10-20 20:57:42 +00:00
|
|
|
|
"The syntax-table used for abbrev-expansion purposes.
|
|
|
|
|
This is not actually made the current syntax table of the buffer, but
|
|
|
|
|
simply controls the set of characters which may be a part of the name
|
2002-02-06 15:42:34 +00:00
|
|
|
|
of a mail alias. The value is set up, buffer-local, when first needed.")
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(defun mail-abbrev-make-syntax-table ()
|
|
|
|
|
(make-local-variable 'mail-abbrev-syntax-table)
|
|
|
|
|
(unless mail-abbrev-syntax-table
|
2002-04-04 20:50:15 +00:00
|
|
|
|
(let ((tab (copy-syntax-table (syntax-table)))
|
2021-03-11 14:32:42 -05:00
|
|
|
|
(syntax-_ (aref (standard-syntax-table) ?_))
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(w (aref (standard-syntax-table) ?w)))
|
|
|
|
|
(map-char-table
|
2020-11-12 22:06:47 +01:00
|
|
|
|
(lambda (key value)
|
|
|
|
|
(if (null value)
|
|
|
|
|
;; Fetch the inherited value
|
|
|
|
|
(setq value (aref tab key)))
|
2021-03-11 14:32:42 -05:00
|
|
|
|
(if (equal value syntax-_)
|
2020-11-12 22:06:47 +01:00
|
|
|
|
(set-char-table-range tab key w)))
|
2002-03-23 16:10:14 +00:00
|
|
|
|
tab)
|
|
|
|
|
(modify-syntax-entry ?@ "w" tab)
|
2002-09-21 20:11:08 +00:00
|
|
|
|
(modify-syntax-entry ?% "w" tab)
|
|
|
|
|
(modify-syntax-entry ?! "w" tab)
|
|
|
|
|
(modify-syntax-entry ?. "w" tab)
|
|
|
|
|
(modify-syntax-entry ?_ "w" tab)
|
|
|
|
|
(modify-syntax-entry ?- "w" tab)
|
2002-03-23 16:10:14 +00:00
|
|
|
|
(setq mail-abbrev-syntax-table tab))))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
|
|
|
|
(defun mail-abbrev-in-expansion-header-p ()
|
|
|
|
|
"Whether point is in a mail-address header field."
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(and ;;
|
|
|
|
|
;; we are on an appropriate header line...
|
|
|
|
|
(save-excursion
|
2001-10-05 09:34:27 +00:00
|
|
|
|
(unless (eobp) (forward-char 1))
|
|
|
|
|
(re-search-backward "^[^ \t]" nil 'move)
|
1992-03-24 04:22:48 +00:00
|
|
|
|
;; are we at the front of an appropriate header line?
|
|
|
|
|
(looking-at mail-abbrev-mode-regexp))
|
|
|
|
|
;;
|
1998-04-30 06:26:19 +00:00
|
|
|
|
;; ...and are we in the headers?
|
2002-02-13 15:59:53 +00:00
|
|
|
|
(< (point)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(rfc822-goto-eoh)
|
|
|
|
|
(point)))))))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
2007-10-31 20:30:28 +00:00
|
|
|
|
(defun mail-abbrev-expand-wrapper (expand)
|
|
|
|
|
(if (and mail-abbrevs (not (eq mail-abbrevs t)))
|
2012-12-06 03:30:23 +00:00
|
|
|
|
(if (or (mail-abbrev-in-expansion-header-p)
|
|
|
|
|
;; Necessary for `message-read-from-minibuffer' to work.
|
|
|
|
|
(window-minibuffer-p))
|
2007-10-31 20:30:28 +00:00
|
|
|
|
|
2018-05-20 10:47:32 -07:00
|
|
|
|
;; We are in a To: (or Cc:, or whatever) header or a minibuffer,
|
2012-12-06 03:30:23 +00:00
|
|
|
|
;; and should use word-abbrevs to expand mail aliases.
|
2007-10-31 20:30:28 +00:00
|
|
|
|
(let ((local-abbrev-table mail-abbrevs))
|
|
|
|
|
|
|
|
|
|
;; Before anything else, resolve aliases if they need it.
|
|
|
|
|
(and mail-abbrev-aliases-need-to-be-resolved
|
|
|
|
|
(mail-resolve-all-aliases))
|
|
|
|
|
|
|
|
|
|
;; Now proceed with the abbrev section.
|
|
|
|
|
;; - We already installed mail-abbrevs as the abbrev table.
|
|
|
|
|
;; - Then install the mail-abbrev-syntax-table, which
|
|
|
|
|
;; temporarily marks all of the
|
|
|
|
|
;; non-alphanumeric-atom-characters (the "_"
|
|
|
|
|
;; syntax ones) as being normal word-syntax. We do this
|
|
|
|
|
;; because the C code for expand-abbrev only works on words,
|
|
|
|
|
;; and we want these characters to be considered words for
|
|
|
|
|
;; the purpose of abbrev expansion.
|
|
|
|
|
;; - Then we call the expand function, to do
|
|
|
|
|
;; the abbrev expansion with the above syntax table.
|
|
|
|
|
|
|
|
|
|
(mail-abbrev-make-syntax-table)
|
|
|
|
|
|
|
|
|
|
;; If the character just typed was non-alpha-symbol-syntax,
|
|
|
|
|
;; then don't expand the abbrev now (that is, don't expand
|
|
|
|
|
;; when the user types -.) Check the character's syntax in
|
|
|
|
|
;; the usual syntax table.
|
|
|
|
|
|
2009-01-09 04:36:00 +00:00
|
|
|
|
(or (and (integerp last-command-event)
|
2007-10-31 20:30:28 +00:00
|
|
|
|
;; Some commands such as M-> may want to expand first.
|
|
|
|
|
(equal this-command 'self-insert-command)
|
2009-01-09 04:36:00 +00:00
|
|
|
|
(or (eq (char-syntax last-command-event) ?_)
|
2007-10-31 20:30:28 +00:00
|
|
|
|
;; Don't expand on @.
|
2009-01-09 04:36:00 +00:00
|
|
|
|
(memq last-command-event '(?@ ?. ?% ?! ?_ ?-))))
|
2007-10-31 20:30:28 +00:00
|
|
|
|
;; Use this table so that abbrevs can have hyphens in them.
|
|
|
|
|
(with-syntax-table mail-abbrev-syntax-table
|
|
|
|
|
(funcall expand))))
|
|
|
|
|
|
|
|
|
|
(if (or (not mail-abbrevs-only)
|
|
|
|
|
(eq this-command 'expand-abbrev))
|
|
|
|
|
;; We're not in a mail header where mail aliases should
|
|
|
|
|
;; be expanded, then use the normal mail-mode abbrev table
|
|
|
|
|
;; (if any) and the normal mail-mode syntax table.
|
|
|
|
|
(funcall expand)
|
|
|
|
|
;; This is not a mail abbrev, and we should not expand it.
|
|
|
|
|
;; Don't expand anything.
|
|
|
|
|
nil))
|
|
|
|
|
;; No mail-abbrevs at all, do the normal thing.
|
|
|
|
|
(funcall expand)))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
|
|
|
|
;;; utilities
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun merge-mail-abbrevs (file)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
"Merge mail aliases from the given file with existing ones."
|
|
|
|
|
(interactive (list
|
|
|
|
|
(let ((insert-default-directory t)
|
|
|
|
|
(default-directory (expand-file-name "~/"))
|
1995-01-03 23:44:25 +00:00
|
|
|
|
(def mail-personal-alias-file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(read-file-name
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 16:56:44 +02:00
|
|
|
|
(format-prompt "Read additional aliases from file" def)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
default-directory
|
|
|
|
|
(expand-file-name def default-directory)
|
|
|
|
|
t))))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(build-mail-abbrevs file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1995-08-25 21:34:09 +00:00
|
|
|
|
(defun rebuild-mail-abbrevs (&optional file)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
"Rebuild all the mail aliases from the given file."
|
|
|
|
|
(interactive (list
|
|
|
|
|
(let ((insert-default-directory t)
|
|
|
|
|
(default-directory (expand-file-name "~/"))
|
1995-01-03 23:44:25 +00:00
|
|
|
|
(def mail-personal-alias-file))
|
1991-12-17 03:37:43 +00:00
|
|
|
|
(read-file-name
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 16:56:44 +02:00
|
|
|
|
(format-prompt "Read mail aliases from file" def)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
default-directory
|
|
|
|
|
(expand-file-name def default-directory)
|
|
|
|
|
t))))
|
1995-08-25 21:34:09 +00:00
|
|
|
|
(if (null file)
|
|
|
|
|
(setq file buffer-file-name))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(setq mail-abbrevs nil)
|
|
|
|
|
(build-mail-abbrevs file))
|
1992-03-16 20:39:07 +00:00
|
|
|
|
|
2000-05-03 19:25:07 +00:00
|
|
|
|
(defun mail-abbrev-insert-alias (&optional alias)
|
1992-03-24 04:22:48 +00:00
|
|
|
|
"Prompt for and insert a mail alias."
|
1992-08-02 03:36:38 +00:00
|
|
|
|
(interactive (progn
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
|
|
|
|
|
(list (completing-read "Expand alias: " mail-abbrevs nil t))))
|
|
|
|
|
(if (not (vectorp mail-abbrevs)) (mail-abbrevs-setup))
|
1995-09-04 20:26:58 +00:00
|
|
|
|
(insert (or (and alias (symbol-value (intern-soft alias mail-abbrevs))) ""))
|
|
|
|
|
(mail-abbrev-expand-hook))
|
1992-10-18 22:20:07 +00:00
|
|
|
|
|
2000-05-03 19:25:07 +00:00
|
|
|
|
(defun mail-abbrev-complete-alias ()
|
|
|
|
|
"Perform completion on alias preceding point."
|
|
|
|
|
(interactive)
|
2002-04-03 15:33:17 +00:00
|
|
|
|
(mail-abbrev-make-syntax-table)
|
2009-11-25 06:02:01 +00:00
|
|
|
|
(let ((end (point))
|
|
|
|
|
(beg (with-syntax-table mail-abbrev-syntax-table
|
|
|
|
|
(save-excursion
|
Fix problems caused by new implementation of sub-word mode
* lisp/subr.el (forward-word-strictly, backward-word-strictly):
New functions.
(word-move-empty-char-table): New variable.
* etc/NEWS: Mention 'forward-word-strictly' and
'backward-word-strictly'.
* doc/lispref/positions.texi (Word Motion): Document
'find-word-boundary-function-table', 'forward-word-strictly', and
'backward-word-strictly'. (Bug#22560)
* src/syntax.c (syms_of_syntax)
<find-word-boundary-function-table>: Doc fix.
* lisp/wdired.el (wdired-xcase-word):
* lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name)
(texinfo-copy-section-title, texinfo-start-menu-description)
(texinfo-copy-menu-title, texinfo-specific-section-type)
(texinfo-insert-node-lines, texinfo-copy-next-section-title):
* lisp/textmodes/texinfo.el (texinfo-clone-environment)
(texinfo-insert-@end):
* lisp/textmodes/texinfmt.el (texinfo-format-scan)
(texinfo-anchor, texinfo-multitable-widths)
(texinfo-multitable-item):
* lisp/textmodes/tex-mode.el (latex-env-before-change):
* lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify):
* lisp/skeleton.el (skeleton-insert):
* lisp/simple.el (count-words):
* lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit)
(vhdl-beginning-of-defun, vhdl-beginning-of-statement-1)
(vhdl-update-sensitivity-list, vhdl-template-block)
(vhdl-template-break, vhdl-template-case, vhdl-template-default)
(vhdl-template-default-indent, vhdl-template-for-loop)
(vhdl-template-if-then-use, vhdl-template-bare-loop)
(vhdl-template-nature, vhdl-template-procedural)
(vhdl-template-process, vhdl-template-selected-signal-asst)
(vhdl-template-type, vhdl-template-variable)
(vhdl-template-while-loop, vhdl-beginning-of-block)
(vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func):
* lisp/progmodes/verilog-mode.el (verilog-backward-sexp)
(verilog-forward-sexp, verilog-beg-of-statement)
(verilog-set-auto-endcomments, verilog-backward-token)
(verilog-do-indent):
* lisp/progmodes/vera-mode.el (vera-guess-basic-syntax)
(vera-indent-block-closing):
* lisp/progmodes/simula.el (simula-context)
(simula-backward-up-level, simula-forward-down-level)
(simula-previous-statement, simula-next-statement)
(simula-skip-comment-backward, simula-calculate-indent)
(simula-find-if, simula-electric-keyword):
* lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p):
* lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p)
(ruby-smie--forward-token, ruby-smie--backward-token)
(ruby-singleton-class-p, ruby-calculate-indent)
(ruby-forward-sexp, ruby-backward-sexp):
* lisp/progmodes/ps-mode.el (ps-run-goto-error):
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function)
(perl-syntax-propertize-special-constructs)
(perl-backward-to-start-of-continued-exp):
* lisp/progmodes/pascal.el (pascal-indent-declaration):
* lisp/progmodes/octave.el (octave-function-file-p):
* lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax):
* lisp/progmodes/js.el (js--forward-function-decl):
* lisp/progmodes/idlwave.el (idlwave-show-begin-check)
(idlwave-beginning-of-block, idlwave-end-of-block)
(idlwave-block-jump-out, idlwave-determine-class):
* lisp/progmodes/icon.el (icon-is-continuation-line)
(icon-backward-to-start-of-continued-exp, end-of-icon-defun):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/f90.el (f90-change-keywords):
* lisp/progmodes/cperl-mode.el (cperl-electric-pod)
(cperl-linefeed, cperl-electric-terminator)
(cperl-find-pods-heres, cperl-fix-line-spacing)
(cperl-invert-if-unless):
* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur):
* lisp/progmodes/cc-align.el (c-lineup-java-inher):
* lisp/progmodes/ada-mode.el (ada-compile-goto-error)
(ada-adjust-case-skeleton, ada-create-case-exception)
(ada-create-case-exception-substring)
(ada-case-read-exceptions-from-file, ada-after-keyword-p)
(ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end)
(ada-get-indent-if, ada-get-indent-block-start)
(ada-get-indent-loop, ada-get-indent-type)
(ada-search-prev-end-stmt, ada-check-defun-name)
(ada-goto-decl-start, ada-goto-matching-start)
(ada-goto-matching-end, ada-looking-at-semi-or)
(ada-looking-at-semi-private, ada-in-paramlist-p)
(ada-search-ignore-complex-boolean, ada-move-to-start)
(ada-move-to-end, ada-which-function, ada-gen-treat-proc):
* lisp/net/quickurl.el (quickurl-grab-url):
* lisp/mail/sendmail.el (mail-do-fcc):
* lisp/mail/rmail.el (rmail-resend):
* lisp/mail/mailabbrev.el (mail-abbrev-complete-alias):
* lisp/mail/mail-extr.el (mail-extract-address-components):
* lisp/json.el (json-read-keyword):
* lisp/files.el (insert-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/completion.el (symbol-under-point, symbol-before-point)
(symbol-before-point-for-complete, next-cdabbrev)
(add-completions-from-c-buffer):
* lisp/cedet/semantic/texi.el (semantic-up-context)
(semantic-beginning-of-context):
* lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables):
use 'forward-word-strictly' and 'backward-word-strictly' instead
of 'forward-word' and 'backward-word'.
2016-02-05 23:54:21 +02:00
|
|
|
|
(backward-word-strictly 1)
|
2009-11-25 06:02:01 +00:00
|
|
|
|
(point)))))
|
|
|
|
|
(completion-in-region beg end mail-abbrevs)))
|
2000-05-03 19:25:07 +00:00
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun mail-abbrev-next-line (&optional arg)
|
2009-03-12 06:23:35 +00:00
|
|
|
|
"Expand a mail abbrev before point, then move vertically down ARG lines.
|
|
|
|
|
This only expands an abbrev (if one is present) if called with
|
|
|
|
|
point at the end of a line, or on whitespace before the end of a line.
|
|
|
|
|
|
|
|
|
|
In terms of line motion, this behaves like `next-line', which see."
|
1992-03-24 04:22:48 +00:00
|
|
|
|
(interactive "p")
|
1992-06-15 21:06:57 +00:00
|
|
|
|
(if (looking-at "[ \t]*\n") (expand-abbrev))
|
|
|
|
|
(setq this-command 'next-line)
|
* progmodes/mixal-mode.el (mixal-run, mixal-debug): Call mixvm
only if it is bound.
* textmodes/reftex.el: Move autoloads for before all uses.
(reftex-make-overlay, reftex-overlay-put, reftex-move-overlay)
(reftex-delete-overlay): Move to the top level with the condition
in the body.
* progmodes/simula.el: Use when instead of if.
* iimage.el (iimage-locate-file): Define unconditionally.
* mail/mailabbrev.el (mail-abbrev-next-line):
* emulation/vip.el (vip-enlarge-region, vip-line)
(vip-next-line-at-bol, vip-previous-line)
(vip-previous-line-at-bol, vip-find-char, vip-put-back, ex-read):
Wrap with-no-warnings around uses of next-line and previous-line.
* ediff.el (run-ediff-from-cvs-buffer):
* ediff-vers.el (cvs-run-ediff-on-file-descriptor): Remove
function not used by pcl-cvs anymore.
(noninteractive, generic-sc-get-latest-rev)
(ediff-generic-sc-internal, ediff-generic-sc-merge-internal):
Delete support for long obsolete generic-sc.el.
2007-10-31 06:28:09 +00:00
|
|
|
|
(with-no-warnings (next-line arg)))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
1992-10-18 22:20:07 +00:00
|
|
|
|
(defun mail-abbrev-end-of-buffer (&optional arg)
|
2009-03-12 06:23:35 +00:00
|
|
|
|
"Expand a mail abbrev before point, then move to the end of the buffer.
|
|
|
|
|
This only expands an abbrev (if one is present) if called with
|
|
|
|
|
point at the end of a line, or on whitespace before the end of a line.
|
1992-10-18 22:20:07 +00:00
|
|
|
|
|
2009-03-12 06:23:35 +00:00
|
|
|
|
In other respects, this behaves like `end-of-buffer', which see."
|
1993-07-08 21:14:43 +00:00
|
|
|
|
(interactive "P")
|
1992-06-15 21:06:57 +00:00
|
|
|
|
(if (looking-at "[ \t]*\n") (expand-abbrev))
|
|
|
|
|
(setq this-command 'end-of-buffer)
|
2009-03-12 06:23:35 +00:00
|
|
|
|
(with-no-warnings (end-of-buffer arg)))
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
2002-02-09 09:46:08 +00:00
|
|
|
|
(eval-after-load "sendmail"
|
|
|
|
|
'(progn
|
2021-03-11 14:32:42 -05:00
|
|
|
|
(define-key mail-mode-map "\C-c\C-a" #'mail-abbrev-insert-alias)
|
2015-05-18 20:53:11 -04:00
|
|
|
|
(define-key mail-mode-map "\e\t" ; like completion-at-point
|
2021-03-11 14:32:42 -05:00
|
|
|
|
#'mail-abbrev-complete-alias))) ;; FIXME: Use `completion-at-point'.
|
1992-03-24 04:22:48 +00:00
|
|
|
|
|
2021-03-11 14:32:42 -05:00
|
|
|
|
;;(define-key mail-mode-map "\C-n" #'mail-abbrev-next-line)
|
|
|
|
|
;;(define-key mail-mode-map "\M->" #'mail-abbrev-end-of-buffer)
|
1991-12-17 03:37:43 +00:00
|
|
|
|
|
1993-03-29 08:09:35 +00:00
|
|
|
|
(provide 'mailabbrev)
|
1996-01-14 07:34:30 +00:00
|
|
|
|
|
2001-07-15 16:15:35 +00:00
|
|
|
|
;;; mailabbrev.el ends here
|