[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

proposed `list-dynamic-libraries'

From: Juanma Barranquero
Subject: proposed `list-dynamic-libraries'
Date: Fri, 6 May 2011 17:46:42 +0200

Would be OK to install this code, which adds a list-dynamic-libraries command?

(Currently it is useful only on Windows, because it's the only
platform supporting dynamic loading on demand.)

If so, which source file would be best?  `list-processes' is in
simple.el, but I have a hard time understanding how can it be
considered a "basic editing command" ;-)


(defvar list-dynamic-libraries--loaded-only-p)

(defun list-dynamic-libraries--refresh ()
  "Recompute the list of dynamic libraries.
Internal use only."
  (setq tabulated-list-entries nil)
  (dolist (lib dynamic-library-alist)
    (let* ((id (car lib))
           (from (get id :loaded-from)))
      (when (or from
                (not list-dynamic-libraries--loaded-only-p))
        (push (list id (vector (symbol-name id)
                               (or from "")
                               (mapconcat 'identity (cdr lib) ", ")))

(defun list-dynamic-libraries (&optional loaded-only-p buffer)
  "Display a list of all dynamic libraries known to Emacs.
\(These are the libraries listed in `dynamic-library-alist'.)
If optional argument LOADED-ONLY-P (interactively, prefix arg)
is non-nil, only libraries already loaded are listed.
Optional argument BUFFER specifies a buffer to use, instead of
\"*Dynamic Libraries*\".
The return value is always nil."
  (interactive "P")
  (unless (bufferp buffer)
    (setq buffer (get-buffer-create "*Dynamic Libraries*")))
  (with-current-buffer buffer
    (setq tabulated-list-format
          (let ((max-id-len 0) (max-name-len 0))
            (dolist (lib dynamic-library-alist)
              (let ((id-len (length (symbol-name (car lib))))
                    (name-len (apply 'max (mapcar 'length (cdr lib)))))
                (when (> id-len max-id-len) (setq max-id-len id-len))
                (when (> name-len max-name-len) (setq max-name-len name-len))))
            (vector (list "Library" (1+ max-id-len) t)
                    (list "Loaded from" (1+ max-name-len) t)
                    (list "Candidate names" 0 t))))
    (setq tabulated-list-sort-key (cons "Library" nil))
    (add-hook 'tabulated-list-revert-hook
'list-dynamic-libraries--refresh nil t)
    (set (make-local-variable 'list-dynamic-libraries--loaded-only-p)
  (display-buffer buffer)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]