From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: describe-mode should first summarize all modes in effect Date: Mon, 29 Sep 2003 15:32:27 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <3F6F155C.4010606@yahoo.com> <3F7301EF.5030701@yahoo.com> <87wubux1v6.fsf_-_@jidanni.org> Reply-To: rms@gnu.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1064864608 20808 80.91.224.253 (29 Sep 2003 19:43:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Sep 2003 19:43:28 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Sep 29 21:43:24 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A43vY-0005GO-00 for ; Mon, 29 Sep 2003 21:43:24 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1A43vX-00030A-00 for ; Mon, 29 Sep 2003 21:43:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A43om-0006Ho-Gx for emacs-devel@quimby.gnus.org; Mon, 29 Sep 2003 15:36:24 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 1A43mq-0005zB-TT for emacs-devel@gnu.org; Mon, 29 Sep 2003 15:34:24 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 1A43mK-0005qh-K1 for emacs-devel@gnu.org; Mon, 29 Sep 2003 15:34:23 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A43mJ-0005qC-DT for emacs-devel@gnu.org; Mon, 29 Sep 2003 15:33:51 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.20) id 1A43kx-0002iN-FA; Mon, 29 Sep 2003 15:32:27 -0400 Original-To: Dan Jacobson In-reply-to: <87wubux1v6.fsf_-_@jidanni.org> (message from Dan Jacobson on Sat, 27 Sep 2003 12:59:57 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:16780 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:16780 What do you think of this version? (defun describe-mode (&optional buffer) "Display documentation of current major mode and minor modes. The major mode description comes first, followed by the minor modes, each on a separate page. For this to work correctly for a minor mode, the mode's indicator variable \(listed in `minor-mode-alist') must also be a function whose documentation describes the minor mode." (interactive) (help-setup-xref (list #'describe-mode (or buffer (current-buffer))) (interactive-p)) ;; For the sake of help-do-xref and help-xref-go-back, ;; don't switch buffers before calling `help-buffer'. (with-output-to-temp-buffer (help-buffer) (save-excursion (when buffer (set-buffer buffer)) (let (minor-modes) ;; Find enabled minor mode we will want to mention. (dolist (mode minor-mode-list) ;; Document a minor mode if it is listed in minor-mode-alist, ;; non-nil, and has a function definition. (and (boundp mode) (symbol-value mode) (fboundp mode) (let ((pretty-minor-mode mode) indicator) (if (string-match "\\(-minor\\)?-mode\\'" (symbol-name mode)) (setq pretty-minor-mode (capitalize (substring (symbol-name mode) 0 (match-beginning 0))))) (setq indicator (cadr (assq mode minor-mode-alist))) (while (and indicator (symbolp indicator) (boundp indicator) (not (eq indicator (symbol-value indicator)))) (setq indicator (symbol-value indicator))) (push (list pretty-minor-mode mode indicator) minor-modes)))) (if auto-fill-function (push '("Auto Fill" auto-fill-mode " Fill") minor-modes)) (setq minor-modes (sort minor-modes (lambda (a b) (string-lessp (car a) (car b))))) (when minor-modes (princ "Summary of minor modes:\n") (dolist (mode minor-modes) (let ((pretty-minor-mode (nth 0 mode)) (indicator (nth 2 mode))) (princ (format " %s minor mode (%s):\n" pretty-minor-mode (if indicator (format "indicator%s" indicator) "no indicator"))))) (princ "\n(Full information about these minor modes follows the description of the major mode.)\n\n")) ;; Document the major mode. (princ mode-name) (princ " mode:\n") (princ (documentation major-mode)) ;; Document the minor modes fully. (dolist (mode minor-modes) (let ((pretty-minor-mode (nth 0 mode)) (mode-function (nth 1 mode)) (indicator (nth 2 mode))) (princ "\n\f\n") (princ (format "%s minor mode (%s):\n" pretty-minor-mode (if indicator (format "indicator%s" indicator) "no indicator"))) (princ (documentation mode-function))))) (print-help-return-message))))