unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: List of major modes?
       [not found] <DNEMKBNJBGPAOPIJOOICEEKJCOAA.drew.adams@oracle.com>
@ 2005-11-11 19:12 ` Lennart Borgman
  2005-11-11 21:51   ` David Reitter
  0 siblings, 1 reply; 18+ messages in thread
From: Lennart Borgman @ 2005-11-11 19:12 UTC (permalink / raw)
  Cc: Help-gnu-emacs, Emacs Devel

Drew Adams wrote:

>Recent Emacs versions have `minor-mode-list' (not alist), a list of all
>minor mode functions. There is no guarantee that it will be complete,
>however. It is fed by `add-minor-mode'.
>  
>
Would it not be best to make something similar for major modes? There 
are some requirements for what major modes should do and why not add a 
new requirement? It will not be very difficult to add it and many users 
would surely like it.

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

* Re: List of major modes?
  2005-11-11 19:12 ` List of major modes? Lennart Borgman
@ 2005-11-11 21:51   ` David Reitter
  2005-11-11 22:18     ` Lennart Borgman
  2005-11-14 16:26     ` Kevin Rodgers
  0 siblings, 2 replies; 18+ messages in thread
From: David Reitter @ 2005-11-11 21:51 UTC (permalink / raw)
  Cc: Help-gnu-emacs, Drew Adams, Emacs Devel

On 11 Nov 2005, at 19:12, Lennart Borgman wrote:

> Drew Adams wrote:
>
>> Recent Emacs versions have `minor-mode-list' (not alist), a list  
>> of all
>> minor mode functions. There is no guarantee that it will be complete,
>> however. It is fed by `add-minor-mode'.
>>
> Would it not be best to make something similar for major modes?  
> There are some requirements for what major modes should do and why  
> not add a new requirement? It will not be very difficult to add it  
> and many users would surely like it.

Changing the conventions for major modes wouldn't work that well,  
since that would basically create an incompatibility.

The following dynamic definition seems to "sort of" work.

(defun major-modes ()
  (apropos-internal "-mode\\'"
    (lambda (mode)
      (and (commandp mode)
	  (not (string-match "\\`turn-\\(on\\|off\\)-"
	  		     (symbol-name mode)))
   	  (not (assq mode minor-mode-list))))))


I don't know, however, whether minor-mode-list is complete, i.e.  
whether it contains the not-yet-auto-loaded minor modes. From what I  
see in easy-mmode.el, it doesn't look like it. 

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

* Re: List of major modes?
  2005-11-11 21:51   ` David Reitter
@ 2005-11-11 22:18     ` Lennart Borgman
  2005-11-14 16:26     ` Kevin Rodgers
  1 sibling, 0 replies; 18+ messages in thread
From: Lennart Borgman @ 2005-11-11 22:18 UTC (permalink / raw)
  Cc: Help-gnu-emacs, Emacs Devel

David Reitter wrote:

> The following dynamic definition seems to "sort of" work.
>
> (defun major-modes ()
>  (apropos-internal "-mode\\'"
>    (lambda (mode)
>      (and (commandp mode)
>       (not (string-match "\\`turn-\\(on\\|off\\)-"
>                    (symbol-name mode)))
>         (not (assq mode minor-mode-list))))))
>
>
> I don't know, however, whether minor-mode-list is complete, i.e.  
> whether it contains the not-yet-auto-loaded minor modes. From what I  
> see in easy-mmode.el, it doesn't look like it.


Maybe I should change my mind. It looks good. If you marry this with the 
code in describe-mode you can perhaps populate minor-mode-list first 
with all minor modes. At least it seems so in that code. (Older minor 
modes seems to be in minor-mode-alist.)

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

* Re: List of major modes?
  2005-11-11 21:51   ` David Reitter
  2005-11-11 22:18     ` Lennart Borgman
