diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2016-02-23 14:45:59 +1100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2016-02-23 14:45:59 +1100 |
commit | a77c6799c1f3ae30c8bbf26aa376f52c33cd554f (patch) | |
tree | 703ec741f3f169caaf977865e36dbb65cbf7bf82 | |
parent | 6f0498bf290cbe066036f8bfe0d09ad99ddaab03 (diff) | |
download | emacs-a77c6799c1f3ae30c8bbf26aa376f52c33cd554f.tar.gz emacs-a77c6799c1f3ae30c8bbf26aa376f52c33cd554f.tar.bz2 emacs-a77c6799c1f3ae30c8bbf26aa376f52c33cd554f.zip |
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.
-rw-r--r-- | lisp/gnus/message.el | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index cc147b3a8f3..a23e3ba5114 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -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/ |