]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Another special case for `notmuch-show-clean-address'.
authorDavid Edmondson <dme@dme.org>
Wed, 25 Jan 2012 13:54:00 +0000 (13:54 +0000)
committerDavid Bremner <bremner@debian.org>
Fri, 27 Jan 2012 11:59:40 +0000 (07:59 -0400)
Remove backslashes.

emacs/notmuch-show.el
test/emacs-address-cleaning.el

index acc2f5e10b2249c28e1945c012e93e1e135d68c7..84ac6249b5df21d70993080d3287da2d55b3ffec 100644 (file)
@@ -315,11 +315,15 @@ unchanged ADDRESS if parsing fails."
        (t
        (setq p-address address)))
 
        (t
        (setq p-address address)))
 
-      ;; Remove outer double quotes. They might be required during
-      ;; transport, but we don't need to see them.
-      (when (and p-name
-                (string-match "^\"\\(.*\\)\"$" p-name))
-       (setq p-name (match-string 1 p-name)))
+      ;; Remove elements of the mailbox part that are not relevant for
+      ;; display, even if they are required during transport.
+      (when p-name
+       ;; Outer double quotes.
+       (when (string-match "^\"\\(.*\\)\"$" p-name)
+         (setq p-name (match-string 1 p-name)))
+
+       ;; Backslashes.
+       (setq p-name (replace-regexp-in-string "\\\\" "" p-name)))
 
       ;; If the address is 'foo@bar.com <foo@bar.com>' then show just
       ;; 'foo@bar.com'.
 
       ;; If the address is 'foo@bar.com <foo@bar.com>' then show just
       ;; 'foo@bar.com'.
index 19e9e055e37241dbbb4a20b035c31be445a3cd95..3b0b109bbb93d445125752cfd2645370921e9994 100644 (file)
   (let* ((input '("ДБ <db-uknot@stop.me.uk>"
                  "foo (at home) <foo@bar.com>"
                  "foo [at home] <foo@bar.com>"
   (let* ((input '("ДБ <db-uknot@stop.me.uk>"
                  "foo (at home) <foo@bar.com>"
                  "foo [at home] <foo@bar.com>"
-                 "Foo Bar"))
+                 "Foo Bar"
+                 "Fred Dibna \\[extraordinaire\\] <fred@dibna.com>"))
         (expected '("ДБ <db-uknot@stop.me.uk>"
                     "foo (at home) <foo@bar.com>"
                     "foo [at home] <foo@bar.com>"
         (expected '("ДБ <db-uknot@stop.me.uk>"
                     "foo (at home) <foo@bar.com>"
                     "foo [at home] <foo@bar.com>"
-                    "Foo Bar"))
+                    "Foo Bar"
+                    "Fred Dibna [extraordinaire] <fred@dibna.com>"))
         (output (mapcar #'notmuch-show-clean-address input)))
     (notmuch-test-expect-equal output expected)))
         (output (mapcar #'notmuch-show-clean-address input)))
     (notmuch-test-expect-equal output expected)))