@ 2005-11-14 16:26     ` Kevin Rodgers
  2005-11-14 16:40       ` Lennart Borgman
                         ` (2 more replies)
  1 sibling, 3 replies; 18+ messages in thread
From: Kevin Rodgers @ 2005-11-14 16:26 UTC (permalink / raw)
  Cc: help-gnu-emacs

David Reitter wrote:
 > The following dynamic definition seems to "sort of" work.
 >
 > (defun major-modes ()
 >  (apropos-internal "-mode\\'"
 >    (lambda (mode)
 >      (and (commandp mode)
 >       (not (string-match "\\`turn-\\(on\\|off\\)-"
 >                    (symbol-name mode)))
 >         (not (assq mode minor-mode-list))))))
 >
 >
 > I don't know, however, whether minor-mode-list is complete, i.e.
 > whether it contains the not-yet-auto-loaded minor modes. From what I
 > see in easy-mmode.el, it doesn't look like it.

I still think it would be better to include functions that follow the
major mode conventions than to exclude functions that don't follow the
minor mode conventions.  The Emacs Lisp manual has nodes describing both
sets of conventions.

For example:

    * The major mode should usually have its own keymap, which is used
      as the local keymap in all buffers in that mode.  The major mode
      command should call `use-local-map' to install this local map.
      *Note Active Keymaps::, for more information.

      This keymap should be stored permanently in a global variable named
      `MODENAME-mode-map'.  Normally the library that defines the mode
      sets this variable.

So you could check (keymapp (intern-soft (concat mode "-map"))) in the
apropos-internal PREDICATE.

-- 
Kevin Rodgers

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

* Re: List of major modes?
  2005-11-14 16:26     ` Kevin Rodgers
@ 2005-11-14 16:40       ` Lennart Borgman
  2005-11-14 19:32         ` Stefan Monnier
  2005-11-15  5:43       ` Richard M. Stallman
  2005-11-15 10:22       ` Alan Mackenzie
  2 siblings, 1 reply; 18+ messages in thread
From: Lennart Borgman @ 2005-11-14 16:40 UTC (permalink / raw)
  Cc: help-gnu-emacs, emacs-devel

Kevin Rodgers wrote:

>
> For example:
>
>    * The major mode should usually have its own keymap, which is used
>      as the local keymap in all buffers in that mode.  The major mode
>      command should call `use-local-map' to install this local map.
>      *Note Active Keymaps::, for more information.
>
>      This keymap should be stored permanently in a global variable named
>      `MODENAME-mode-map'.  Normally the library that defines the mode
>      sets this variable.
>
> So you could check (keymapp (intern-soft (concat mode "-map"))) in the
> apropos-internal PREDICATE.
>
What about autoloading?

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

* Re: List of major modes?
  2005-11-14 16:40       ` Lennart Borgman
@ 2005-11-14 19:32         ` Stefan Monnier
  0 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2005-11-14 19:32 UTC (permalink / raw)
  Cc: Kevin Rodgers, help-gnu-emacs, emacs-devel

>> * The major mode should usually have its own keymap, which is used
>> as the local keymap in all buffers in that mode.  The major mode
>> command should call `use-local-map' to install this local map.
>> *Note Active Keymaps::, for more information.
>> 
>> This keymap should be stored permanently in a global variable named
>> `MODENAME-mode-map'.  Normally the library that defines the mode
>> sets this variable.
>> 
>> So you could check (keymapp (intern-soft (concat mode "-map"))) in the
>> apropos-internal PREDICATE.
>> 
> What about autoloading?

Indeed, it's very difficult to tell the difference between an autoloaded
major mode and some other autoloaded function whose name ends in `-mode'.

If the autoload is complete (i.e. generated by a recent autoload.el), then
it'll include the arg list, in which case we can check whether the arglist
is empty (as the convention says).

This said, I'm still not sure why you'd want a list of major modes.


        Stefan

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

* Re: List of major modes?
  2005-11-14 16:26     ` Kevin Rodgers
  2005-11-14 16:40       ` Lennart Borgman
@ 2005-11-15  5:43       ` Richard M. Stallman
  2005-11-15 16:36         ` Lennart Borgman
  2005-11-15 10:22       ` Alan Mackenzie
  2 siblings, 1 reply; 18+ messages in thread
From: Richard M. Stallman @ 2005-11-15  5:43 UTC (permalink / raw)
  Cc: help-gnu-emacs, emacs-devel

It is not correct to assume that every major mode has a keymap named
after it.  However, major mode commands take no arguments, whereas
every minor mode command takes an argument.  There may be one or two
exceptions, major mode commands that take arguments, but it would be
easy to put them on a list of exceptions.

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

* Re: List of major modes?
  2005-11-14 16:26     ` Kevin Rodgers
  2005-11-14 16:40       ` Lennart Borgman
  2005-11-15  5:43       ` Richard M. Stallman
