X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/4dc7c8d5795458e89d19b59f64760e155c2cd70b..0877d0dc24ee792b9b14592869ea1aa0934aee58:/lisp/mail/mailabbrev.el diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el index 290c57c1c5..3308e6416e 100644 --- a/lisp/mail/mailabbrev.el +++ b/lisp/mail/mailabbrev.el @@ -1,7 +1,7 @@ ;;; mailabbrev.el --- abbrev-expansion of mail aliases -;; Copyright (C) 1985-1987, 1992-1993, 1996-1997, 2000-2012 -;; Free Software Foundation, Inc. +;; Copyright (C) 1985-1987, 1992-1993, 1996-1997, 2000-2013 Free +;; Software Foundation, Inc. ;; Author: Jamie Zawinski ;; Maintainer: FSF @@ -391,35 +391,24 @@ double-quotes." (defun mail-abbrev-expand-hook () "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 -fill-column, break the line at the previous comma, and indent the next line." - ;; Disable abbrev mode to avoid recursion in indent-relative expanding - ;; part of the abbrev expansion as an abbrev itself. - (let ((abbrev-mode nil)) - (save-excursion - (let ((p (point)) - bol comma fp) - (beginning-of-line) - (setq bol (point)) - (goto-char p) - (while (and auto-fill-function - (>= (current-column) fill-column) - (search-backward "," bol t)) - (setq comma (point)) - (forward-char 1) ; Now we are just past the comma. - (insert "\n") - (delete-horizontal-space) - (setq p (point)) - (indent-relative) - (setq fp (buffer-substring p (point))) - ;; Go to the end of the new line. - (end-of-line) - (if (> (current-column) fill-column) - ;; It's still too long; do normal auto-fill. - (let ((fill-prefix (or fp "\t"))) - (do-auto-fill))) - ;; Resume the search. - (goto-char comma) - ))))) +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))))))) ;;; Syntax tables and abbrev-expansion @@ -483,10 +472,12 @@ of a mail alias. The value is set up, buffer-local, when first needed.") (defun mail-abbrev-expand-wrapper (expand) (if (and mail-abbrevs (not (eq mail-abbrevs t))) - (if (mail-abbrev-in-expansion-header-p) + (if (or (mail-abbrev-in-expansion-header-p) + ;; Necessary for `message-read-from-minibuffer' to work. + (window-minibuffer-p)) - ;; We are in a To: (or CC:, or whatever) header, and - ;; should use word-abbrevs to expand mail aliases. + ;; We are in a To: (or CC:, or whatever) header or a minibuffer, + ;; and should use word-abbrevs to expand mail aliases. (let ((local-abbrev-table mail-abbrevs)) ;; Before anything else, resolve aliases if they need it.