[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8660: 23.2; info-look.el makefile-mode derivatives
From: |
Kevin Ryde |
Subject: |
bug#8660: 23.2; info-look.el makefile-mode derivatives |
Date: |
Sat, 16 Feb 2013 11:02:25 +1100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
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.
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
- bug#8660: 23.2; info-look.el makefile-mode derivatives,
Kevin Ryde <=