From: Kevin Ryde <user42@zip.com.au>
To: 8660@debbugs.gnu.org
Subject: bug#8660: 23.2; info-look.el makefile-mode derivatives
Date: Sat, 16 Feb 2013 11:02:25 +1100 [thread overview]
Message-ID: <877gm96s8e.fsf@blah.blah> (raw)
In-Reply-To: <jwv1v022az5.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 14 May 2011 00:55:18 -0300")
[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> I suppose also info-look might check a derived-mode-parent if a mode
>> doesn't have its own setup. That might pick up more things with less
>> effort in each mode.
>
> Oh, yes, that would be a better change. Patch welcome.
It took a while but I made the couple of lines below.
I considered having the lookup bits such as info-lookup->mode-value do
their lookups under a parent mode if the given mode has nothing. But I
think there are too many complications from that. Some calls are asking
if there's anything before adding and thus don't want a fallback. The
caching bits probably would want to cache against the actual name rather
than any derived child name. And behaviour would subtly change after a
derived mode has loaded and thus gained a `derived-mode-parent'
property.
A nicer default `info-lookup-mode' should do only good, and it won't
affect anything which explicitly selects an info-lookup-mode itself.
2013-02-16 Kevin Ryde <user42@zip.com.au>
* info-look.el (info-lookup-select-mode): If major-mode has no
info-lookup-alist entry then search up derived-mode-parent.
This means a define-derived-mode uses its parent's info-look setups
if it has none of its own. Helps `makefile-gmake-mode' and friends
automatically use their parent `makefile-mode' instead of prompting
for a mode.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: info-look.el.derived-mode-parent.diff --]
[-- Type: text/x-diff, Size: 1382 bytes --]
diff -u /home/gg/bug/info-look-parent/info-look.el.orig /home/gg/bug/info-look-parent/info-look.el
--- /home/gg/bug/info-look-parent/info-look.el.orig 2012-09-09 07:58:12.000000000 +1000
+++ /home/gg/bug/info-look-parent/info-look.el 2013-02-16 10:47:30.000000000 +1100
@@ -298,6 +298,21 @@
(when (string-match (caar file-name-alist) file-name)
(setq info-lookup-mode (cdar file-name-alist)))
(setq file-name-alist (cdr file-name-alist)))))
+
+ ;; If major-mode has no setups in info-lookup-alist, under any topic, then
+ ;; search up through derived-mode-parent to find a parent mode which does
+ ;; have some setups. This means that a `define-derived-mode' with no
+ ;; setups of its own will select its parent mode for lookups, if one of
+ ;; its parents has some setups. Good for example on `makefile-gmake-mode'
+ ;; and similar derivatives of `makefile-mode'.
+ ;;
+ (let ((mode major-mode)) ;; look for `mode' with some setups
+ (while (and mode (not info-lookup-mode))
+ (dolist (topic-cell info-lookup-alist) ;; usually only two topics here
+ (if (info-lookup->mode-value (car topic-cell) mode)
+ (setq info-lookup-mode mode)))
+ (setq mode (get mode 'derived-mode-parent))))
+
(or info-lookup-mode (setq info-lookup-mode major-mode)))
(defun info-lookup-change-mode (topic)
Diff finished. Sat Feb 16 10:48:55 2013
next prev parent reply other threads:[~2013-02-16 0:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-12 0:21 bug#8660: 23.2; info-look.el makefile-mode derivatives Kevin Ryde
2011-05-12 3:11 ` Stefan Monnier
2011-05-14 1:37 ` Kevin Ryde
2011-05-14 3:55 ` Stefan Monnier
2011-05-16 0:02 ` Kevin Ryde
2011-05-16 17:42 ` Stefan Monnier
2013-02-16 0:02 ` Kevin Ryde [this message]
2013-02-16 17:21 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877gm96s8e.fsf@blah.blah \
--to=user42@zip.com.au \
--cc=8660@debbugs.gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.