0

I have create this little helper to easy jump to my last used git projects, I using magit-status-internal to open a status buffer and I set magit-display-buffer-function so that the status is open in a full frame, that works but I don't want the change to affect other magit calls should I just set magit-display-buffer-function to its previous value after the call to magit-status-internal or is there a better way to archive that.

(defun git-repository-p (d)
  (file-exists-p (concat d "/.git/config")))

(defun find-git-repository (d)
  (if (equal (file-name-directory (directory-file-name d)) d)
      nil
    (if (git-repository-p d)
        d
      (find-git-repository (file-name-directory (directory-file-name d))))))

(defvar recentf-list)

(defun counsel-recentp ()
  (interactive)
  (require 'recentf)
  (recentf-mode)
  (ivy-read "Recentp: " (delq nil (delete-dups (mapcar #'find-git-repository recentf-list)))
            :action (lambda (f)
                      (with-ivy-window
                        (setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-v1)
                        (magit-status-internal f)))
            :caller 'counsel-recentp))

1 Answer 1

2

Sorry, I haven't really tried this, but can't you just use a let binding instead of the call to setq?

(with-ivy-window
  (let ((magit-display-buffer-function 'magit-display-buffer-fullframe-status-v1))
    (magit-status-internal f)))

... something like that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.