branch: elpa/helm
commit 58e7d4a5af3e4607bf8315c2db456831efd63930
Author: Thierry Volpiatto <thie...@posteo.net>
Commit: Thierry Volpiatto <thie...@posteo.net>

    Replace cl-defun in places where cl-return* is used
---
 helm-core.el  | 135 +++++++++++++++++++++++++-------------------------
 helm-epa.el   |  25 +++++-----
 helm-utils.el | 157 +++++++++++++++++++++++++++++-----------------------------
 3 files changed, 160 insertions(+), 157 deletions(-)

diff --git a/helm-core.el b/helm-core.el
index 2ce80b2c15..2fd7652923 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -7394,7 +7394,7 @@ Argument ACTION can be a symbol or a list of actions."
 (defun helm-initialize-persistent-action ()
   (set (make-local-variable 'helm-persistent-action-display-window) nil))
 
-(cl-defun helm-execute-persistent-action (&optional attr split)
+(defun helm-execute-persistent-action (&optional attr split)
   "Perform the associated action ATTR without quitting helm.
 
 Arg ATTR default will be `persistent-action' or
@@ -7410,72 +7410,73 @@ in only one window, the helm window is split to display
 maintain visibility.  The argument SPLIT can be used to force
 splitting inconditionally, it is unused currently."
   (interactive)
-  (with-suppressed-warnings ((obsolete special-display-regexps)
-                             (obsolete special-display-buffer-names))
-    (with-helm-alive-p
-      (let ((source (helm-get-current-source)))
-        (unless attr
-          (setq attr (or (car (assq 'persistent-action source))
-                         (car (assq 'persistent-action-if source)))))
-        (helm-log "helm-execute-persistent-action" "executing 
persistent-action")
-        (let* ((selection (and source (helm-get-selection nil nil source)))
-               (attr-val (if (eq attr 'persistent-action-if)
-                             (funcall (assoc-default attr source) selection)
-                           (assoc-default attr source)))
-               ;; If attr value is a cons, use its car as persistent function.
-               (fn       (if (and (consp attr-val)
-                                  ;; maybe a lambda.
-                                  (not (functionp attr-val)))
-                             (car attr-val) attr-val))
-               ;; And its cdr to decide if helm window should be splitted.
-               (no-split (and (consp attr-val)
-                              (not (functionp attr-val))
-                              (cdr attr-val)))
-               ;; Is next-window (from helm-window) a suitable window for PA?
-               (no-suitable-win
-                (helm-aand (not helm--buffer-in-new-frame-p)
-                           (get-buffer-window helm-current-buffer)
-                           (or (window-dedicated-p it)
-                               (window-parameter it 'window-side))))
-               (cursor-in-echo-area t)
-               mode-line-in-non-selected-windows)
-          (progn
-            (when (and helm-onewindow-p (null no-split)
-                       (null helm--buffer-in-new-frame-p))
-              (helm-toggle-full-frame))
-            (when (eq fn 'ignore)
-              (cl-return-from helm-execute-persistent-action nil))
-            (when source
-              (with-helm-window
-                (save-selected-window
-                  ;; FIXME: Simplify SPLIT behavior, it is a mess currently.
-                  (if no-split
-                      (helm-select-persistent-action-window :split 'never)
-                    (helm-select-persistent-action-window
-                     :split (or split helm-onewindow-p no-suitable-win)))
-                  (helm-log "helm-execute-persistent-action"
-                            "current-buffer = %S" (current-buffer))
-                  (let ((helm-in-persistent-action t)
-                        (display-buffer-alist '((".*" 
(display-buffer-same-window))))
-                        display-buffer-function pop-up-windows pop-up-frames
-                        special-display-regexps special-display-buffer-names)
-                    (helm-execute-selection-action-1
-                     selection (or fn (helm-get-actions-from-current-source 
source)) t)
-                    (unless (helm-action-window)
-                      (helm-log-run-hook "helm-execute-persistent-action"
-                                         'helm-after-persistent-action-hook)))
-                  ;; A typical case is when a persistent action delete
-                  ;; the buffer already displayed in
-                  ;; `helm-persistent-action-display-window' and 
`helm-full-frame'
-                  ;; is enabled, we end up with the `helm-buffer'
-                  ;; displayed in two windows.
-                  (when (and helm-onewindow-p
-                             (> (length (window-list)) 1)
-                             (equal (buffer-name
-                                     (window-buffer
-                                      helm-persistent-action-display-window))
-                                    (helm-buffer-get)))
-                    (delete-other-windows)))))))))))
+  (catch 'ignore
+    (with-suppressed-warnings ((obsolete special-display-regexps)
+                               (obsolete special-display-buffer-names))
+      (with-helm-alive-p
+        (let ((source (helm-get-current-source)))
+          (unless attr
+            (setq attr (or (car (assq 'persistent-action source))
+                           (car (assq 'persistent-action-if source)))))
+          (helm-log "helm-execute-persistent-action" "executing 
persistent-action")
+          (let* ((selection (and source (helm-get-selection nil nil source)))
+                 (attr-val (if (eq attr 'persistent-action-if)
+                               (funcall (assoc-default attr source) selection)
+                             (assoc-default attr source)))
+                 ;; If attr value is a cons, use its car as persistent 
function.
+                 (fn       (if (and (consp attr-val)
+                                    ;; maybe a lambda.
+                                    (not (functionp attr-val)))
+                               (car attr-val) attr-val))
+                 ;; And its cdr to decide if helm window should be splitted.
+                 (no-split (and (consp attr-val)
+                                (not (functionp attr-val))
+                                (cdr attr-val)))
+                 ;; Is next-window (from helm-window) a suitable window for PA?
+                 (no-suitable-win
+                  (helm-aand (not helm--buffer-in-new-frame-p)
+                             (get-buffer-window helm-current-buffer)
+                             (or (window-dedicated-p it)
+                                 (window-parameter it 'window-side))))
+                 (cursor-in-echo-area t)
+                 mode-line-in-non-selected-windows)
+            (progn
+              (when (and helm-onewindow-p (null no-split)
+                         (null helm--buffer-in-new-frame-p))
+                (helm-toggle-full-frame))
+              (when (eq fn 'ignore)
+                (throw 'ignore nil))
+              (when source
+                (with-helm-window
+                  (save-selected-window
+                    ;; FIXME: Simplify SPLIT behavior, it is a mess currently.
+                    (if no-split
+                        (helm-select-persistent-action-window :split 'never)
+                      (helm-select-persistent-action-window
+                       :split (or split helm-onewindow-p no-suitable-win)))
+                    (helm-log "helm-execute-persistent-action"
+                              "current-buffer = %S" (current-buffer))
+                    (let ((helm-in-persistent-action t)
+                          (display-buffer-alist '((".*" 
(display-buffer-same-window))))
+                          display-buffer-function pop-up-windows pop-up-frames
+                          special-display-regexps special-display-buffer-names)
+                      (helm-execute-selection-action-1
+                       selection (or fn (helm-get-actions-from-current-source 
source)) t)
+                      (unless (helm-action-window)
+                        (helm-log-run-hook "helm-execute-persistent-action"
+                                           
'helm-after-persistent-action-hook)))
+                    ;; A typical case is when a persistent action delete
+                    ;; the buffer already displayed in
+                    ;; `helm-persistent-action-display-window' and 
`helm-full-frame'
+                    ;; is enabled, we end up with the `helm-buffer'
+                    ;; displayed in two windows.
+                    (when (and helm-onewindow-p
+                               (> (length (window-list)) 1)
+                               (equal (buffer-name
+                                       (window-buffer
+                                        helm-persistent-action-display-window))
+                                      (helm-buffer-get)))
+                      (delete-other-windows))))))))))))
 (put 'helm-execute-persistent-action 'helm-only t)
 
 (cl-defun helm-persistent-action-display-window (&key split)
diff --git a/helm-epa.el b/helm-epa.el
index 4e938b8de6..3bd03dbfbd 100644
--- a/helm-epa.el
+++ b/helm-epa.el
@@ -86,19 +86,20 @@
                                   uid 'face 'font-lock-warning-face))
                          key)))
 
-(cl-defun helm-epa--select-keys (prompt keys)
+(defun helm-epa--select-keys (prompt keys)
   "A helm replacement for `epa--select-keys'."
-  (let ((result (helm :sources (helm-make-source "Epa select keys" 'helm-epa
-                                 :candidates (lambda ()
-                                               (helm-epa-get-key-list keys))
-                                 :action (lambda (_candidate)
-                                           (helm-marked-candidates)))
-                      :prompt (and prompt (helm-epa--format-prompt prompt))
-                      :buffer "*helm epa*")))
-    (if (or (equal result "") (null result))
-        (cl-return-from helm-epa--select-keys
-          (error "No keys selected, aborting"))
-      result)))
+  (catch 'nokey
+    (let ((result (helm :sources (helm-make-source "Epa select keys" 'helm-epa
+                                   :candidates (lambda ()
+                                                 (helm-epa-get-key-list keys))
+                                   :action (lambda (_candidate)
+                                             (helm-marked-candidates)))
+                        :prompt (and prompt (helm-epa--format-prompt prompt))
+                        :buffer "*helm epa*")))
+      (if (or (equal result "") (null result))
+          (throw 'nokey
+            (error "No keys selected, aborting"))
+        result))))
 
 (defun helm-epa--format-prompt (prompt)
   (let ((split (split-string prompt "\n")))
diff --git a/helm-utils.el b/helm-utils.el
index 29d6ec8200..e1b567871d 100644
--- a/helm-utils.el
+++ b/helm-utils.el
@@ -909,7 +909,7 @@ Inlined here for compatibility."
 (defvar helm-match-line-overlay nil)
 (defvar helm--match-item-overlays nil)
 
-(cl-defun helm-highlight-current-line (&optional start end buf face)
+(defun helm-highlight-current-line (&optional start end buf face)
   "Highlight current line and all matching items around it.
 
 The number of lines around matched line where the matching items are
@@ -918,83 +918,84 @@ When the variable `helm-highlight-only-all-matches' is 
non nil only
 the lines containing all matches (in case of multi match) are highlighted.
 
 Optional arguments START, END and FACE are only here for debugging purpose."
-  (let* ((start (or start (line-beginning-position)))
-         (end (or end (1+ (line-end-position))))
-         start-match end-match
-         (args (list start end buf))
-         (case-fold-search (if helm-alive-p
-                               (helm-set-case-fold-search)
-                             case-fold-search)))
-    ;; Highlight the current line.
-    (if (not helm-match-line-overlay)
-        (setq helm-match-line-overlay (apply 'make-overlay args))
-      (apply 'move-overlay helm-match-line-overlay args))
-    (overlay-put helm-match-line-overlay
-                 'face (or face 'helm-selection-line))
-    ;; Now highlight matches only if we are in helm session, we are
-    ;; maybe coming from helm-grep-mode or helm-moccur-mode buffers.
-    (when helm-alive-p
-      (helm-acase helm-highlight-matches-around-point-max-lines
-        ;; Next 2 clauses must precede others otherwise
-        ;; `helm-highlight-matches-around-point-max-lines' is
-        ;; compared as a number by other clauses and return an error.
-        (never (cl-return-from helm-highlight-current-line))
-        ((dst* (x . y))
-         (setq start-match (save-excursion (forward-line (- x)) (pos-bol))
-               end-match   (save-excursion (forward-line y) (pos-bol))))
-        ((guard* (or (null it) (zerop it)))
-         (setq start-match start
-               end-match   end))
-        ((guard* (< it 0))
-         (setq start-match (save-excursion (forward-line it) (pos-bol))
-               end-match   start))
-        ((guard* (> it 0))
-         (setq start-match start
-               end-match   (save-excursion (forward-line it) (pos-bol)))))
-      (catch 'empty-line
-        (let* ((regex-list (helm-remove-if-match
-                            "\\`!" (helm-mm-split-pattern
-                                    (if (with-helm-buffer
-                                          ;; Needed for highlighting AG 
matches.
-                                          (assq 'pcre 
(helm-get-current-source)))
-                                        (helm--translate-pcre-to-elisp 
helm-input)
-                                      helm-input))))
-               (num-regex (length regex-list)))
-          (save-excursion
-            (goto-char start-match)
-            (while (< (point) end-match)
-              (let* ((start-line (line-beginning-position))
-                     (end-line   (line-end-position))
-                     all-matches)
-                (dolist (r regex-list)
-                  (let ((match-list '()))
-                    (save-excursion
-                      (goto-char start-line)
-                      (while (condition-case _err
-                                 (and (not (= start-line end-line))
-                                      (if helm-migemo-mode
-                                          (helm-mm-migemo-forward r end-line t)
-                                        (re-search-forward r end-line t)))
-                               (invalid-regexp nil))
-                        (let ((s (match-beginning 0))
-                              (e (match-end 0)))
-                          (if (= s e)
-                              (throw 'empty-line nil)
-                            (push (cons s e) match-list)))))
-                    (when match-list
-                      (push match-list all-matches))))
-                (when (and all-matches
-                           (or (not helm-highlight-only-all-matches)
-                               (eql (length all-matches) num-regex)))
-                  (cl-loop for ml in all-matches
-                           do (cl-loop for (s . e) in ml
-                                       for ov = (make-overlay s e)
-                                       do (progn
-                                            (push ov helm--match-item-overlays)
-                                            (overlay-put ov 'face 
'helm-match-item)
-                                            (overlay-put ov 'priority 1))))))
-              (forward-line 1))))))
-    (recenter)))
+  (catch 'never
+    (let* ((start (or start (line-beginning-position)))
+           (end (or end (1+ (line-end-position))))
+           start-match end-match
+           (args (list start end buf))
+           (case-fold-search (if helm-alive-p
+                                 (helm-set-case-fold-search)
+                               case-fold-search)))
+      ;; Highlight the current line.
+      (if (not helm-match-line-overlay)
+          (setq helm-match-line-overlay (apply 'make-overlay args))
+        (apply 'move-overlay helm-match-line-overlay args))
+      (overlay-put helm-match-line-overlay
+                   'face (or face 'helm-selection-line))
+      ;; Now highlight matches only if we are in helm session, we are
+      ;; maybe coming from helm-grep-mode or helm-moccur-mode buffers.
+      (when helm-alive-p
+        (helm-acase helm-highlight-matches-around-point-max-lines
+          ;; Next 2 clauses must precede others otherwise
+          ;; `helm-highlight-matches-around-point-max-lines' is
+          ;; compared as a number by other clauses and return an error.
+          (never (throw 'never nil))
+          ((dst* (x . y))
+           (setq start-match (save-excursion (forward-line (- x)) (pos-bol))
+                 end-match   (save-excursion (forward-line y) (pos-bol))))
+          ((guard* (or (null it) (zerop it)))
+           (setq start-match start
+                 end-match   end))
+          ((guard* (< it 0))
+           (setq start-match (save-excursion (forward-line it) (pos-bol))
+                 end-match   start))
+          ((guard* (> it 0))
+           (setq start-match start
+                 end-match   (save-excursion (forward-line it) (pos-bol)))))
+        (catch 'empty-line
+          (let* ((regex-list (helm-remove-if-match
+                              "\\`!" (helm-mm-split-pattern
+                                      (if (with-helm-buffer
+                                            ;; Needed for highlighting AG 
matches.
+                                            (assq 'pcre 
(helm-get-current-source)))
+                                          (helm--translate-pcre-to-elisp 
helm-input)
+                                        helm-input))))
+                 (num-regex (length regex-list)))
+            (save-excursion
+              (goto-char start-match)
+              (while (< (point) end-match)
+                (let* ((start-line (line-beginning-position))
+                       (end-line   (line-end-position))
+                       all-matches)
+                  (dolist (r regex-list)
+                    (let ((match-list '()))
+                      (save-excursion
+                        (goto-char start-line)
+                        (while (condition-case _err
+                                   (and (not (= start-line end-line))
+                                        (if helm-migemo-mode
+                                            (helm-mm-migemo-forward r end-line 
t)
+                                          (re-search-forward r end-line t)))
+                                 (invalid-regexp nil))
+                          (let ((s (match-beginning 0))
+                                (e (match-end 0)))
+                            (if (= s e)
+                                (throw 'empty-line nil)
+                              (push (cons s e) match-list)))))
+                      (when match-list
+                        (push match-list all-matches))))
+                  (when (and all-matches
+                             (or (not helm-highlight-only-all-matches)
+                                 (eql (length all-matches) num-regex)))
+                    (cl-loop for ml in all-matches
+                             do (cl-loop for (s . e) in ml
+                                         for ov = (make-overlay s e)
+                                         do (progn
+                                              (push ov 
helm--match-item-overlays)
+                                              (overlay-put ov 'face 
'helm-match-item)
+                                              (overlay-put ov 'priority 1))))))
+                (forward-line 1))))))
+      (recenter))))
 
 (defun helm--translate-pcre-to-elisp (regexp)
   "Should translate pcre REGEXP to elisp regexp.

Reply via email to