diff options
| author | Richard M. Stallman | 1994-05-28 13:06:55 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-05-28 13:06:55 +0000 |
| commit | 3c55fda04ce25d74879421cb3180c779ce00b3cb (patch) | |
| tree | f2ba8f96a400fe40578a9c01c4e6bfb3cf6fdf25 | |
| parent | f87de92aa2bd02096608d38d295136666533e83d (diff) | |
| download | emacs-3c55fda04ce25d74879421cb3180c779ce00b3cb.tar.gz emacs-3c55fda04ce25d74879421cb3180c779ce00b3cb.zip | |
(build-mail-aliases): Handle source directives.
Handle MAILRC envvar.
| -rw-r--r-- | lisp/mail/mailalias.el | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/lisp/mail/mailalias.el b/lisp/mail/mailalias.el index a807d331992..09335afdb39 100644 --- a/lisp/mail/mailalias.el +++ b/lisp/mail/mailalias.el | |||
| @@ -105,7 +105,7 @@ removed from alias expansions." | |||
| 105 | ;; Called by mail-setup, or similar functions, only if ~/.mailrc exists. | 105 | ;; Called by mail-setup, or similar functions, only if ~/.mailrc exists. |
| 106 | (defun build-mail-aliases (&optional file) | 106 | (defun build-mail-aliases (&optional file) |
| 107 | "Read mail aliases from `~/.mailrc' and set `mail-aliases'." | 107 | "Read mail aliases from `~/.mailrc' and set `mail-aliases'." |
| 108 | (setq file (expand-file-name (or file "~/.mailrc"))) | 108 | (setq file (expand-file-name (or file (or (getenv "MAILRC") "~/.mailrc")))) |
| 109 | (let ((buffer nil) | 109 | (let ((buffer nil) |
| 110 | (obuf (current-buffer))) | 110 | (obuf (current-buffer))) |
| 111 | (unwind-protect | 111 | (unwind-protect |
| @@ -113,22 +113,35 @@ removed from alias expansions." | |||
| 113 | (setq buffer (generate-new-buffer "mailrc")) | 113 | (setq buffer (generate-new-buffer "mailrc")) |
| 114 | (buffer-disable-undo buffer) | 114 | (buffer-disable-undo buffer) |
| 115 | (set-buffer buffer) | 115 | (set-buffer buffer) |
| 116 | (cond ((get-file-buffer file) | 116 | (while file |
| 117 | (insert (save-excursion | 117 | (cond ((get-file-buffer file) |
| 118 | (set-buffer (get-file-buffer file)) | 118 | (insert (save-excursion |
| 119 | (buffer-substring (point-min) (point-max))))) | 119 | (set-buffer (get-file-buffer file)) |
| 120 | ((not (file-exists-p file))) | 120 | (buffer-substring (point-min) (point-max))))) |
| 121 | (t (insert-file-contents file))) | 121 | ((file-exists-p file) (insert-file-contents file)) |
| 122 | ;; Don't lose if no final newline. | 122 | ((file-exists-p (setq file (concat "~/" file))) |
| 123 | (goto-char (point-max)) | 123 | (insert-file-contents file)) |
| 124 | (or (eq (preceding-char) ?\n) (newline)) | 124 | (t (setq file nil))) |
| 125 | (goto-char (point-min)) | 125 | ;; Don't lose if no final newline. |
| 126 | ;; handle "\\\n" continuation lines | 126 | (goto-char (point-max)) |
| 127 | (while (not (eobp)) | 127 | (or (eq (preceding-char) ?\n) (newline)) |
| 128 | (end-of-line) | 128 | (goto-char (point-min)) |
| 129 | (if (= (preceding-char) ?\\) | 129 | ;; handle "\\\n" continuation lines |
| 130 | (progn (delete-char -1) (delete-char 1) (insert ?\ )) | 130 | (while (not (eobp)) |
| 131 | (end-of-line) | ||
| 132 | (if (= (preceding-char) ?\\) | ||
| 133 | (progn (delete-char -1) (delete-char 1) (insert ?\ )) | ||
| 131 | (forward-char 1))) | 134 | (forward-char 1))) |
| 135 | (goto-char (point-min)) | ||
| 136 | ;; handle `source' directives -- Eddy/1994/May/25 | ||
| 137 | (cond ((re-search-forward "^source[ \t]+" nil t) | ||
| 138 | (re-search-forward "\\S-+") | ||
| 139 | (setq file | ||
| 140 | (buffer-substring (match-beginning 0) (match-end 0))) | ||
| 141 | (beginning-of-line) | ||
| 142 | (insert "# ") ; to ensure we don't re-process this file | ||
| 143 | (beginning-of-line)) | ||
| 144 | (t (setq file nil)))) | ||
| 132 | (goto-char (point-min)) | 145 | (goto-char (point-min)) |
| 133 | (while (or (re-search-forward "^a\\(lias\\|\\)[ \t]+" nil t) | 146 | (while (or (re-search-forward "^a\\(lias\\|\\)[ \t]+" nil t) |
| 134 | (re-search-forward "^g\\(roup\\|\\)[ \t]+" nil t)) | 147 | (re-search-forward "^g\\(roup\\|\\)[ \t]+" nil t)) |