aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1996-05-26 23:12:01 +0000
committerRoland McGrath1996-05-26 23:12:01 +0000
commit0f965ba3f746b95826172f369e1016d783f53ab4 (patch)
tree195e032e3b089219d5e4ee8652fcc9c57151faac
parent805288011b170d23b6d9d9b2a451933fdf28562d (diff)
downloademacs-0f965ba3f746b95826172f369e1016d783f53ab4.tar.gz
emacs-0f965ba3f746b95826172f369e1016d783f53ab4.zip
(mail-abbrev-expand-hook): Disable abbrev mode temporarily while working,
to avoid recursion in indent-relative expanding part of the abbrev expansion as an abbrev itself.
-rw-r--r--lisp/mail/mailabbrev.el63
1 files changed, 33 insertions, 30 deletions
diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el
index 539794ba86f..e69e10cdf5f 100644
--- a/lisp/mail/mailabbrev.el
+++ b/lisp/mail/mailabbrev.el
@@ -26,7 +26,7 @@
26 26
27;;; Commentary: 27;;; Commentary:
28 28
29;; This file ensures that, when the point is in a To:, CC:, BCC:, or From: 29;; This file ensures that, when the point is in a To:, CC:, BCC:, or From:
30;; field, word-abbrevs are defined for each of your mail aliases. These 30;; field, word-abbrevs are defined for each of your mail aliases. These
31;; aliases will be defined from your .mailrc file (or the file specified by 31;; aliases will be defined from your .mailrc file (or the file specified by
32;; the MAILRC environment variable) if it exists. Your mail aliases will 32;; the MAILRC environment variable) if it exists. Your mail aliases will
@@ -41,7 +41,7 @@
41;; Your mail alias abbrevs will be in effect only when the point is in an 41;; Your mail alias abbrevs will be in effect only when the point is in an
42;; appropriate header field. When in the body of the message, or other 42;; appropriate header field. When in the body of the message, or other
43;; header fields, the mail aliases will not expand. Rather, the normal 43;; header fields, the mail aliases will not expand. Rather, the normal
44;; mode-specific abbrev table (mail-mode-abbrev-table) will be used if 44;; mode-specific abbrev table (mail-mode-abbrev-table) will be used if
45;; defined. So if you use mail-mode specific abbrevs, this code will not 45;; defined. So if you use mail-mode specific abbrevs, this code will not
46;; adversely affect you. You can control which header fields the abbrevs 46;; adversely affect you. You can control which header fields the abbrevs
47;; are used in by changing the variable mail-abbrev-mode-regexp. 47;; are used in by changing the variable mail-abbrev-mode-regexp.
@@ -153,7 +153,7 @@ no aliases, which is represented by this being a table with no entries.)")
153 (if (and (not (vectorp mail-abbrevs)) 153 (if (and (not (vectorp mail-abbrevs))
154 (file-exists-p mail-personal-alias-file)) 154 (file-exists-p mail-personal-alias-file))
155 (progn 155 (progn
156 (setq mail-abbrev-modtime 156 (setq mail-abbrev-modtime
157 (nth 5 (file-attributes mail-personal-alias-file))) 157 (nth 5 (file-attributes mail-personal-alias-file)))
158 (build-mail-abbrevs))) 158 (build-mail-abbrevs)))
159 (mail-abbrevs-sync-aliases) 159 (mail-abbrevs-sync-aliases)
@@ -233,7 +233,7 @@ By default this is the file specified by `mail-personal-alias-file'."
233 233
234(defvar mail-alias-separator-string ", " 234(defvar mail-alias-separator-string ", "
235 "*A string inserted between addresses in multi-address mail aliases. 235 "*A string inserted between addresses in multi-address mail aliases.
236This has to contain a comma, so \", \" is a reasonable value. You might 236This has to contain a comma, so \", \" is a reasonable value. You might
237also want something like \",\\n \" to get each address on its own line.") 237also want something like \",\\n \" to get each address on its own line.")
238 238
239;; define-mail-abbrev sets this flag, which causes mail-resolve-all-aliases 239;; define-mail-abbrev sets this flag, which causes mail-resolve-all-aliases
@@ -329,35 +329,38 @@ If DEFINITION contains multiple addresses, separate them with commas."
329 "For use as the fourth arg to `define-abbrev'. 329 "For use as the fourth arg to `define-abbrev'.
330After expanding a mail-abbrev, if Auto Fill mode is on and we're past the 330After expanding a mail-abbrev, if Auto Fill mode is on and we're past the
331fill-column, break the line at the previous comma, and indent the next line." 331fill-column, break the line at the previous comma, and indent the next line."
332 (save-excursion 332 ;; Disable abbrev mode to avoid recursion in indent-relative expanding
333 (let ((p (point)) 333 ;; part of the abbrev expansion as an abbrev itself.
334 bol comma fp) 334 (let ((abbrev-mode nil))
335 (beginning-of-line) 335 (save-excursion
336 (setq bol (point)) 336 (let ((p (point))
337 (goto-char p) 337 bol comma fp)
338 (while (and auto-fill-function 338 (beginning-of-line)
339 (>= (current-column) fill-column) 339 (setq bol (point))
340 (search-backward "," bol t)) 340 (goto-char p)
341 (setq comma (point)) 341 (while (and auto-fill-function
342 (forward-char 1) ; Now we are just past the comma. 342 (>= (current-column) fill-column)
343 (insert "\n") 343 (search-backward "," bol t))
344 (delete-horizontal-space) 344 (setq comma (point))
345 (setq p (point)) 345 (forward-char 1) ; Now we are just past the comma.
346 (indent-relative) 346 (insert "\n")
347 (setq fp (buffer-substring p (point))) 347 (delete-horizontal-space)
348 ;; Go to the end of the new line. 348 (setq p (point))
349 (end-of-line) 349 (indent-relative)
350 (if (> (current-column) fill-column) 350 (setq fp (buffer-substring p (point)))
351 ;; It's still too long; do normal auto-fill. 351 ;; Go to the end of the new line.
352 (let ((fill-prefix (or fp "\t"))) 352 (end-of-line)
353 (do-auto-fill))) 353 (if (> (current-column) fill-column)
354 ;; Resume the search. 354 ;; It's still too long; do normal auto-fill.
355 (goto-char comma) 355 (let ((fill-prefix (or fp "\t")))
356 )))) 356 (do-auto-fill)))
357 ;; Resume the search.
358 (goto-char comma)
359 )))))
357 360
358;;; Syntax tables and abbrev-expansion 361;;; Syntax tables and abbrev-expansion
359 362
360(defvar mail-abbrev-mode-regexp 363(defvar mail-abbrev-mode-regexp
361 "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):" 364 "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):"
362 "*Regexp to select mail-headers in which mail abbrevs should be expanded. 365 "*Regexp to select mail-headers in which mail abbrevs should be expanded.
363This string will be handed to `looking-at' with point at the beginning 366This string will be handed to `looking-at' with point at the beginning