From: Tassilo Horn <tsdh@gnu.org>
To: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
Cc: 18992@debbugs.gnu.org
Subject: bug#18992: 24.4; describe-mode
Date: Sat, 08 Nov 2014 15:34:03 +0100 [thread overview]
Message-ID: <871tpdvk10.fsf@thinkpad-t440p.tsdh.org> (raw)
In-Reply-To: <545DDF6C.9000901@easy-emacs.de> ("Andreas \=\?utf-8\?Q\?R\=C3\=B6h\?\= \=\?utf-8\?Q\?ler\=22's\?\= message of "Sat, 08 Nov 2014 10:16:28 +0100")
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> M-x describe-mode RET should report the major-mode.
> Currently it tells the value of "mode-name".
>
> Several issues with this:
>
> - Value of mode-name is displayed in current-buffers mode-line allready
I guess the main usage of `describe-mode' is to get its documentation
and key bindings.
> - mode-name often will be a quit shortened, as space in mode-line is precious
Usually it's just the capitalized version of the major-mode function
with the `-mode' stripped. And sometimes it contains more information
that just the mode function, e.g., "Dired by name", "Dired by date",
etc.
> - don't see a usage of mode-name beyond mode-line
The other important usage is printing the pretty name with
describe-mode. ;-)
> - user will be interested in value of major-mode, which isn't told
describe-mode prints a link you can click to jump to the major-mode
function.
> See for example from inside a M-x shell RET
>
> M-x describe-mode says: "Shell mode"
> while the real major-mode is sh-mode
No, the real mode function is `shell-mode'. `sh-mode' is the editing
mode for shell scripts, and that has mode-names like "Shell-script[zsh]"
or "Shell-script[bash]" which are even more informative than just the
plain mode function.
Well, but of course having the mode functions printed in `describe-mode'
wouldn't hurt anyway. This patch does that:
--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/help.el'
--- lisp/help.el 2014-08-07 03:25:09 +0000
+++ lisp/help.el 2014-11-08 14:27:54 +0000
@@ -946,7 +946,8 @@
(let ((start (point)))
(insert (format-mode-line mode nil nil buffer))
(add-text-properties start (point) '(face bold)))))
- (princ " mode")
+ (princ " mode ")
+ (princ (format "(`%s')" major-mode))
(let* ((mode major-mode)
(file-name (find-lisp-object-file-name mode nil)))
(when file-name
--8<---------------cut here---------------end--------------->8---
With that, in this message buffer I get:
--8<---------------cut here---------------start------------->8---
Message mode (`message-mode') defined in `message.el':
Major mode for editing mail and news to be sent.
Like Text Mode but with these additional commands:
...
--8<---------------cut here---------------end--------------->8---
With the following patch, the same would be done for the active minor
modes, too:
--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/help.el'
--- lisp/help.el 2014-08-07 03:25:09 +0000
+++ lisp/help.el 2014-11-08 14:31:30 +0000
@@ -924,7 +924,8 @@
(push (point-marker) help-button-cache)
;; Document the minor modes fully.
(insert pretty-minor-mode)
- (princ (format " minor mode (%s):\n"
+ (princ (format " minor mode (`%s'; %s):\n"
+ mode-function
(if (zerop (length indicator))
"no indicator"
(format "indicator%s"
@@ -946,7 +947,8 @@
(let ((start (point)))
(insert (format-mode-line mode nil nil buffer))
(add-text-properties start (point) '(face bold)))))
- (princ " mode")
+ (princ " mode ")
+ (princ (format "(`%s')" major-mode))
(let* ((mode major-mode)
(file-name (find-lisp-object-file-name mode nil)))
(when file-name
--8<---------------cut here---------------end--------------->8---
However, in contrast to major-modes, minor mode names tend to be much
longer, so we can get some long lines like:
Global-Edit-Server-Edit minor mode (`global-edit-server-edit-mode'; no indicator):
Bye,
Tassilo
next prev parent reply other threads:[~2014-11-08 14:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-08 9:16 bug#18992: 24.4; describe-mode Andreas Röhler
2014-11-08 14:34 ` Tassilo Horn [this message]
2014-11-08 15:54 ` Andreas Röhler
2014-11-08 16:35 ` Drew Adams
2014-11-08 15:57 ` Drew Adams
2014-11-08 16:42 ` Drew Adams
2019-12-05 11:35 ` Stefan Kangas
2020-01-15 2:01 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871tpdvk10.fsf@thinkpad-t440p.tsdh.org \
--to=tsdh@gnu.org \
--cc=18992@debbugs.gnu.org \
--cc=andreas.roehler@easy-emacs.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).