unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57481: elisp code utilising derived-mode-parent
@ 2022-08-30  5:44 Christopher Dimech
  2022-08-30  6:37 ` Phil Sainty
  2022-08-30 10:36 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 14+ messages in thread
From: Christopher Dimech @ 2022-08-30  5:44 UTC (permalink / raw)
  To: 57481


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.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30  5:44 bug#57481: elisp code utilising derived-mode-parent Christopher Dimech
@ 2022-08-30  6:37 ` Phil Sainty
  2022-08-30 11:33   ` Christopher Dimech
                     ` (2 more replies)
  2022-08-30 10:36 ` Lars Ingebrigtsen
  1 sibling, 3 replies; 14+ messages in thread
From: Phil Sainty @ 2022-08-30  6:37 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: 57481

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)






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30  5:44 bug#57481: elisp code utilising derived-mode-parent Christopher Dimech
  2022-08-30  6:37 ` Phil Sainty
@ 2022-08-30 10:36 ` Lars Ingebrigtsen
  2022-08-30 11:48   ` Christopher Dimech
  1 sibling, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-30 10:36 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: 57481

Christopher Dimech <dimech@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".





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30  6:37 ` Phil Sainty
@ 2022-08-30 11:33   ` Christopher Dimech
  2022-08-30 12:02     ` Phil Sainty
  2022-08-30 12:08   ` Christopher Dimech
  2022-08-31 11:31   ` Christopher Dimech
  2 siblings, 1 reply; 14+ messages in thread
From: Christopher Dimech @ 2022-08-30 11:33 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 57481


> Sent: Tuesday, August 30, 2022 at 6:37 PM
> From: "Phil Sainty" <psainty@orcon.net.nz>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: 57481@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







^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 10:36 ` Lars Ingebrigtsen
@ 2022-08-30 11:48   ` Christopher Dimech
  0 siblings, 0 replies; 14+ messages in thread
From: Christopher Dimech @ 2022-08-30 11:48 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 57481


> Sent: Tuesday, August 30, 2022 at 10:36 PM
> From: "Lars Ingebrigtsen" <larsi@gnus.org>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: 57481@debbugs.gnu.org
> Subject: bug#57481: elisp code utilising derived-mode-parent
>
> Christopher Dimech <dimech@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.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 11:33   ` Christopher Dimech
@ 2022-08-30 12:02     ` Phil Sainty
  0 siblings, 0 replies; 14+ messages in thread
From: Phil Sainty @ 2022-08-30 12:02 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: 57481

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.







^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30  6:37 ` Phil Sainty
  2022-08-30 11:33   ` Christopher Dimech
@ 2022-08-30 12:08   ` Christopher Dimech
  2022-08-30 12:38     ` Phil Sainty
  2022-08-31 11:31   ` Christopher Dimech
  2 siblings, 1 reply; 14+ messages in thread
From: Christopher Dimech @ 2022-08-30 12:08 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 57481


> Sent: Tuesday, August 30, 2022 at 6:37 PM
> From: "Phil Sainty" <psainty@orcon.net.nz>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: 57481@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?





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 12:08   ` Christopher Dimech
@ 2022-08-30 12:38     ` Phil Sainty
  2022-08-30 12:46       ` Christopher Dimech
  2022-08-30 13:02       ` Eli Zaretskii
  0 siblings, 2 replies; 14+ messages in thread
From: Phil Sainty @ 2022-08-30 12:38 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: 57481

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.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 12:38     ` Phil Sainty
@ 2022-08-30 12:46       ` Christopher Dimech
  2022-08-30 13:02       ` Eli Zaretskii
  1 sibling, 0 replies; 14+ messages in thread
From: Christopher Dimech @ 2022-08-30 12:46 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 57481



> Sent: Wednesday, August 31, 2022 at 12:38 AM
> From: "Phil Sainty" <psainty@orcon.net.nz>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: 57481@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?





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 12:38     ` Phil Sainty
  2022-08-30 12:46       ` Christopher Dimech
@ 2022-08-30 13:02       ` Eli Zaretskii
  2022-08-30 13:16         ` Christopher Dimech
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-08-30 13:02 UTC (permalink / raw)
  To: Phil Sainty; +Cc: dimech, 57481

> Cc: 57481@debbugs.gnu.org
> Date: Wed, 31 Aug 2022 00:38:46 +1200
> From: Phil Sainty <psainty@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.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 13:02       ` Eli Zaretskii
@ 2022-08-30 13:16         ` Christopher Dimech
  2022-08-30 22:07           ` Phil Sainty
  0 siblings, 1 reply; 14+ messages in thread
From: Christopher Dimech @ 2022-08-30 13:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Phil Sainty, 57481

> Sent: Wednesday, August 31, 2022 at 1:02 AM
> From: "Eli Zaretskii" <eliz@gnu.org>
> To: "Phil Sainty" <psainty@orcon.net.nz>
> Cc: dimech@gmx.com, 57481@debbugs.gnu.org
> Subject: Re: bug#57481: elisp code utilising derived-mode-parent
>
> > Cc: 57481@debbugs.gnu.org
> > Date: Wed, 31 Aug 2022 00:38:46 +1200
> > From: Phil Sainty <psainty@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.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 13:16         ` Christopher Dimech
@ 2022-08-30 22:07           ` Phil Sainty
  2022-08-31  6:24             ` Christopher Dimech
  0 siblings, 1 reply; 14+ messages in thread
From: Phil Sainty @ 2022-08-30 22:07 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Eli Zaretskii, 57481

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.







^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30 22:07           ` Phil Sainty
@ 2022-08-31  6:24             ` Christopher Dimech
  0 siblings, 0 replies; 14+ messages in thread
From: Christopher Dimech @ 2022-08-31  6:24 UTC (permalink / raw)
  To: Phil Sainty; +Cc: Eli Zaretskii, 57481


> Sent: Wednesday, August 31, 2022 at 10:07 AM
> From: "Phil Sainty" <psainty@orcon.net.nz>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Eli Zaretskii" <eliz@gnu.org>, 57481@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.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#57481: elisp code utilising derived-mode-parent
  2022-08-30  6:37 ` Phil Sainty
  2022-08-30 11:33   ` Christopher Dimech
  2022-08-30 12:08   ` Christopher Dimech
@ 2022-08-31 11:31   ` Christopher Dimech
  2 siblings, 0 replies; 14+ messages in thread
From: Christopher Dimech @ 2022-08-31 11:31 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 57481

> Sent: Tuesday, August 30, 2022 at 6:37 PM
> From: "Phil Sainty" <psainty@orcon.net.nz>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: 57481@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?





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-08-31 11:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30  5:44 bug#57481: elisp code utilising derived-mode-parent Christopher Dimech
2022-08-30  6:37 ` Phil Sainty
2022-08-30 11:33   ` Christopher Dimech
2022-08-30 12:02     ` Phil Sainty
2022-08-30 12:08   ` Christopher Dimech
2022-08-30 12:38     ` Phil Sainty
2022-08-30 12:46       ` Christopher Dimech
2022-08-30 13:02       ` Eli Zaretskii
2022-08-30 13:16         ` Christopher Dimech
2022-08-30 22:07           ` Phil Sainty
2022-08-31  6:24             ` Christopher Dimech
2022-08-31 11:31   ` Christopher Dimech
2022-08-30 10:36 ` Lars Ingebrigtsen
2022-08-30 11:48   ` Christopher Dimech

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