message-strip-subject-trailing-was: Refactor
* lisp/gnus/message.el (message-strip-subject-trailing-was): Refactor the function replacing sequence of `if' calls with a mixture of `or' and `and' calls instead. This makes it shorter and containing less internal state thus easier to follow.
This commit is contained in:
parent
6f0498bf29
commit
a77c6799c1
1 changed files with 20 additions and 27 deletions
|
@ -2197,33 +2197,26 @@ charset: "
|
|||
"Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
|
||||
Leading \"Re: \" is not stripped by this function. Use the function
|
||||
`message-strip-subject-re' for this."
|
||||
(let* ((query message-subject-trailing-was-query)
|
||||
(new) (found))
|
||||
(setq found
|
||||
(string-match
|
||||
(if (eq query 'ask)
|
||||
message-subject-trailing-was-ask-regexp
|
||||
message-subject-trailing-was-regexp)
|
||||
subject))
|
||||
(if found
|
||||
(setq new (substring subject 0 (match-beginning 0))))
|
||||
(if (or (not found) (eq query nil))
|
||||
subject
|
||||
(if (eq query 'ask)
|
||||
(if (message-y-or-n-p
|
||||
"Strip `(was: <old subject>)' in subject? " t
|
||||
(concat
|
||||
"Strip `(was: <old subject>)' in subject "
|
||||
"and use the new one instead?\n\n"
|
||||
"Current subject is: \""
|
||||
subject "\"\n\n"
|
||||
"New subject would be: \""
|
||||
new "\"\n\n"
|
||||
"See the variable `message-subject-trailing-was-query' "
|
||||
"to get rid of this query."
|
||||
))
|
||||
new subject)
|
||||
new))))
|
||||
(or
|
||||
(let ((query message-subject-trailing-was-query) new)
|
||||
(and query
|
||||
(string-match (if (eq query 'ask)
|
||||
message-subject-trailing-was-ask-regexp
|
||||
message-subject-trailing-was-regexp)
|
||||
subject)
|
||||
(setq new (substring subject 0 (match-beginning 0)))
|
||||
(or (not (eq query 'ask))
|
||||
(message-y-or-n-p
|
||||
"Strip `(was: <old subject>)' in subject? " t
|
||||
(concat
|
||||
"Strip `(was: <old subject>)' in subject "
|
||||
"and use the new one instead?\n\n"
|
||||
"Current subject is: \"" subject "\"\n\n"
|
||||
"New subject would be: \"" new "\"\n\n"
|
||||
"See the variable `message-subject-trailing-was-query' "
|
||||
"to get rid of this query.")))
|
||||
new))
|
||||
subject))
|
||||
|
||||
;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue