unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Mailabbrev fixes [PATCH]
@ 2005-01-01  8:21 cyd
  2005-01-02  2:35 ` Miles Bader
  0 siblings, 1 reply; 4+ messages in thread
From: cyd @ 2005-01-01  8:21 UTC (permalink / raw)


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

Hi,

The attached patch should fix two items in FOR-RELEASE:

** Mailabbrev should quote addresses to correspond to RFC 822.
See http://article.gmane.org/gmane.emacs.devel/27585

** The '@' character should not expand addresses in mailabbrev
See http://article.gmane.org/gmane.emacs.devel/27585

The first bug is fixed by enclosing everything preceding the actual email
address in quotes <">. This is overkill, because quoting is only necessary
when there are illegal characters present, but it is not wrong. I think
that actually checking for the presence of illegal characters would cause
too much complexity for too little gain, but others may disagree.

The second bug is fixed by partially reverting the following commit:

2002-02-06  Richard M. Stallman  <address@bogus.example.com>
+
+       * mail/mailabbrev.el: Require sendmail only at compile time.
+       (mail-mode-header-syntax-table): Var deleted.

mail-mode-header-syntax-table has been re-introduced. It does not do
anything except ensure that abbrev expansion does not occur on typing @.

-- Yidong

[-- Attachment #2: mailabbrev.patch --]
[-- Type: application/octet-stream, Size: 2565 bytes --]

--- mailabbrev.el~	2004-12-31 22:31:48.000000000 -0800
+++ mailabbrev.el	2005-01-01 00:05:00.000000000 -0800
@@ -305,7 +305,10 @@
 		    end (string-match "\"[ \t,]*" definition start))
 	    (setq end (string-match "[ \t,]+" definition start)))
 	(setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
-      (setq result (cons (substring definition start end) result))
+      (setq result (cons
+                    (replace-regexp-in-string
+                     "\\(.+?\\)[ \t]*\\(<.*>\\)" "\"\\1\" \\2"
+                     (substring definition start end)) result))
       (setq start (and end
 		       (/= (match-end 0) L)
 		       (match-end 0))))
@@ -398,6 +401,24 @@
 This should be set to match those mail fields in which you want abbreviations
 turned on.")
 
+(defvar mail-mode-header-syntax-table
+  (let ((tab (copy-syntax-table (syntax-table))))
+    ;; This makes the characters "@%!._-" be considered symbol
+    ;; constituents, but not word constituents. Among other things,
+    ;; this ensures that typing "@" will not cause abbrev expansion.
+    (modify-syntax-entry ?@ "_" tab)
+    (modify-syntax-entry ?% "_" tab)
+    (modify-syntax-entry ?! "_" tab)
+    (modify-syntax-entry ?. "_" tab)
+    (modify-syntax-entry ?_ "_" tab)
+    (modify-syntax-entry ?- "_" tab)
+    (modify-syntax-entry ?< "(>" tab)
+    (modify-syntax-entry ?> ")<" tab)
+    tab)
+  "The syntax table used in send-mail-mode when in a mail-address header.
+`mail-mode-syntax-table' is used when the cursor is in the message body or
+in non-address headers.")
+
 (defvar mail-abbrev-syntax-table nil
   "The syntax-table used for abbrev-expansion purposes.
 This is not actually made the current syntax table of the buffer, but
@@ -476,6 +497,10 @@
 	     ;;      will happen as a result of this function's call to
 	     ;;      expand-abbrev, and not as a result of the call to
 	     ;;      expand-abbrev which invoked *us*.
+	     ;;   -  Then we set the syntax table to
+	     ;;      mail-mode-header-syntax-table, which doesn't have
+	     ;;      anything to do with abbrev expansion, but is just
+	     ;;      for the user's convenience (see its doc string.)
 
 	     (mail-abbrev-make-syntax-table)
 
@@ -484,6 +509,7 @@
 	     ;; when the user types -.)  Check the character's syntax in
 	     ;; the usual syntax table.
 
