X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/d1d6801eb4badab97416d0b6294e1920d0f90c3e..033f22ddadf6c11b4d35108f3c299692bb3bbc60:/lisp/misc.el?ds=sidebyside diff --git a/lisp/misc.el b/lisp/misc.el index 6f32a3eb90..8da289cb80 100644 --- a/lisp/misc.el +++ b/lisp/misc.el @@ -1,7 +1,6 @@ -;;; misc.el --- some nonstandard basic editing commands for Emacs +;;; misc.el --- some nonstandard editing and utility commands for Emacs -;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, -;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1989, 2001-2013 Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: convenience @@ -26,6 +25,9 @@ ;;; Code: +(eval-when-compile + (require 'tabulated-list)) + (defun copy-from-above-command (&optional arg) "Copy characters from previous nonblank line, starting just above point. Copy ARG characters, but not past the end of that line. @@ -54,7 +56,7 @@ The characters copied are inserted in the buffer before point." (setq string (concat string (buffer-substring (point) - (min (save-excursion (end-of-line) (point)) + (min (line-end-position) (+ n (point))))))) (insert string))) @@ -97,14 +99,14 @@ Ignores CHAR at point." (defun forward-to-word (arg) "Move forward until encountering the beginning of a word. With argument, do this that many times." - (interactive "p") + (interactive "^p") (or (re-search-forward (if (> arg 0) "\\W\\b" "\\b\\W") nil t arg) (goto-char (if (> arg 0) (point-max) (point-min))))) (defun backward-to-word (arg) "Move backward until encountering the end of a word. With argument, do this that many times." - (interactive "p") + (interactive "^p") (forward-to-word (- arg))) ;;;###autoload @@ -130,7 +132,72 @@ variation of `C-x M-c M-butterfly' from url `http://xkcd.com/378/'." (message "Well, then go to xkcd.com!") (browse-url "http://xkcd.com/378/"))) +;; A command to list dynamically loaded libraries. This useful in +;; environments where dynamic-library-alist is used, i.e., Windows + +(defvar list-dynamic-libraries--loaded-only-p) +(make-variable-buffer-local 'list-dynamic-libraries--loaded-only-p) + +(defun list-dynamic-libraries--loaded (from) + "Compute the \"Loaded from\" column. +Internal use only." + (if from + (let ((name (car from)) + (path (or (cdr from) ""))) + ;; This is a roundabout way to change the tooltip without + ;; having to replace the default printer function + (propertize name + 'display (propertize name + 'help-echo (concat "Loaded from: " path)))) + "")) + +(defun list-dynamic-libraries--refresh () + "Recompute the list of dynamic libraries. +Internal use only." + (setq tabulated-list-format ; recomputed because column widths can change + (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)))) + (tabulated-list-init-header) + (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) + (list-dynamic-libraries--loaded from) + (mapconcat 'identity (cdr lib) ", "))) + tabulated-list-entries))))) + +;;;###autoload +(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 + (tabulated-list-mode) + (setq tabulated-list-sort-key (cons "Library" nil)) + (add-hook 'tabulated-list-revert-hook 'list-dynamic-libraries--refresh nil t) + (setq list-dynamic-libraries--loaded-only-p loaded-only-p) + (list-dynamic-libraries--refresh) + (tabulated-list-print)) + (display-buffer buffer) + nil) + (provide 'misc) -;; arch-tag: 908f7884-c19e-4388-920c-9cfa425e449b ;;; misc.el ends here