unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: describe-mode should first summarize all modes in effect
       [not found]       ` <87wubux1v6.fsf_-_@jidanni.org>
@ 2003-09-29 19:32         ` Richard Stallman
  0 siblings, 0 replies; only message in thread
From: Richard Stallman @ 2003-09-29 19:32 UTC (permalink / raw)
  Cc: emacs-devel

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))))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-29 19:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.443.1064004252.21628.bug-gnu-emacs@gnu.org>
     [not found] ` <3F6F155C.4010606@yahoo.com>
     [not found]   ` <mailman.677.1064447066.21628.bug-gnu-emacs@gnu.org>
     [not found]     ` <3F7301EF.5030701@yahoo.com>
     [not found]       ` <87wubux1v6.fsf_-_@jidanni.org>
2003-09-29 19:32         ` describe-mode should first summarize all modes in effect Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).