+	     (set-syntax-table mail-mode-header-syntax-table)
 	     (or (and (integerp last-command-char)
 		      (eq (char-syntax last-command-char) ?_))
 		 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Mailabbrev fixes [PATCH]
  2005-01-01  8:21 Mailabbrev fixes [PATCH] cyd
@ 2005-01-02  2:35 ` Miles Bader
  2005-01-02  6:07   ` Chong Yidong
  0 siblings, 1 reply; 4+ messages in thread
From: Miles Bader @ 2005-01-02  2:35 UTC (permalink / raw)
  Cc: emacs-devel

> I think
> that actually checking for the presence of illegal characters would cause
> too much complexity for too little gain, but others may disagree.

Er, (string-match "[^a-zA-Z0-9 ]" name) is complexity?

[Yeah, I find MUAs that quote everything pretty annoying...]

-Miles

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

* Re: Mailabbrev fixes [PATCH]
  2005-01-02  2:35 ` Miles Bader
@ 2005-01-02  6:07   ` Chong Yidong
  2005-01-03 22:39     ` John Owens
  0 siblings, 1 reply; 4+ messages in thread
From: Chong Yidong @ 2005-01-02  6:07 UTC (permalink / raw)


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

>> I think that actually checking for the presence of illegal characters
>> would cause too much complexity for too little gain, but others may
>> disagree.
>
> Er, (string-match "[^a-zA-Z0-9 ]" name) is complexity?
>
> [Yeah, I find MUAs that quote everything pretty annoying...]

Okay, then. Here is an amended patch. (The legal character set is more like
[^- !#-'*+/-9=?A-Z^-~], but I see your point.)

-- Yidong

[-- Attachment #2: mailabbrev.patch --]
[-- Type: application/octet-stream, Size: 2714 bytes --]

--- mailabbrev.el~	2004-12-31 22:31:48.000000000 -0800
+++ mailabbrev.el	2005-01-01 22:01:21.000000000 -0800
@@ -305,7 +305,10 @@
 		    end (string-match "\"[ \t,]*" definition start))
 	    (setq end (string-match "[ \t,]+" definition start)))
 	(setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
-      (setq result (cons (substring definition start end) result))
+      (setq result (cons
+          (replace-regexp-in-string
+           "\\(.*[^- !#-'*+/-9=?A-Z^-~].*?\\)[ \t]*\\(<.*>\\)"
+           "\"\\1\" \\2" (substring definition start end)) result))
       (setq start (and end
 		       (/= (match-end 0) L)
 		       (match-end 0))))
@@ -398,6 +401,24 @@
 This should be set to match those mail fields in which you want abbreviations
 turned on.")
 
+(defvar mail-mode-header-syntax-table
+  (let ((tab (copy-syntax-table (syntax-table))))
+    ;; This makes the characters "@%!._-" be considered symbol
+    ;; constituents, but not word constituents. Among other things,
+    ;; this ensures that typing "@" will not cause abbrev expansion.
+    (modify-syntax-entry ?@ "_" tab)
+    (modify-syntax-entry ?% "_" tab)
+    (modify-syntax-entry ?! "_" tab)
+    (modify-syntax-entry ?. "_" tab)
+    (modify-syntax-entry ?_ "_" tab)
+    (modify-syntax-entry ?- "_" tab)
+    (modify-syntax-entry ?< "(>" tab)
+    (modify-syntax-entry ?> ")<" tab)
+    tab)
+  "The syntax table used in send-mail-mode when in a mail-address header.
+`mail-mode-syntax-table' is used when the cursor is in the message body or
+in non-address headers.")
+
 (defvar mail-abbrev-syntax-table nil
   "The syntax-table used for abbrev-expansion purposes.
 This is not actually made the current syntax table of the buffer, but
@@ -476,14 +497,19 @@
 	     ;;      will happen as a result of this function's call to
 	     ;;      expand-abbrev, and not as a result of the call to
 	     ;;      expand-abbrev which invoked *us*.
+	     ;;   -  Then we set the syntax table to
+	     ;;      mail-mode-header-syntax-table, which doesn't have
+	     ;;      anything to do with abbrev expansion, but is just
+	     ;;      for the user's convenience (see its doc string.)
 
 	     (mail-abbrev-make-syntax-table)
 
 	     ;; If the character just typed was non-alpha-symbol-syntax,
 	     ;; then don't expand the abbrev now (that is, don't expand
 	     ;; when the user types -.)  Check the character's syntax in
-	     ;; the usual syntax table.
+	     ;; mail-mode-header-syntax-table.
 
+	     (set-syntax-table mail-mode-header-syntax-table)
 	     (or (and (integerp last-command-char)
 		      (eq (char-syntax last-command-char) ?_))
 		 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Mailabbrev fixes [PATCH]
  2005-01-02  6:07   ` Chong Yidong
@ 2005-01-03 22:39     ` John Owens
  0 siblings, 0 replies; 4+ messages in thread
From: John Owens @ 2005-01-03 22:39 UTC (permalink / raw)


Chong Yidong <cyd <at> stupidchicken.com> writes:

> Okay, then. Here is an amended patch. (The legal character set is more like
> [^- !#-'*+/-9=?A-Z^-~], but I see your point.)

I'm glad the quoting is properly handled- thanks. I originally filed these bugs.
I can't check the quoting one since my FLIM version has been updated to a 
version that quotes if necessary, but the second bug, expansion on @, is 
fixed with this patch (with this morning's CVS build).

JDO

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

end of thread, other threads:[~2005-01-03 22:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-01  8:21 Mailabbrev fixes [PATCH] cyd
2005-01-02  2:35 ` Miles Bader
2005-01-02  6:07   ` Chong Yidong
2005-01-03 22:39     ` John Owens

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).