dunn / homebrew-mode

Emacs minor mode for editing Homebrew formulae
GNU General Public License v3.0
15 stars 4 forks source link

Command to visit a local tap, with tab completion #7

Closed lassik closed 3 years ago

lassik commented 3 years ago
(defvar homebrew-taps-directory "/usr/local/Homebrew/Library/Taps/")

(defun homebrew-taps ()
  (let ((root homebrew-taps-directory) (taps '()))
    (dolist (user (directory-files root nil "^[^.]") taps)
      (dolist (repo (directory-files (concat root user) nil "^[^.]"))
        (let ((dot-git (concat root user "/" repo "/" ".git")))
          (when (file-exists-p dot-git)
            (let ((tap (concat user "/" repo)))
              (push tap taps))))))))

(defun homebrew-tap (tap)
  (interactive
   (list (completing-read "Visit Homebrew tap: " (homebrew-taps) nil t)))
  (when (string-blank-p tap) (error "No tap given"))
  (dired (concat (file-name-as-directory homebrew-taps-directory)
                 (file-name-as-directory tap)
                 (file-name-as-directory "Formula"))))

I find the above homebrew-tap command convenient. Would you be willing to add it to the package? (Feel free to refactor the code if you do.)

dunn commented 3 years ago

I rarely use this package anymore, but if it works and is useful to you I'd be happy to review a PR!

lassik commented 3 years ago

Implemented in #8 and #9.