[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master dc219b3 12/57: Add counsel-load-library
From: |
Oleh Krehel |
Subject: |
[elpa] master dc219b3 12/57: Add counsel-load-library |
Date: |
Tue, 19 May 2015 14:21:23 +0000 |
branch: master
commit dc219b312075f65d6987071352a663d526b3320c
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add counsel-load-library
* counsel.el (counsel-directory-parent): New defun.
(counsel-load-library): New command.
Improve on `load-library':
- don't consider .*elc or .*pkg.elc?, they're usually useless
- resolve duplicates in a similar way to uniquify (prepend parent directory)
- allow to jump-to-library with "C-." (see `counsel-describe-map')
---
counsel.el | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/counsel.el b/counsel.el
index 7ee63fc..a0e6813 100644
--- a/counsel.el
+++ b/counsel.el
@@ -260,6 +260,42 @@
(delete-region (car bnd) (cdr bnd)))
(insert res))))
+(defun counsel-directory-parent (dir)
+ "Return the directory parent of directory DIR."
+ (concat (file-name-nondirectory
+ (directory-file-name dir)) "/"))
+
+(defun counsel-load-library ()
+ "Load a selected the Emacs Lisp library.
+The libraries are offered from `load-path'."
+ (interactive)
+ (let ((dirs load-path)
+ (suffix (concat (regexp-opt '(".el" ".el.gz") t) "\\'"))
+ (cands (make-hash-table :test #'equal))
+ short-name
+ old-dir)
+ (dolist (dir dirs)
+ (when (file-directory-p dir)
+ (dolist (file (file-name-all-completions "" dir))
+ (when (string-match suffix file)
+ (unless (string-match "pkg.elc?$" file)
+ (setq short-name (substring file 0 (match-beginning 0)))
+ (if (setq old-dir (gethash short-name cands))
+ (progn
+ (remhash short-name cands)
+ ;; assume going up directory once will resolve name clash
+ (puthash (concat (counsel-directory-parent old-dir)
+ short-name)
+ old-dir cands)
+ (puthash (concat (counsel-directory-parent dir)
+ short-name)
+ dir cands))
+ (puthash short-name dir cands)))))))
+ (ivy-read "Load library: " (hash-table-keys cands)
+ :action (lambda ()
+ (load-library ivy--current))
+ :keymap counsel-describe-map)))
+
(provide 'counsel)
;;; counsel.el ends here
- [elpa] master updated (e559638 -> 155f2a6), Oleh Krehel, 2015/05/19
- [elpa] master ca91c88 01/57: Add an option for out-of-order matching, Oleh Krehel, 2015/05/19
- [elpa] master 4ad1ab2 02/57: ivy.el (ivy-tab-space): New defcustom, Oleh Krehel, 2015/05/19
- [elpa] master 41bc3e8 03/57: Ignore case for "TAB", Oleh Krehel, 2015/05/19
- [elpa] master 2c39e10 04/57: "TAB" shouldn't delete input when no candidate, Oleh Krehel, 2015/05/19
- [elpa] master 2d7f287 09/57: Improve "TAB" interaction with `confirm-nonexistent-file-or-buffer', Oleh Krehel, 2015/05/19
- [elpa] master 03ab827 07/57: Merge ivy--collection into ivy-last, Oleh Krehel, 2015/05/19
- [elpa] master dc219b3 12/57: Add counsel-load-library,
Oleh Krehel <=
- [elpa] master 8b08cc0 08/57: ivy.el (ivy-done): Simplify and improve, Oleh Krehel, 2015/05/19
- [elpa] master cd083cc 18/57: Add swiper -> avy finalizer, Oleh Krehel, 2015/05/19
- [elpa] master f2a0966 16/57: Add ivy-partial: partial complete without exiting, Oleh Krehel, 2015/05/19
- [elpa] master 386184b 14/57: Merge ivy--update-fn into ivy-last, Oleh Krehel, 2015/05/19
- [elpa] master c5fce64 05/57: Make "TAB" switch directories properly, Oleh Krehel, 2015/05/19
- [elpa] master 6784185 17/57: Allow to use "^" in swiper, Oleh Krehel, 2015/05/19
- [elpa] master fb3fce9 13/57: Add parents using 'display for `counsel-load-library', Oleh Krehel, 2015/05/19
- [elpa] master 5601653 06/57: Require dired when completing file names, Oleh Krehel, 2015/05/19
- [elpa] master 4a7ba2f 15/57: Try to prevent the resize of minibuffer window, Oleh Krehel, 2015/05/19
- [elpa] master 5a451a9 26/57: ivy.el (ivy-read): Add a re-builder argument, Oleh Krehel, 2015/05/19