Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

use cl-do instead of do #568

Closed
wants to merge 2 commits into from

2 participants

@tarsius
Owner

Sorry, I missed that one.

@tarsius
Owner

Cl advices dolist to be wrapped in an implicit nil-block which magit-find-buffer made use of. However sometimes that block was missing resulting in an error because cl-return was used outside any block. I am not sure why the block was missing but think it might have to do with using files compiled with other Emacs versions.

So instead of relying on an implicit block use cl-find-if.

tarsius added some commits
@tarsius tarsius use cl-do instead of do 3300976
@tarsius tarsius magit-find-buffer: use cl-find-if
Use `cl-find-if' instead of returning from `dolist' using cl's
implicit nil-block on first match.  The implicit nil-block did not
always work; apparently because byte compilation happened on older
Emacsen.
99ddcb1
@sigma
Owner

merged !

@sigma sigma closed this
@tarsius tarsius deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2013
  1. @tarsius

    use cl-do instead of do

    tarsius authored
  2. @tarsius

    magit-find-buffer: use cl-find-if

    tarsius authored
    Use `cl-find-if' instead of returning from `dolist' using cl's
    implicit nil-block on first match.  The implicit nil-block did not
    always work; apparently because byte compilation happened on older
    Emacsen.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 7 deletions.
  1. +1 −1  magit-key-mode.el
  2. +7 −6 magit.el
View
2  magit-key-mode.el
@@ -269,7 +269,7 @@ The user is prompted for the key."
(goto-char (point-min))
(let* ((exec (get-text-property (point) 'key-group-executor))
(exec-alist (if exec `((,exec . ,(point))) nil)))
- (do nil ((eobp) (nreverse exec-alist))
+ (cl-do nil ((eobp) (nreverse exec-alist))
(when (not (eq exec (get-text-property (point) 'key-group-executor)))
(setq exec (get-text-property (point) 'key-group-executor))
(when exec (push (cons exec (point)) exec-alist)))
View
13 magit.el
@@ -2563,12 +2563,13 @@ Please see the manual for a complete description of Magit.
(defun magit-find-buffer (submode &optional dir)
(let ((topdir (magit-get-top-dir (or dir default-directory))))
- (dolist (buf (buffer-list))
- (if (with-current-buffer buf
- (and (eq major-mode submode)
- default-directory
- (equal (expand-file-name default-directory) topdir)))
- (cl-return buf)))))
+ (cl-find-if (lambda (buf)
+ (with-current-buffer buf
+ (and (eq major-mode submode)
+ default-directory
+ (equal (expand-file-name default-directory)
+ topdir))))
+ (buffer-list))))
(defun magit-find-status-buffer (&optional dir)
(magit-find-buffer 'magit-status-mode dir))
Something went wrong with that request. Please try again.