@ 2005-11-15 10:22       ` Alan Mackenzie
  2005-11-15 18:21         ` Kevin Rodgers
                           ` (2 more replies)
  2 siblings, 3 replies; 18+ messages in thread
From: Alan Mackenzie @ 2005-11-15 10:22 UTC (permalink / raw)
  Cc: help-gnu-emacs, emacs-devel



On Mon, 14 Nov 2005, Kevin Rodgers wrote:

>David Reitter wrote:
> > The following dynamic definition seems to "sort of" work.

> > (defun major-modes ()
> >  (apropos-internal "-mode\\'"
> >    (lambda (mode)
> >      (and (commandp mode)
> >       (not (string-match "\\`turn-\\(on\\|off\\)-"
> >                    (symbol-name mode)))
> >         (not (assq mode minor-mode-list))))))


> > I don't know, however, whether minor-mode-list is complete, i.e.
> > whether it contains the not-yet-auto-loaded minor modes. From what I
> > see in easy-mmode.el, it doesn't look like it.

>I still think it would be better to include functions that follow the
>major mode conventions than to exclude functions that don't follow the
>minor mode conventions.  The Emacs Lisp manual has nodes describing both
>sets of conventions.

It is impossible to create a list of major modes, because a major mode is
simply a lisp function, with nothing definitive to distinguish it from
any other lisp function.

So how about having a property `emacs-mode' on symbols, with valid values
(major minor major-minor nil)?  Getting a list of major modes would then
be trivial.  (OK, for Emacs 23. ;-)

>-- 
>Kevin Rodgers

-- 
Alan Mackenzie (Munich, Germany)

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

* Re: List of major modes?
  2005-11-15  5:43       ` Richard M. Stallman
@ 2005-11-15 16:36         ` Lennart Borgman
  2005-11-15 23:19           ` Stefan Monnier
  2005-11-15 23:22           ` Richard M. Stallman
  0 siblings, 2 replies; 18+ messages in thread
From: Lennart Borgman @ 2005-11-15 16:36 UTC (permalink / raw)
  Cc: Kevin Rodgers, emacs-devel

Richard M. Stallman wrote:

>It is not correct to assume that every major mode has a keymap named
>after it.  However, major mode commands take no arguments, whereas
>every minor mode command takes an argument.  There may be one or two
>exceptions, major mode commands that take arguments, but it would be
>easy to put them on a list of exceptions.
>  
>
But is information about arguments available for autoloaded functions 
that has not been loaded yet?

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

* Re: List of major modes?
  2005-11-15 10:22       ` Alan Mackenzie
@ 2005-11-15 18:21         ` Kevin Rodgers
  2005-11-15 23:22         ` Richard M. Stallman
  2005-11-16 17:20         ` David Reitter
  2 siblings, 0 replies; 18+ messages in thread
From: Kevin Rodgers @ 2005-11-15 18:21 UTC (permalink / raw)
  Cc: emacs-devel

Alan Mackenzie wrote:
 > On Mon, 14 Nov 2005, Kevin Rodgers wrote:
 > > I still think it would be better to include functions that follow the
 > > major mode conventions than to exclude functions that don't follow the
 > > minor mode conventions.  The Emacs Lisp manual has nodes describing 
both
 > > sets of conventions.
 >
 > It is impossible to create a list of major modes, because a major mode is
 > simply a lisp function, with nothing definitive to distinguish it from
 > any other lisp function.

Yes.  We have been discussing heuristics that could be used in the
absence of a definitive test.

 > So how about having a property `emacs-mode' on symbols, with valid values
 > (major minor major-minor nil)?  Getting a list of major modes would then
 > be trivial.  (OK, for Emacs 23. ;-)

Did you mean (major minor global-minor nil)?

-- 
Kevin Rodgers

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

