emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 282/352: Replace nested IF structure with COND in wcheck-actions


From: Stefan Monnier
Subject: [elpa] 282/352: Replace nested IF structure with COND in wcheck-actions
Date: Mon, 07 Jul 2014 14:04:58 +0000

monnier pushed a commit to branch master
in repository elpa.

commit f742b6ecfe2fce3c73db883d79e2d37c3ee6fac4
Author: Teemu Likonen <address@hidden>
Date:   Sat Jul 2 20:10:09 2011 +0300

    Replace nested IF structure with COND in wcheck-actions
    
    Also optimize (= 1 (length actions)) to (null (cdr actions)). There's no
    need to traverse down the whole list.
---
 wcheck-mode.el |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/wcheck-mode.el b/wcheck-mode.el
index c437d09..5e185fc 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -1825,18 +1825,20 @@ any kind of actions, though."
       (let ((marked-text (or (wcheck-marked-text-at pos)
                              (wcheck-marked-text-at (1- pos))))
             (return-value nil))
+
         (if (not marked-text)
             (signal 'wcheck-action-error "There is no marked text here")
           (let* ((start (copy-marker (aref marked-text 1)))
                  (end (copy-marker (aref marked-text 2)))
                  (actions (wcheck-get-actions marked-text))
-                 (choice (if (and (wcheck-query-language-data
-                                   (aref marked-text 4) 'action-autoselect)
-                                  (= 1 (length actions)))
-                             (cdr (car actions))
-                           (if (and (display-popup-menus-p) event)
-                               (wcheck-choose-action-popup actions event)
-                             (wcheck-choose-action-minibuffer actions)))))
+                 (choice (cond ((and (null (cdr actions))
+                                     (wcheck-query-language-data
+                                      (aref marked-text 4) 'action-autoselect))
+                                (cdar actions))
+                               ((and event (display-popup-menus-p))
+                                (wcheck-choose-action-popup actions event))
+                               (t (wcheck-choose-action-minibuffer actions)))))
+
             (cond ((and (stringp choice)
                         (markerp start)
                         (markerp end))
@@ -1850,6 +1852,7 @@ any kind of actions, though."
                   ((functionp choice)
                    (funcall choice marked-text)
                    (setq return-value choice)))
+
             (if (markerp start) (set-marker start nil))
             (if (markerp end) (set-marker end nil))))
         return-value)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]