• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/mail/

Lines Matching +refs:mail +refs:directory +refs:function

7 ;; Keywords: mail
28 ;; Basic functions for defining and expanding mail aliases.
37 "Expanding mail aliases."
38 :group 'mail)
40 (defcustom mail-passwd-files '("/etc/passwd")
45 (defcustom mail-passwd-command nil
50 (defvar mail-directory-names t
51 "Alist of mail address directory entries.
54 (defvar mail-address-field-regexp
57 (defcustom mail-complete-alist
60 ;; Don't refer to mail-address-field-regexp here;
63 . (mail-get-names pattern))
68 ("Followup-To:" . (mail-sentto-newsgroups))
74 If not on matching header, `mail-complete-function' gets called instead."
77 (put 'mail-complete-alist 'risky-local-variable t)
80 (defcustom mail-complete-style 'angles
81 "*Specifies how \\[mail-complete] formats the full name when it completes.
91 (defcustom mail-complete-function 'ispell-complete-word
92 "*Function to call when completing outside `mail-complete-alist'-header."
93 :type '(choice function (const nil))
96 (defcustom mail-directory-function nil
97 "*Function to get completions from directory service or nil for none.
98 See `mail-directory-requery'."
99 :type '(choice function (const nil))
102 ;; This is for when the directory is huge, or changes frequently.
103 (defcustom mail-directory-requery nil
104 "*When non-nil call `mail-directory-function' for each completion.
105 In that case, one argument gets passed to the function, the partial string
110 (defcustom mail-directory-process nil
111 "*Shell command to get the list of names from a mail directory.
112 This value is used when the value of `mail-directory-function'
113 is `mail-directory-process'. The value should be a list
116 `mail-directory-requery' is non-nil, during evaluation of these
118 completed. `pattern' is nil when `mail-directory-requery' is nil.
129 (put 'mail-directory-process 'risky-local-variable t)
131 (defcustom mail-directory-stream nil
132 "*List of (HOST SERVICE) for stream connection to mail directory."
135 (put 'mail-directory-stream 'risky-local-variable t)
137 (defcustom mail-directory-parser nil
138 "*How to interpret the output of `mail-directory-function'.
143 - function called at beginning of buffer that returns an alist of names"
144 :type '(choice (const nil) regexp function)
146 (put 'mail-directory-parser 'risky-local-variable t)
150 (defvar mail-names t
151 "Alist of local users, aliases and directory entries as available.
154 for the next use. This is used in `mail-complete'.")
156 (defvar mail-local-names t
163 ;; only if some mail aliases are defined.
165 (defun expand-mail-aliases (beg end &optional exclude)
166 "Expand all mail aliases in suitable header fields found between BEG and END.
176 (mail-header-end))))
178 (when (eq mail-aliases t)
179 (setq mail-aliases nil)
180 (build-mail-aliases))
186 (re-search-forward mail-address-field-regexp end t))
217 (setq translation (cdr (assoc string mail-aliases))))
241 ;; Called by mail-setup, or similar functions, only if the file specified
242 ;; by mail-personal-alias-file (usually `~/.mailrc') exists.
243 (defun build-mail-aliases (&optional file)
244 "Read mail aliases from personal aliases file and set `mail-aliases'.
245 By default, this is the file specified by `mail-personal-alias-file'."
246 (setq file (expand-file-name (or file mail-personal-alias-file)))
247 ;; In case mail-aliases is t, make sure define-mail-alias
248 ;; does not recursively call build-mail-aliases.
249 (setq mail-aliases nil)
301 (define-mail-alias name value t))))
302 mail-aliases)
309 (defun define-mail-alias (name definition &optional from-mailrc-file)
310 "Define NAME as a mail alias that translates to DEFINITION.
318 (interactive "sDefine mail alias: \nsDefine %s as mail alias for: ")
323 (if (eq mail-aliases t)
325 (setq mail-aliases nil)
326 (if (file-exists-p mail-personal-alias-file)
327 (build-mail-aliases))))
368 (setq definition (mapconcat (function identity)
371 (setq tem (assoc name mail-aliases))
374 (setq mail-aliases (cons (cons name definition) mail-aliases)
375 mail-names t))))
378 (defun mail-complete (arg)
380 Completable headers are according to `mail-complete-alist'. If none matches
381 current header, calls `mail-complete-function' and passes prefix arg if any."
385 (if (eq mail-aliases t)
387 (setq mail-aliases nil)
388 (if (file-exists-p mail-personal-alias-file)
389 (build-mail-aliases))))
390 (let ((list mail-complete-alist))
391 (if (and (< 0 (mail-header-end))
414 (let ((alist-elt (assoc completion mail-names)))
416 (cond ((eq mail-complete-style 'parens)
418 ((eq mail-complete-style 'angles)
429 (funcall mail-complete-function arg))))
431 (defun mail-get-names (pattern)
432 "Fetch local users and global mail addresses for completion.
433 Consults `/etc/passwd' and a directory service if one is set up via
434 `mail-directory-function'.
436 (if (eq mail-local-names t)
439 (let ((files mail-passwd-files))
443 (if mail-passwd-command
445 shell-command-switch mail-passwd-command))
447 (setq mail-local-names nil)
457 (add-to-list 'mail-local-names
463 (if (or (eq mail-names t)
464 (eq mail-directory-names t))
465 (let (directory)
466 (and mail-directory-function
467 (eq mail-directory-names t)
468 (setq directory
469 (mail-directory (if mail-directory-requery pattern))))
470 (or mail-directory-requery
471 (setq mail-directory-names directory))
472 (if (or directory
473 (eq mail-names t))
474 (setq mail-names
475 (sort (append (if (consp mail-aliases)
477 (function (lambda (a) (list (car a))))
478 mail-aliases))
479 (if (consp mail-local-names)
480 mail-local-names)
481 (or directory
482 (when (consp mail-directory-names)
483 mail-directory-names)))
488 mail-names)
491 (defun mail-directory (pattern)
492 "Use mail-directory facility to get user names matching PATTERN.
494 This function calls `mail-directory-function' to query the directory,
495 then uses `mail-directory-parser' to parse the output it returns."
497 (message "Querying directory...")
498 (set-buffer (generate-new-buffer " *mail-directory*"))
499 (funcall mail-directory-function pattern)
501 (let (directory)
502 (if (stringp mail-directory-parser)
503 (while (re-search-forward mail-directory-parser nil t)
504 (setq directory
505 (cons (match-string 1) directory)))
506 (if mail-directory-parser
507 (setq directory (funcall mail-directory-parser))
509 (setq directory
516 directory)))))
518 (message "Querying directory...done")
519 directory)))
522 (defun mail-directory-process (pattern)
523 "Run a shell command to output names in directory.
524 See `mail-directory-process'."
525 (when (consp mail-directory-process)
526 (apply 'call-process (eval (car mail-directory-process)) nil t nil
527 (mapcar 'eval (cdr mail-directory-process)))))
530 (defun mail-directory-stream (pattern)
531 "Open a stream to retrieve names in directory.
532 See `mail-directory-stream'."
536 mail-directory-stream)
542 (defun mail-sentto-newsgroups ()
545 (if (mail-position-on-field "newsgroups" t)