GNU bug report logs - #57481
elisp code utilising derived-mode-parent

Previous Next

Package: emacs;

Reported by: Christopher Dimech <dimech <at> gmx.com>

Date: Tue, 30 Aug 2022 05:45:02 UTC

Severity: normal

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57481 in the body.
You can then email your comments to 57481 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 05:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Dimech <dimech <at> gmx.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 30 Aug 2022 05:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: bug-gnu-emacs <at> gnu.org
Subject: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 07:44:39 +0200
Have seen that  (get 'latex-mode 'derived-mode-parent)  as a normal elisp command.
For instance, I cannot run it in "lisp-interaction-mode" or simply make a elisp
function that iterates the result of the expression until reacting "nil" to get
a tree of all parents.

Would be a handy tool to have.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 06:38:02 GMT) Full text and rfc822 format available.

Message #8 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Christopher Dimech <dimech <at> gmx.com>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 18:37:22 +1200
You can derive (as it were) such a function from the code of
`provided-mode-derived-p' like so:


 (defun derived-mode-chain (mode)
   "Return the chain of derived modes for MODE."
   (let (chain)
     (while (progn (push mode chain)
                   (let* ((parent (get mode 'derived-mode-parent))
                          (parentfn (symbol-function parent)))
                     (setq mode (if (and parentfn (symbolp parentfn))
                                    parentfn
                                  parent)))))
     (nreverse chain)))


 (derived-mode-chain 'latex-mode)
 => (latex-mode tex-mode text-mode)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 10:37:02 GMT) Full text and rfc822 format available.

Message #11 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Christopher Dimech <dimech <at> gmx.com>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 12:36:48 +0200
Christopher Dimech <dimech <at> gmx.com> writes:

> Have seen that (get 'latex-mode 'derived-mode-parent) as a normal
> elisp command.
> For instance, I cannot run it in "lisp-interaction-mode" or simply make a elisp
> function that iterates the result of the expression until reacting "nil" to get
> a tree of all parents.
>
> Would be a handy tool to have.

I don't think that would be generally useful -- it's internal data that
wouldn't be interesting to the vast majority of users.

So I'm closing this as a "wontfix".




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 30 Aug 2022 10:38:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 57481 <at> debbugs.gnu.org and Christopher Dimech <dimech <at> gmx.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 30 Aug 2022 10:38:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 11:34:01 GMT) Full text and rfc822 format available.

Message #18 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 13:33:13 +0200
> Sent: Tuesday, August 30, 2022 at 6:37 PM
> From: "Phil Sainty" <psainty <at> orcon.net.nz>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 57481 <at> debbugs.gnu.org
> Subject: bug#57481: elisp code utilising derived-mode-parent
>
> You can derive (as it were) such a function from the code of
> `provided-mode-derived-p' like so:
>
>
>   (defun derived-mode-chain (mode)
>     "Return the chain of derived modes for MODE."
>     (let (chain)
>       (while (progn (push mode chain)
>                     (let* ((parent (get mode 'derived-mode-parent))
>                            (parentfn (symbol-function parent)))
>                       (setq mode (if (and parentfn (symbolp parentfn))
>                                      parentfn
>                                    parent)))))
>       (nreverse chain)))
>
>
>   (derived-mode-chain 'latex-mode)
>   => (latex-mode tex-mode text-mode)

We are getting somewhere, but am only getting (latex-mode) on Emacs 27.2






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 11:49:02 GMT) Full text and rfc822 format available.

Message #21 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 13:48:17 +0200
> Sent: Tuesday, August 30, 2022 at 10:36 PM
> From: "Lars Ingebrigtsen" <larsi <at> gnus.org>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 57481 <at> debbugs.gnu.org
> Subject: bug#57481: elisp code utilising derived-mode-parent
>
> Christopher Dimech <dimech <at> gmx.com> writes:
>
> > Have seen that (get 'latex-mode 'derived-mode-parent) as a normal
> > elisp command.
> > For instance, I cannot run it in "lisp-interaction-mode" or simply make a elisp
> > function that iterates the result of the expression until reacting "nil" to get
> > a tree of all parents.
> >
> > Would be a handy tool to have.
>
> I don't think that would be generally useful -- it's internal data that
> wouldn't be interesting to the vast majority of users.
>
> So I'm closing this as a "wontfix".

I encourage tools that assist the perusing of internal data.  Such tools
would be instrumental for people keenly interested in Emacs Internals.

Besides users there should be a separate focus towards developer needs.
Will elevate emacs work substantially.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 12:03:02 GMT) Full text and rfc822 format available.

Message #24 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Christopher Dimech <dimech <at> gmx.com>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Wed, 31 Aug 2022 00:02:00 +1200
On 2022-08-30 23:33, Christopher Dimech wrote:
> am only getting (latex-mode) on Emacs 27.2

You obviously haven't loaded the library defining the mode
(which is tex-mode.el).  Don't expect Emacs to know much
about something that hasn't been loaded.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 12:09:02 GMT) Full text and rfc822 format available.

Message #27 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 14:08:31 +0200
> Sent: Tuesday, August 30, 2022 at 6:37 PM
> From: "Phil Sainty" <psainty <at> orcon.net.nz>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 57481 <at> debbugs.gnu.org
> Subject: Re: bug#57481: elisp code utilising derived-mode-parent
>
> You can derive (as it were) such a function from the code of
> `provided-mode-derived-p' like so:
>
>
>   (defun derived-mode-chain (mode)
>     "Return the chain of derived modes for MODE."
>     (let (chain)
>       (while (progn (push mode chain)
>                     (let* ((parent (get mode 'derived-mode-parent))
>                            (parentfn (symbol-function parent)))
>                       (setq mode (if (and parentfn (symbolp parentfn))
>                                      parentfn
>                                    parent)))))
>       (nreverse chain)))
>
>
>   (derived-mode-chain 'latex-mode)
>   => (latex-mode tex-mode text-mode)

Can one do something that can be run in elisp code and in
lisp-interaction-mode without requirement that the mode one
is interested in has been loaded?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 12:39:02 GMT) Full text and rfc822 format available.

Message #30 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Christopher Dimech <dimech <at> gmx.com>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Wed, 31 Aug 2022 00:38:46 +1200
On 2022-08-31 00:08, Christopher Dimech wrote:
> Can one do something that can be run in elisp code and in
> lisp-interaction-mode without requirement that the mode one
> is interested in has been loaded?

You're asking whether Emacs can tell you things it doesn't know.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 12:47:01 GMT) Full text and rfc822 format available.

Message #33 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 14:46:11 +0200

> Sent: Wednesday, August 31, 2022 at 12:38 AM
> From: "Phil Sainty" <psainty <at> orcon.net.nz>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 57481 <at> debbugs.gnu.org
> Subject: Re: bug#57481: elisp code utilising derived-mode-parent
>
> On 2022-08-31 00:08, Christopher Dimech wrote:
> > Can one do something that can be run in elisp code and in
> > lisp-interaction-mode without requirement that the mode one
> > is interested in has been loaded?
>
> You're asking whether Emacs can tell you things it doesn't know.

Then the information can only be traced at run-time.  Could things get loaded
if needed without having this requirement done by users?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 13:03:01 GMT) Full text and rfc822 format available.

Message #36 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: dimech <at> gmx.com, 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 16:02:32 +0300
> Cc: 57481 <at> debbugs.gnu.org
> Date: Wed, 31 Aug 2022 00:38:46 +1200
> From: Phil Sainty <psainty <at> orcon.net.nz>
> 
> On 2022-08-31 00:08, Christopher Dimech wrote:
> > Can one do something that can be run in elisp code and in
> > lisp-interaction-mode without requirement that the mode one
> > is interested in has been loaded?
> 
> You're asking whether Emacs can tell you things it doesn't know.

Well, it's Emacs, isn't it?  Why shouldn't it have a feature whereby
it tells us things it doesn't know about?  It certainly sounds useful
to have.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 13:18:01 GMT) Full text and rfc822 format available.

Message #39 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Tue, 30 Aug 2022 15:16:50 +0200
> Sent: Wednesday, August 31, 2022 at 1:02 AM
> From: "Eli Zaretskii" <eliz <at> gnu.org>
> To: "Phil Sainty" <psainty <at> orcon.net.nz>
> Cc: dimech <at> gmx.com, 57481 <at> debbugs.gnu.org
> Subject: Re: bug#57481: elisp code utilising derived-mode-parent
>
> > Cc: 57481 <at> debbugs.gnu.org
> > Date: Wed, 31 Aug 2022 00:38:46 +1200
> > From: Phil Sainty <psainty <at> orcon.net.nz>
> >
> > On 2022-08-31 00:08, Christopher Dimech wrote:
> > > Can one do something that can be run in elisp code and in
> > > lisp-interaction-mode without requirement that the mode one
> > > is interested in has been loaded?
> >
> > You're asking whether Emacs can tell you things it doesn't know.
>
> Well, it's Emacs, isn't it?  Why shouldn't it have a feature whereby
> it tells us things it doesn't know about?  It certainly sounds useful
> to have.

It could find things through and do what it has to do, without requirements
for user mode loading.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Tue, 30 Aug 2022 22:08:02 GMT) Full text and rfc822 format available.

Message #42 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Christopher Dimech <dimech <at> gmx.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Wed, 31 Aug 2022 10:07:30 +1200
On 2022-08-31 01:16, Christopher Dimech wrote:
> It could find things through and do what it has to do,
> without requirements for user mode loading.

Except that what it needs to do is load the mode.

If you're now saying that you're actually happy for the mode
to be loaded just so long as the user doesn't have to do it
themselves, then you can do that for autoloaded modes.
Check autoloadp and, if non-nil, call autoload-do-load.

For modes which are neither loaded nor known as autoloads,
Emacs doesn't even know they exist, let alone how to tell
you what they derive from.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Wed, 31 Aug 2022 06:25:02 GMT) Full text and rfc822 format available.

Message #45 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Wed, 31 Aug 2022 08:24:03 +0200
> Sent: Wednesday, August 31, 2022 at 10:07 AM
> From: "Phil Sainty" <psainty <at> orcon.net.nz>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: "Eli Zaretskii" <eliz <at> gnu.org>, 57481 <at> debbugs.gnu.org
> Subject: Re: bug#57481: elisp code utilising derived-mode-parent
>
> On 2022-08-31 01:16, Christopher Dimech wrote:
> > It could find things through and do what it has to do,
> > without requirements for user mode loading.
>
> Except that what it needs to do is load the mode.
>
> If you're now saying that you're actually happy for the mode
> to be loaded just so long as the user doesn't have to do it
> themselves, then you can do that for autoloaded modes.
> Check autoloadp and, if non-nil, call autoload-do-load.

It has been a misinterpretation.  Not-loading was a reference to
make the loading requirement fall upon the user.  Unless the
user has already loaded it or was loaded it for whatever task
user is doing, then I can load the mode appropriately when the
user calls the function.

> For modes which are neither loaded nor known as autoloads,
> Emacs doesn't even know they exist, let alone how to tell
> you what they derive from.

Can scrutinise that some other time.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57481; Package emacs. (Wed, 31 Aug 2022 11:32:01 GMT) Full text and rfc822 format available.

Message #48 received at 57481 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Dimech <dimech <at> gmx.com>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 57481 <at> debbugs.gnu.org
Subject: Re: bug#57481: elisp code utilising derived-mode-parent
Date: Wed, 31 Aug 2022 13:31:15 +0200
> Sent: Tuesday, August 30, 2022 at 6:37 PM
> From: "Phil Sainty" <psainty <at> orcon.net.nz>
> To: "Christopher Dimech" <dimech <at> gmx.com>
> Cc: 57481 <at> debbugs.gnu.org
> Subject: Re: bug#57481: elisp code utilising derived-mode-parent
>
> You can derive (as it were) such a function from the code of
> `provided-mode-derived-p' like so:
>
>
>   (defun derived-mode-chain (mode)
>     "Return the chain of derived modes for MODE."
>     (let (chain)
>       (while (progn (push mode chain)
>                     (let* ((parent (get mode 'derived-mode-parent))
>                            (parentfn (symbol-function parent)))
>                       (setq mode (if (and parentfn (symbolp parentfn))
>                                      parentfn
>                                    parent)))))
>       (nreverse chain)))
>
>
>   (derived-mode-chain 'latex-mode)
>   => (latex-mode tex-mode text-mode)
>

Have not encountered "(while" with "(progn" in "(while (progn".  Could you be so kind to explain it?




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 29 Sep 2022 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 210 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.