comparison lisp/mail/mailalias.el @ 7732:b99162ca5247

(build-mail-aliases): Handle source directives. Handle MAILRC envvar.
author Richard M. Stallman <rms@gnu.org>
date Sat, 28 May 1994 13:06:55 +0000
parents e67f922b73ed
children d8bede4feaed
comparison
equal deleted inserted replaced
7731:3cfe5791ddfb 7732:b99162ca5247
103 (set-marker end nil))) 103 (set-marker end nil)))
104 104
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
112 (progn 112 (progn
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))
135 (re-search-forward "[^ \t]+") 148 (re-search-forward "[^ \t]+")
136 (let* ((name (buffer-substring (match-beginning 0) (match-end 0))) 149 (let* ((name (buffer-substring (match-beginning 0) (match-end 0)))