Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locate package configuration by name #191

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions use-package.el
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,8 @@ deferred until the prefix key sequence is pressed."
;; The main macro
;;

(defvar use-package--packages nil)

(defmacro use-package (name &rest args)
"Declare an Emacs package by specifying a group of configuration options.

Expand Down Expand Up @@ -1042,11 +1044,37 @@ this file. Usage:
(emacs-lisp-mode)
(insert (pp-to-string body)))
buf))))
body))))

(list
'progn body
`(let ((name (symbol-name ',name-symbol)))
(unless (assoc-string name use-package--packages)
(if ,load-file-name
(add-to-list 'use-package--packages
(cons name ,load-file-name))))))))))

(put 'use-package 'lisp-indent-function 'defun)

(defun use-package-locate (name)
"Locate package configuration by name."
(interactive
(list (funcall (if (fboundp 'ido-completing-read)
'ido-completing-read 'completing-read)
"Locate package: " use-package--packages)))
(let ((section (assoc-string name use-package--packages))
done)
(if (and section
(cdr section)
(file-exists-p (cdr section)))
(progn
(find-file (cdr section))
(goto-char (point-min))
(setq done t)
(re-search-forward
(concat "(\\s-*use-package\\s-+" (regexp-quote (car section))))
(recenter-top-bottom 0)))
(unless done
(message "Failed to locate package %s." name))))

(provide 'use-package)

;; Local Variables:
Expand Down