[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)
- [elpa] 264/352: Ensure case-fold-search=t in the example email detect function, (continued)
- [elpa] 264/352: Ensure case-fold-search=t in the example email detect function, Stefan Monnier, 2014/07/07
- [elpa] 277/352: Accept any value for case-fold option in customize system, Stefan Monnier, 2014/07/07
- [elpa] 268/352: Add a note for programmers about wcheck-marked-text-at, Stefan Monnier, 2014/07/07
- [elpa] 279/352: Remove examples from wcheck-language-data doc and replace it with URL, Stefan Monnier, 2014/07/07
- [elpa] 272/352: Revert "Emphasize wcheck-language-data-defaults in read-or-skip-faces doc", Stefan Monnier, 2014/07/07
- [elpa] 280/352: Add a table of contents to README file, Stefan Monnier, 2014/07/07
- [elpa] 276/352: Put quotes `...' around the example function add-word-to-dictionary, Stefan Monnier, 2014/07/07
- [elpa] 278/352: New feature: the only action menu item can be chosen automatically, Stefan Monnier, 2014/07/07
- [elpa] 269/352: Clarify that OPERATION-MODE can be also be nil, Stefan Monnier, 2014/07/07
- [elpa] 281/352: State that action-autoselect=nil is the default, Stefan Monnier, 2014/07/07
- [elpa] 282/352: Replace nested IF structure with COND in wcheck-actions,
Stefan Monnier <=
- [elpa] 284/352: Don't bind variable "language" unnecessarily, Stefan Monnier, 2014/07/07
- [elpa] 288/352: Document where "syntax" and "case-fold" are used, Stefan Monnier, 2014/07/07
- [elpa] 286/352: Make "syntax" and "case-fold" effective with "parser" function, Stefan Monnier, 2014/07/07
- [elpa] 283/352: Use org-mode markup in README and rename it to README.org, Stefan Monnier, 2014/07/07
- [elpa] 164/352: Järjestellään uudelleen funktiota wcheck-choose-suggestion-minibuffer, Stefan Monnier, 2014/07/07
- [elpa] 323/352: Fix bug in SIGNAL call: add FORMAT, Stefan Monnier, 2014/07/07
- [elpa] 329/352: Add another empty lines before headings, Stefan Monnier, 2014/07/07
- [elpa] 331/352: Remove "mode" from "Speck mode" link text, Stefan Monnier, 2014/07/07
- [elpa] 335/352: Fix typo in the doc string of wcheck-language-date, Stefan Monnier, 2014/07/07
- [elpa] 332/352: Add link to Marmalade package archive, Stefan Monnier, 2014/07/07