GNU bug report logs - #12439
24.2.50; mail-abbrev fills long aliasee uglily

Previous Next

Package: emacs;

Reported by: Katsumi Yamaoka <yamaoka <at> jpl.org>

Date: Fri, 14 Sep 2012 08:55:02 UTC

Severity: minor

Tags: patch

Found in version 24.2.50

Done: Katsumi Yamaoka <yamaoka <at> jpl.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12439 in the body.
You can then email your comments to 12439 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12439; Package emacs. (Fri, 14 Sep 2012 08:55:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Katsumi Yamaoka <yamaoka <at> jpl.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 14 Sep 2012 08:55:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2.50; mail-abbrev fills long aliasee uglily
Date: Fri, 14 Sep 2012 17:53:15 +0900
[Message part 1 (text/plain, inline)]
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 <at> bar.baz, foo2 <at> bar.baz, foo3 <at> bar.baz, foo4 <at> bar.baz,
    foo5 <at> bar.baz,
    foo6 <at> bar.baz,
    foo7 <at> bar.baz,
    foo8 <at> bar.baz

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

(define-mail-abbrev "foo"
  "foo1 <at> bar.baz, foo2 <at> bar.baz, foo3 <at> bar.baz, foo4 <at> bar.baz,\
 foo5 <at> bar.baz, foo6 <at> bar.baz, foo7 <at> bar.baz, foo8 <at> 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.

[Message part 2 (text/x-patch, inline)]
--- 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)))))))
 
 ;;; Syntax tables and abbrev-expansion
 

Reply sent to Katsumi Yamaoka <yamaoka <at> jpl.org>:
You have taken responsibility. (Sun, 16 Sep 2012 23:18:02 GMT) Full text and rfc822 format available.

Notification sent to Katsumi Yamaoka <yamaoka <at> jpl.org>:
bug acknowledged by developer. (Sun, 16 Sep 2012 23:18:02 GMT) Full text and rfc822 format available.

Message #10 received at 12439-done <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: 12439-done <at> debbugs.gnu.org
Subject: Re: bug#12439: 24.2.50; mail-abbrev fills long aliasee uglily
Date: Mon, 17 Sep 2012 08:16:21 +0900
Katsumi Yamaoka <yamaoka <at> 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 <at> bar.baz, foo2 <at> bar.baz, foo3 <at> bar.baz, foo4 <at> bar.baz,
>     foo5 <at> bar.baz,
>     foo6 <at> bar.baz,
>     foo7 <at> bar.baz,
>     foo8 <at> bar.baz

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

> (define-mail-abbrev "foo"
>   "foo1 <at> bar.baz, foo2 <at> bar.baz, foo3 <at> bar.baz, foo4 <at> bar.baz,\
>  foo5 <at> bar.baz, foo6 <at> bar.baz, foo7 <at> bar.baz, foo8 <at> 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 15 Oct 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 244 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.