* Re: List of major modes?
  2005-11-15 16:36         ` Lennart Borgman
@ 2005-11-15 23:19           ` Stefan Monnier
  2005-11-15 23:22           ` Richard M. Stallman
  1 sibling, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2005-11-15 23:19 UTC (permalink / raw)
  Cc: Kevin Rodgers, rms, emacs-devel

> But is information about arguments available for autoloaded functions that
> has not been loaded yet?

Sometimes, yes.  See all the "(fn ...)" at the end of doctrings in
loaddefs.el.


        Stefan

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

* Re: List of major modes?
  2005-11-15 10:22       ` Alan Mackenzie
  2005-11-15 18:21         ` Kevin Rodgers
@ 2005-11-15 23:22         ` Richard M. Stallman
  2005-11-16 17:20         ` David Reitter
  2 siblings, 0 replies; 18+ messages in thread
From: Richard M. Stallman @ 2005-11-15 23:22 UTC (permalink / raw)
  Cc: ihs_4664, help-gnu-emacs, emacs-devel

    So how about having a property `emacs-mode' on symbols, with valid values
    (major minor major-minor nil)?  Getting a list of major modes would then
    be trivial.  (OK, for Emacs 23. ;-)

That is straightforward, but it would be substantial trouble.
Is it worth the trouble?

What benefit would it provide?  What was the reason for asking
for this?

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

* Re: List of major modes?
  2005-11-15 16:36         ` Lennart Borgman
  2005-11-15 23:19           ` Stefan Monnier
@ 2005-11-15 23:22           ` Richard M. Stallman
  1 sibling, 0 replies; 18+ messages in thread
From: Richard M. Stallman @ 2005-11-15 23:22 UTC (permalink / raw)
  Cc: ihs_4664, emacs-devel

    But is information about arguments available for autoloaded functions 
    that has not been loaded yet?

No, it isn't.  So my proposal won't work.

Thanks.

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

* Re: List of major modes?
  2005-11-15 10:22       ` Alan Mackenzie
  2005-11-15 18:21         ` Kevin Rodgers
  2005-11-15 23:22         ` Richard M. Stallman
@ 2005-11-16 17:20         ` David Reitter
  2005-11-17 14:07           ` Richard M. Stallman
  2 siblings, 1 reply; 18+ messages in thread
From: David Reitter @ 2005-11-16 17:20 UTC (permalink / raw)
  Cc: Kevin Rodgers, Emacs-Devel '

On 15 Nov 2005, at 10:22, Alan Mackenzie wrote:

> So how about having a property `emacs-mode' on symbols, with valid  
> values
> (major minor major-minor nil)?  Getting a list of major modes would  
> then
> be trivial.  (OK, for Emacs 23. ;-)

How do you make third-party packages compatible without forcing them  
to update their modes?

Richard Stallman wrote:

> That is straightforward, but it would be substantial trouble.
> Is it worth the trouble?
>
> What benefit would it provide?  What was the reason for asking
> for this?

This thread started a while ago when I was asking for a function that  
would give me a list of major mode. What I wanted to write has a  
"switch-to-major-mode" function which would offer - via a completions  
list - a good overview of what modes are available. I think that  
would benefit new users who would be able to explore Emacs that way.

It was found that there was no clean and reliable way to find all  
installed major modes.

Honestly, I don't think implementing a complex mechanism is worth the  
trouble for Emacs 22 at this point. Existing modes wouldn't be  
compatible anyways. The above "newbie function" is probably not that  
important right now.

What might make sense is to add the above property  as a  
recommendation to the mode conventions, pointing out that this will  
be a requirement for Emacs 23 modes.

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

* Re: List of major modes?
  2005-11-16 17:20         ` David Reitter
@ 2005-11-17 14:07           ` Richard M. Stallman
  2005-11-17 17:16             ` Lennart Borgman
  0 siblings, 1 reply; 18+ messages in thread
From: Richard M. Stallman @ 2005-11-17 14:07 UTC (permalink / raw)
  Cc: acm, ihs_4664, emacs-devel

    This thread started a while ago when I was asking for a function that  
    would give me a list of major mode. What I wanted to write has a  
    "switch-to-major-mode" function which would offer - via a completions  
    list - a good overview of what modes are available. I think that  
    would benefit new users who would be able to explore Emacs that way.

