unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12439: 24.2.50; mail-abbrev fills long aliasee uglily
@ 2012-09-14  8:53 Katsumi Yamaoka
  2012-09-16 23:16 ` Katsumi Yamaoka
  0 siblings, 1 reply; 2+ messages in thread
From: Katsumi Yamaoka @ 2012-09-14  8:53 UTC (permalink / raw)
  To: 12439

[-- Attachment #1: Type: text/plain, Size: 803 bytes --]

Hi,

By default message.el uses mail-abbrev to expand mail aliases in
headers in a draft.  If an aliasee is longer than fill-column,
it will be expanded like the following:

To: foo1@bar.baz, foo2@bar.baz, foo3@bar.baz, foo4@bar.baz,
    foo5@bar.baz,
    foo6@bar.baz,
    foo7@bar.baz,
    foo8@bar.baz

To reproduce this, try the "foo" alias specified as follows:

(define-mail-abbrev "foo"
  "foo1@bar.baz, foo2@bar.baz, foo3@bar.baz, foo4@bar.baz,\
 foo5@bar.baz, foo6@bar.baz, foo7@bar.baz, foo8@bar.baz")

The point is that the latter half addresses in an aliasee are
put line by line.  Moreover, I think a SPC is enough for LWSP
preceding to the latter half (message.el uses TAB in some fill
function, though), rather than the one indent-relative generates.

A patch I tried is attached below.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1874 bytes --]

--- mailabbrev.el~	2012-05-06 21:58:55.506179000 +0000
+++ mailabbrev.el	2012-09-14 08:38:38.323389500 +0000
@@ -391,35 +391,24 @@
 (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)))))))
 \f
 ;;; Syntax tables and abbrev-expansion
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#12439: 24.2.50; mail-abbrev fills long aliasee uglily
  2012-09-14  8:53 bug#12439: 24.2.50; mail-abbrev fills long aliasee uglily Katsumi Yamaoka
@ 2012-09-16 23:16 ` Katsumi Yamaoka
  0 siblings, 0 replies; 2+ messages in thread
From: Katsumi Yamaoka @ 2012-09-16 23:16 UTC (permalink / raw)
  To: 12439-done

Katsumi Yamaoka <yamaoka@jpl.org> wrote:
> By default message.el uses mail-abbrev to expand mail aliases in
> headers in a draft.  If an aliasee is longer than fill-column,
> it will be expanded like the following:

> To: foo1@bar.baz, foo2@bar.baz, foo3@bar.baz, foo4@bar.baz,
>     foo5@bar.baz,
>     foo6@bar.baz,
>     foo7@bar.baz,
>     foo8@bar.baz

> To reproduce this, try the "foo" alias specified as follows:

> (define-mail-abbrev "foo"
>   "foo1@bar.baz, foo2@bar.baz, foo3@bar.baz, foo4@bar.baz,\
>  foo5@bar.baz, foo6@bar.baz, foo7@bar.baz, foo8@bar.baz")

> The point is that the latter half addresses in an aliasee are
> put line by line.  Moreover, I think a SPC is enough for LWSP
> preceding to the latter half (message.el uses TAB in some fill
> function, though), rather than the one indent-relative generates.

> A patch I tried is attached below.

I've installed my patch to the trunk.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-16 23:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-14  8:53 bug#12439: 24.2.50; mail-abbrev fills long aliasee uglily Katsumi Yamaoka
2012-09-16 23:16 ` Katsumi Yamaoka

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).