mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
emacs: More address cleaning.
Remove outer single-quotes from the mailbox part. Allow for multiple sets of nested single and double quotes. Add more tests.
This commit is contained in:
parent
6bd3d8af54
commit
32d7b3aabd
2 changed files with 25 additions and 7 deletions
|
@ -316,15 +316,25 @@ unchanged ADDRESS if parsing fails."
|
|||
(t
|
||||
(setq p-address address)))
|
||||
|
||||
;; 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)))
|
||||
|
||||
;; Remove elements of the mailbox part that are not relevant for
|
||||
;; display, even if they are required during transport:
|
||||
;;
|
||||
;; Backslashes.
|
||||
(setq p-name (replace-regexp-in-string "\\\\" "" p-name)))
|
||||
(setq p-name (replace-regexp-in-string "\\\\" "" p-name))
|
||||
|
||||
;; Outer single and double quotes, which might be nested.
|
||||
(loop
|
||||
with start-of-loop
|
||||
do (setq start-of-loop p-name)
|
||||
|
||||
when (string-match "^\"\\(.*\\)\"$" p-name)
|
||||
do (setq p-name (match-string 1 p-name))
|
||||
|
||||
when (string-match "^'\\(.*\\)'$" p-name)
|
||||
do (setq p-name (match-string 1 p-name))
|
||||
|
||||
until (string= start-of-loop p-name)))
|
||||
|
||||
;; If the address is 'foo@bar.com <foo@bar.com>' then show just
|
||||
;; 'foo@bar.com'.
|
||||
|
|
|
@ -21,11 +21,19 @@
|
|||
"foo (at home) <foo@bar.com>"
|
||||
"foo [at home] <foo@bar.com>"
|
||||
"Foo Bar"
|
||||
"'Foo Bar' <foo@bar.com>"
|
||||
"\"'Foo Bar'\" <foo@bar.com>"
|
||||
"'\"Foo Bar\"' <foo@bar.com>"
|
||||
"'\"'Foo Bar'\"' <foo@bar.com>"
|
||||
"Fred Dibna \\[extraordinaire\\] <fred@dibna.com>"))
|
||||
(expected '("ДБ <db-uknot@stop.me.uk>"
|
||||
"foo (at home) <foo@bar.com>"
|
||||
"foo [at home] <foo@bar.com>"
|
||||
"Foo Bar"
|
||||
"Foo Bar <foo@bar.com>"
|
||||
"Foo Bar <foo@bar.com>"
|
||||
"Foo Bar <foo@bar.com>"
|
||||
"Foo Bar <foo@bar.com>"
|
||||
"Fred Dibna [extraordinaire] <fred@dibna.com>"))
|
||||
(output (mapcar #'notmuch-show-clean-address input)))
|
||||
(notmuch-test-expect-equal output expected)))
|
||||
|
|
Loading…
Reference in a new issue