It doesn't seem terribly important.  I think that anyone who wants to
explore this way will want to look at the modes' doc strings anyway,
and those will show which ones are major modes.  You can do this just
fine with C-h a mode$, so a new feature would provide little benefit.

    What might make sense is to add the above property  as a  
    recommendation to the mode conventions, pointing out that this will  
    be a requirement for Emacs 23 modes.

That would be a lot of work for a lot of people.  My decision is to do
nothing about this.

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

* Re: List of major modes?
  2005-11-17 14:07           ` Richard M. Stallman
@ 2005-11-17 17:16             ` Lennart Borgman
  2005-11-20  1:22               ` Juri Linkov
  0 siblings, 1 reply; 18+ messages in thread
From: Lennart Borgman @ 2005-11-17 17:16 UTC (permalink / raw)
  Cc: David Reitter, emacs-devel

Richard M. Stallman wrote:

>It doesn't seem terribly important.  I think that anyone who wants to
>explore this way will want to look at the modes' doc strings anyway,
>and those will show which ones are major modes.  You can do this just
>fine with C-h a mode$, so a new feature would provide little benefit.
>
The functionality to show the doc strings from the *Apropos* buffer is 
very good. Should it not be more visible and easy to use for beginners? 
Would it not be easier for them (and many others too) if the the links 
looked the same way as those in the *info* buffer? I believe it would 
help in a case like that we are discussing here.

BTW I would prefer that the links in the *Help* buffer also looked the same.

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

* Re: List of major modes?
  2005-11-17 17:16             ` Lennart Borgman
@ 2005-11-20  1:22               ` Juri Linkov
  2005-11-20 23:22                 ` Richard M. Stallman
  0 siblings, 1 reply; 18+ messages in thread
From: Juri Linkov @ 2005-11-20  1:22 UTC (permalink / raw)
  Cc: david.reitter, rms, emacs-devel

> The functionality to show the doc strings from the *Apropos* buffer is
> very good. Should it not be more visible and easy to use for beginners?
> Would it not be easier for them (and many others too) if the the link
> looked the same way as those in the *info* buffer? I believe it would
> help in a case like that we are discussing here.
>
> BTW I would prefer that the links in the *Help* buffer also looked the same.

Links highlighted in blue stand out more than underlined argument names.
But using a foreground color for argument names might help avoid this problem.
IMO, the following colors for the Help buffer looks good:

  (set-face-foreground 'button "blue")
  (set-face-attribute 'help-argument-name nil
                      :inherit '(font-lock-constant-face italic))

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: List of major modes?
  2005-11-20  1:22               ` Juri Linkov
@ 2005-11-20 23:22                 ` Richard M. Stallman
  0 siblings, 0 replies; 18+ messages in thread
From: Richard M. Stallman @ 2005-11-20 23:22 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel, david.reitter

Please let's not discuss changes in faces for apropos now.
This is not a bug fix, and not a new feature, and not terribly
important.

How about instead debugging one of the recent bug reports?

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

end of thread, other threads:[~2005-11-20 23:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <DNEMKBNJBGPAOPIJOOICEEKJCOAA.drew.adams@oracle.com>
2005-11-11 19:12 ` List of major modes? Lennart Borgman
2005-11-11 21:51   ` David Reitter
2005-11-11 22:18     ` Lennart Borgman
2005-11-14 16:26     ` Kevin Rodgers
2005-11-14 16:40       ` Lennart Borgman
2005-11-14 19:32         ` Stefan Monnier
2005-11-15  5:43       ` Richard M. Stallman
2005-11-15 16:36         ` Lennart Borgman
2005-11-15 23:19           ` Stefan Monnier
2005-11-15 23:22           ` Richard M. Stallman
2005-11-15 10:22       ` Alan Mackenzie
2005-11-15 18:21         ` Kevin Rodgers
2005-11-15 23:22         ` Richard M. Stallman
2005-11-16 17:20         ` David Reitter
2005-11-17 14:07           ` Richard M. Stallman
2005-11-17 17:16             ` Lennart Borgman
2005-11-20  1:22               ` Juri Linkov
2005-11-20 23:22                 ` Richard M. Stallman

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