aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2011-05-09 17:52:57 +0200
committerJuanma Barranquero2011-05-09 17:52:57 +0200
commit5f4b1dfefa556c156b3eeb9664471bb5e86deb3b (patch)
tree62d462cf4554acd7a87956d617037c196746c5f0
parent394970663d323b8c9090e6bd8772502f59ee4d7a (diff)
downloademacs-5f4b1dfefa556c156b3eeb9664471bb5e86deb3b.tar.gz
emacs-5f4b1dfefa556c156b3eeb9664471bb5e86deb3b.zip
lisp/misc.el: Implement new command `list-dynamic-libraries'.
* misc.el (list-dynamic-libraries--loaded-only-p): New variable. (list-dynamic-libraries--refresh): New function. (list-dynamic-libraries): New command.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/misc.el56
2 files changed, 62 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a04afa93930..38bc7840712 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12011-05-09 Juanma Barranquero <lekktu@gmail.com>
2
3 * misc.el: Implement new command `list-dynamic-libraries'.
4 (list-dynamic-libraries--loaded-only-p): New variable.
5 (list-dynamic-libraries--refresh): New function.
6 (list-dynamic-libraries): New command.
7
12011-05-09 Chong Yidong <cyd@stupidchicken.com> 82011-05-09 Chong Yidong <cyd@stupidchicken.com>
2 9
3 * progmodes/compile.el (compilation-error-regexp-alist-alist): Fix 10 * progmodes/compile.el (compilation-error-regexp-alist-alist): Fix
diff --git a/lisp/misc.el b/lisp/misc.el
index 8a571f45144..e05173992b6 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -1,4 +1,4 @@
1;;; misc.el --- some nonstandard basic editing commands for Emacs 1;;; misc.el --- some nonstandard editing and utility commands for Emacs
2 2
3;; Copyright (C) 1989, 2001-2011 Free Software Foundation, Inc. 3;; Copyright (C) 1989, 2001-2011 Free Software Foundation, Inc.
4 4
@@ -129,6 +129,60 @@ variation of `C-x M-c M-butterfly' from url `http://xkcd.com/378/'."
129 (message "Well, then go to xkcd.com!") 129 (message "Well, then go to xkcd.com!")
130 (browse-url "http://xkcd.com/378/"))) 130 (browse-url "http://xkcd.com/378/")))
131 131
132;; A command to list dynamically loaded libraries. This useful in
133;; environments where dynamic-library-alist is used, i.e., Windows
134
135(defvar list-dynamic-libraries--loaded-only-p)
136(make-variable-buffer-local 'list-dynamic-libraries--loaded-only-p)
137
138(defun list-dynamic-libraries--refresh ()
139 "Recompute the list of dynamic libraries.
140Internal use only."
141 (setq tabulated-list-format ; recomputed because column widths can change
142 (let ((max-id-len 0) (max-name-len 0))
143 (dolist (lib dynamic-library-alist)
144 (let ((id-len (length (symbol-name (car lib))))
145 (name-len (apply 'max (mapcar 'length (cdr lib)))))
146 (when (> id-len max-id-len) (setq max-id-len id-len))
147 (when (> name-len max-name-len) (setq max-name-len name-len))))
148 (vector (list "Library" (1+ max-id-len) t)
149 (list "Loaded from" (1+ max-name-len) t)
150 (list "Candidate names" 0 t))))
151 (setq tabulated-list-entries nil)
152 (dolist (lib dynamic-library-alist)
153 (let* ((id (car lib))
154 (from (get id :loaded-from)))
155 (when (or from
156 (not list-dynamic-libraries--loaded-only-p))
157 (push (list id (vector (symbol-name id)
158 (or from "")
159 (mapconcat 'identity (cdr lib) ", ")))
160 tabulated-list-entries)))))
161
162;;;###autoload
163(defun list-dynamic-libraries (&optional loaded-only-p buffer)
164 "Display a list of all dynamic libraries known to Emacs.
165\(These are the libraries listed in `dynamic-library-alist'.)
166If optional argument LOADED-ONLY-P (interactively, prefix arg)
167is non-nil, only libraries already loaded are listed.
168Optional argument BUFFER specifies a buffer to use, instead of
169\"*Dynamic Libraries*\".
170The return value is always nil."
171 (interactive "P")
172 (unless (bufferp buffer)
173 (setq buffer (get-buffer-create "*Dynamic Libraries*")))
174 (with-current-buffer buffer
175 (tabulated-list-mode)
176 (setq tabulated-list-sort-key (cons "Library" nil))
177 (add-hook 'tabulated-list-revert-hook 'list-dynamic-libraries--refresh nil t)
178 (tabulated-list-init-header)
179 (setq list-dynamic-libraries--loaded-only-p loaded-only-p)
180 (list-dynamic-libraries--refresh)
181 (tabulated-list-print))
182 (display-buffer buffer)
183 nil)
184
185
132(provide 'misc) 186(provide 'misc)
133 187
134;;; misc.el ends here 188;;; misc.el ends here