diff options
| author | Juanma Barranquero | 2003-03-31 20:22:58 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-03-31 20:22:58 +0000 |
| commit | 8e86406878ccfca4f3a2deaa7c2e76ea71532c15 (patch) | |
| tree | 9930716c71c5074493149c19525c9c37cc28a4a8 | |
| parent | 3d29fd3365f0c6d9862e265f1bd934c974935b41 (diff) | |
| download | emacs-8e86406878ccfca4f3a2deaa7c2e76ea71532c15.tar.gz emacs-8e86406878ccfca4f3a2deaa7c2e76ea71532c15.zip | |
(describe-minor-mode, describe-minor-mode-from-indicator,
lookup-minor-mode-from-indicator): New functions.
| -rw-r--r-- | lisp/help.el | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/lisp/help.el b/lisp/help.el index 8488e6939c0..41a5a890c67 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -611,6 +611,74 @@ For minor modes, see following pages.\n\n")) | |||
| 611 | (setq minor-modes (cdr minor-modes)))) | 611 | (setq minor-modes (cdr minor-modes)))) |
| 612 | (print-help-return-message)))) | 612 | (print-help-return-message)))) |
| 613 | 613 | ||
| 614 | (defun describe-minor-mode (minor-mode) | ||
| 615 | "Display documentation of a minor mode given as MINOR-MODE." | ||
| 616 | (interactive (list (intern (completing-read | ||
| 617 | "Minor mode: " | ||
| 618 | (delete nil (mapcar | ||
| 619 | (function (lambda (x) | ||
| 620 | (if (eval (car x)) | ||
| 621 | (symbol-name (car x))))) | ||
| 622 | minor-mode-alist)))))) | ||
| 623 | (if (fboundp minor-mode) | ||
| 624 | (describe-function minor-mode) | ||
| 625 | (describe-variable minor-mode))) | ||
| 626 | |||
| 627 | (defun describe-minor-mode-from-indicator (indicator) | ||
| 628 | "Display documentation of a minor mode specified by INDICATOR." | ||
| 629 | (interactive (list | ||
| 630 | (completing-read | ||
| 631 | "Minor mode indicator: " | ||
| 632 | (delete nil | ||
| 633 | (mapcar | ||
| 634 | #'(lambda (x) | ||
| 635 | (if (eval (car x)) | ||
| 636 | (let ((i (expand-minor-mode-indicator-object (cadr x)))) | ||
| 637 | (if (and (< 0 (length i)) | ||
| 638 | (string= " " (substring i 0 1))) | ||
| 639 | (substring i 1) | ||
| 640 | i)))) | ||
| 641 | minor-mode-alist))))) | ||
| 642 | (let ((minor-mode (lookup-minor-mode-from-indicator indicator))) | ||
| 643 | (if minor-mode | ||
| 644 | (describe-minor-mode minor-mode) | ||
| 645 | (error "Cannot find minor mode for `%s'" indicator)))) | ||
| 646 | |||
| 647 | (defun lookup-minor-mode-from-indicator (indicator) | ||
| 648 | "Return a minor mode symbol from its indicator on the modeline." | ||
| 649 | (if (and (< 0 (length indicator)) | ||
| 650 | (not (string= " " (substring indicator 0 1)))) | ||
| 651 | (setq indicator (concat " " indicator))) | ||
| 652 | (let ((minor-modes minor-mode-alist) | ||
| 653 | result) | ||
| 654 | (while minor-modes | ||
| 655 | (let* ((minor-mode (car (car minor-modes))) | ||
| 656 | (anindicator (car (cdr (car minor-modes))))) | ||
| 657 | (setq anindicator (expand-minor-mode-indicator-object anindicator)) | ||
| 658 | (if (and (stringp anindicator) | ||
| 659 | (string= anindicator indicator)) | ||
| 660 | (setq result minor-mode | ||
| 661 | minor-modes nil) | ||
| 662 | (setq minor-modes (cdr minor-modes))))) | ||
| 663 | result)) | ||
| 664 | |||
| 665 | (defun expand-minor-mode-indicator-object (obj) | ||
| 666 | "Expand OBJ that represents a minor-mode indicator. | ||
| 667 | cdr part of a `minor-mode-alist' element(indicator object) is the | ||
| 668 | indicator of minor mode that is in car part. Normally indicator | ||
| 669 | object is a string. However, in some case it is more compound object | ||
| 670 | like cons cell. This function tries to make the compound object a string." | ||
| 671 | ;; copied from describe-mode | ||
| 672 | (while (and obj (symbolp obj) | ||
| 673 | (boundp obj) | ||
| 674 | (not (eq obj (symbol-value obj)))) | ||
| 675 | (setq obj (symbol-value obj))) | ||
| 676 | (when (and (consp obj) | ||
| 677 | (keywordp (car obj)) | ||
| 678 | (eq :eval (car obj))) | ||
| 679 | (setq obj (eval (cadr obj)))) | ||
| 680 | obj) | ||
| 681 | |||
| 614 | 682 | ||
| 615 | ;;; Automatic resizing of temporary buffers. | 683 | ;;; Automatic resizing of temporary buffers. |
| 616 | 684 | ||