unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* /etc/TODO: define-minor-mode & minor-mode-list
@ 2012-02-01  2:05 William Stevenson
  2012-02-01  2:32 ` Juanma Barranquero
  2012-02-01 14:06 ` Stefan Monnier
  0 siblings, 2 replies; 13+ messages in thread
From: William Stevenson @ 2012-02-01  2:05 UTC (permalink / raw)
  To: emacs-devel

Looking in the TODO file for a beginner item I started with:

** Check what minor modes don't use define-minor-mode and convert them
to use it.

I'm confused about minor-mode-list. Why are some minor-modes added in
the definition even though they are defined with define-minor-mode? 
I also found that abbrev-mode remained in the list if it was removed 
from this definition.

Also is this todo considered todone?


;; If a minor mode is not defined with define-minor-mode,
;; add it here explicitly.
;; isearch-mode is deliberately excluded, since you should
;; not call it yourself.
(defvar minor-mode-list '(auto-save-mode auto-fill-mode abbrev-mode
					 overwrite-mode view-mode
                                         hs-minor-mode)
  "List of all minor mode functions.")




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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01  2:05 /etc/TODO: define-minor-mode & minor-mode-list William Stevenson
@ 2012-02-01  2:32 ` Juanma Barranquero
  2012-02-01  2:46   ` William Stevenson
  2012-02-01  3:14   ` Chong Yidong
  2012-02-01 14:06 ` Stefan Monnier
  1 sibling, 2 replies; 13+ messages in thread
From: Juanma Barranquero @ 2012-02-01  2:32 UTC (permalink / raw)
  To: William Stevenson; +Cc: emacs-devel

On Wed, Feb 1, 2012 at 03:05, William Stevenson <yhvh2000@gmail.com> wrote:

> I'm confused about minor-mode-list. Why are some minor-modes added in
> the definition even though they are defined with define-minor-mode?

Likely because these minor modes were converted to use
define-minor-mode, but not removed from minor-mode-list.

> I also found that abbrev-mode remained in the list if it was removed
> from this definition.

define-minor-mode (conditionally) calls add-minor-mode, which does

  (unless (memq toggle minor-mode-list)
    (push toggle minor-mode-list))

so minor modes defined with define-minor-mode will end in the list.
For preloaded minor modes, that's already so:

 emacs -Q --batch --eval "(princ (length minor-mode-list))"  => 30

> Also is this todo considered todone?

There are 300+ instances of "(defun .*-mode " in the sources. Not all
are really modes, and many are major modes, but surely there are still
unconverted minor modes.

    Juanma



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01  2:32 ` Juanma Barranquero
@ 2012-02-01  2:46   ` William Stevenson
  2012-02-01  3:39     ` Juanma Barranquero
  2012-02-01  3:14   ` Chong Yidong
  1 sibling, 1 reply; 13+ messages in thread
From: William Stevenson @ 2012-02-01  2:46 UTC (permalink / raw)
  To: emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> On Wed, Feb 1, 2012 at 03:05, William Stevenson <yhvh2000@gmail.com> wrote:
>
>> I'm confused about minor-mode-list. Why are some minor-modes added in
>> the definition even though they are defined with define-minor-mode?
>
> Likely because these minor modes were converted to use
> define-minor-mode, but not removed from minor-mode-list.
>
>> I also found that abbrev-mode remained in the list if it was removed
>> from this definition.
>
> define-minor-mode (conditionally) calls add-minor-mode, which does
>
>   (unless (memq toggle minor-mode-list)
>     (push toggle minor-mode-list))
>
> so minor modes defined with define-minor-mode will end in the list.
> For preloaded minor modes, that's already so:
>
>  emacs -Q --batch --eval "(princ (length minor-mode-list))"  => 30

Sorry, I didn't explain clearly. I found that abbrev-mode was the _only_
mode that could be removed from the definition and still end up in the
list. And my confusion arose from my inability to see what caused this
when all 5 of these modes are defined using define-minor-mode.

For example:

(defvar minor-mode-list '()
  "List of all minor mode functions.")

emacs -Q --batch --eval "(princ (length minor-mode-list))"  => 25


>> Also is this todo considered todone?
>
> There are 300+ instances of "(defun .*-mode " in the sources. Not all
> are really modes, and many are major modes, but surely there are still
> unconverted minor modes.

Thanks for your reply, I will do a thorough search.




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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01  2:32 ` Juanma Barranquero
  2012-02-01  2:46   ` William Stevenson
@ 2012-02-01  3:14   ` Chong Yidong
  1 sibling, 0 replies; 13+ messages in thread
From: Chong Yidong @ 2012-02-01  3:14 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: William Stevenson, emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> There are 300+ instances of "(defun .*-mode " in the sources. Not all
> are really modes, and many are major modes, but surely there are still
> unconverted minor modes.

Probably many of those major modes should use define-derived-mode and
inherit from text-mode/prog-mode/special-mode.



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01  2:46   ` William Stevenson
@ 2012-02-01  3:39     ` Juanma Barranquero
  0 siblings, 0 replies; 13+ messages in thread
From: Juanma Barranquero @ 2012-02-01  3:39 UTC (permalink / raw)
  To: William Stevenson; +Cc: emacs-devel

On Wed, Feb 1, 2012 at 03:46, William Stevenson <yhvh2000@gmail.com> wrote:

> Sorry, I didn't explain clearly. I found that abbrev-mode was the _only_
> mode that could be removed from the definition and still end up in the
> list. And my confusion arose from my inability to see what caused this
> when all 5 of these modes are defined using define-minor-mode.

These modes are all auto-loaded, but if you look at the definition of
define-minor-mode, you'll see that the part that invokes
add-minor-mode (and so, sets minor-mode-list) is not autoloaded (it's
after :autoload-end). So these modes do not enter into minor-mode-list
until they are run. I haven't checked, but I suspect that abbrev-mode
is run at some point during initialization and so it does enter the
list.

    Juanma



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01  2:05 /etc/TODO: define-minor-mode & minor-mode-list William Stevenson
  2012-02-01  2:32 ` Juanma Barranquero
@ 2012-02-01 14:06 ` Stefan Monnier
  2012-02-01 14:53   ` Juanma Barranquero
                     ` (2 more replies)
  1 sibling, 3 replies; 13+ messages in thread
From: Stefan Monnier @ 2012-02-01 14:06 UTC (permalink / raw)
  To: William Stevenson; +Cc: emacs-devel

> Also is this todo considered todone?

Largely, yes.  I did this during the Emacs-24 development (which lead to
the addition of the `:variable' argument).  My methodology to find
potential minor modes was to grep for something like "defun.*-mode
([^)]" since traditionally minor modes take an argument, whereas major
modes don't.  There are a few cases I found which I haven't converted,
usually because the conversion was less straightforward so I left it
for later.  These are: orgstruct++-mode, tcl-auto-fill-mode,
vhdl-hs-minor-mode, speedbar-frame-mode, reftex-isearch-minor-mode,
type-break-mode.
There are probably other candidates, of course.

As already mentioned, most/all "*-mode" functions should not be defined
with `defun' but with one of define-*-mode.


        Stefan



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01 14:06 ` Stefan Monnier
@ 2012-02-01 14:53   ` Juanma Barranquero
  2012-02-01 15:14     ` Stefan Monnier
  2012-02-02  0:56   ` Juri Linkov
  2012-02-02  6:57   ` William Stevenson
  2 siblings, 1 reply; 13+ messages in thread
From: Juanma Barranquero @ 2012-02-01 14:53 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: William Stevenson, emacs-devel

On Wed, Feb 1, 2012 at 15:06, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Largely, yes.  I did this during the Emacs-24 development (which lead to
> the addition of the `:variable' argument).

Then, to address one of the OP's points, shouldn't these
newly-converted modes be removed from minor-mode-list?

    Juanma



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01 14:53   ` Juanma Barranquero
@ 2012-02-01 15:14     ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2012-02-01 15:14 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: William Stevenson, emacs-devel

>> Largely, yes.  I did this during the Emacs-24 development (which lead to
>> the addition of the `:variable' argument).
> Then, to address one of the OP's points, shouldn't these
> newly-converted modes be removed from minor-mode-list?

I think so, yes.


        Stefan



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01 14:06 ` Stefan Monnier
  2012-02-01 14:53   ` Juanma Barranquero
@ 2012-02-02  0:56   ` Juri Linkov
  2012-02-02  6:57   ` William Stevenson
  2 siblings, 0 replies; 13+ messages in thread
From: Juri Linkov @ 2012-02-02  0:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: William Stevenson, emacs-devel

> There are a few cases I found which I haven't converted,
> usually because the conversion was less straightforward so I left it
> These are: orgstruct++-mode, tcl-auto-fill-mode,
> vhdl-hs-minor-mode, speedbar-frame-mode, reftex-isearch-minor-mode,

ISTR, `reftex-isearch-minor-mode' is kept only for backward
compatibility with Emacs 22.  In later versions, it can be replaced
with a single variable `multi-isearch-next-buffer-function'.



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-01 14:06 ` Stefan Monnier
  2012-02-01 14:53   ` Juanma Barranquero
  2012-02-02  0:56   ` Juri Linkov
@ 2012-02-02  6:57   ` William Stevenson
  2012-02-02 18:40     ` Stefan Monnier
  2012-02-02 21:14     ` Juri Linkov
  2 siblings, 2 replies; 13+ messages in thread
From: William Stevenson @ 2012-02-02  6:57 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Also is this todo considered todone?
>
> Largely, yes.  I did this during the Emacs-24 development (which lead to
> the addition of the `:variable' argument).  My methodology to find
> potential minor modes was to grep for something like "defun.*-mode
> ([^)]" since traditionally minor modes take an argument, whereas major
> modes don't.  There are a few cases I found which I haven't converted,
> usually because the conversion was less straightforward so I left it
> for later.  These are: orgstruct++-mode, tcl-auto-fill-mode,
> vhdl-hs-minor-mode, speedbar-frame-mode, reftex-isearch-minor-mode,
> type-break-mode.
> There are probably other candidates, of course.


I searched for more but I've probably unearthed more false positives
than anything else. I'll hopefully have at least one patch by the end of
the week.



| file                    | mode name                             | d-m-m | d-d-m | notes |
|-------------------------+---------------------------------------+-------+-------+-------|
| org/org.el              | orgstruct++-mode                      | y     |       |       |
| progmodes/tcl.el        | tcl-auto-fill-mode                    | y     |       |       |
| speedbar.el             | speedbar-frame-mode                   |       |       | ?     |
| reftex-global.el        | reftex-isearch-minor-mode             | y     |       | ?     |
| progmodes/vhdl-mode.el  | vhdl-hs-minor-mode                    | y     |       | ?     |
| textmodes/two-column.el | 2C-mode                               | y     |       |       |
| textmodes/artist.el     | artist-mode                           | y     |       |       |
| emulation/edt.el        | edt-select-mode                       |       |       | m/M?  |
| ehelp.el                | electric-help-orig-major-mode         | y     |       | ?     |
| eshell/esh-mode.el      | eshell-mode                           |       |       | m/M?  |
| textmodes/fill.el       | fill-indent-according-to-mode         | ?     | ?     |       |
| font-lock.el            | font-lock-major-mode                  | ?     | ?     |       |
| gnus/gnus-agent.el      | gnus-agent-mode                       | y     |       |       |
| gnus/gnus-start.el      | gnus-slave-mode                       | y     |       | FIXME |
| gnus/gnus-topic.el      | gnus-topic-mode                       | y     |       | FIXME |
| ido.el                  | ido-mode                              | y     |       |       |
| image-mode.el           | image-mode                            |       | y     |       |
| info-look.el            | info-lookup-mode                      |       |       | ?     |
| jit-lock.el             | jit-lock-mode                         | y     |       | ?     |
| avoid.el                | mouse-avoidance-mode                  | y     |       | ?     |
| net/rcirc.el            | rcirc-mode                            |       | y     | FIXME |
| nxml/rng-valid.el       | rng-validate-mode                     | y     |       |       |
| international/robin.el  | robin-mode                            |       |       | m/M?  |
| shell.el                | shell                                 |       |       | m/M?  |
| term.el                 | term-insert-mode                      |       |       | ?     |
| type-break.el           | type-break-mode                       | y     |       |       |
| uniquify.el             | uniquify-list-buffers-directory-modes |       |       | ?     |
| emulation/vi.el         | vi-mode-old-major-mode                |       | y     | old?  |
| winner.el               | winner-mode                           | y     |       |       |
|-------------------------+---------------------------------------+-------+-------+-------|




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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-02  6:57   ` William Stevenson
@ 2012-02-02 18:40     ` Stefan Monnier
  2012-02-02 21:14     ` Juri Linkov
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2012-02-02 18:40 UTC (permalink / raw)
  To: William Stevenson; +Cc: emacs-devel

>>> Also is this todo considered todone?
>> Largely, yes.  I did this during the Emacs-24 development (which lead to
>> the addition of the `:variable' argument).  My methodology to find
>> potential minor modes was to grep for something like "defun.*-mode
>> ([^)]" since traditionally minor modes take an argument, whereas major
>> modes don't.  There are a few cases I found which I haven't converted,
>> usually because the conversion was less straightforward so I left it
>> for later.  These are: orgstruct++-mode, tcl-auto-fill-mode,
>> vhdl-hs-minor-mode, speedbar-frame-mode, reftex-isearch-minor-mode,
>> type-break-mode.
>> There are probably other candidates, of course.
> I searched for more but I've probably unearthed more false positives
> than anything else. I'll hopefully have at least one patch by the end of
> the week.

Just to give you an idea of the kinds of problems you might have to deal
with: changing orgstruct++-mode to use define-minor-mode should be
fairly easy with the new `:variable' argument, but I suspect that the
Org guys won't be happy with this since they want their code to work
under Emacs-23 as well.


        Stefan



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-02  6:57   ` William Stevenson
  2012-02-02 18:40     ` Stefan Monnier
@ 2012-02-02 21:14     ` Juri Linkov
  2012-02-04 13:49       ` Johan Bockgård
  1 sibling, 1 reply; 13+ messages in thread
From: Juri Linkov @ 2012-02-02 21:14 UTC (permalink / raw)
  To: William Stevenson; +Cc: emacs-devel

> | file                    | mode name                             | d-m-m | d-d-m | notes |
> |-------------------------+---------------------------------------+-------+-------+-------|
> | [...]
> | image-mode.el           | image-mode                            |       | y     |       |

I suppose you intend to derive `image-mode' from `special-mode'.
Then perhaps `doc-view-mode' should be derived from `image-mode'.

Also `archive-mode' could derive from `special-mode',
because `tar-mode' already derives from 'special-mode'.



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

* Re: /etc/TODO: define-minor-mode & minor-mode-list
  2012-02-02 21:14     ` Juri Linkov
@ 2012-02-04 13:49       ` Johan Bockgård
  0 siblings, 0 replies; 13+ messages in thread
From: Johan Bockgård @ 2012-02-04 13:49 UTC (permalink / raw)
  To: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> I suppose you intend to derive `image-mode' from `special-mode'.
> Then perhaps `doc-view-mode' should be derived from `image-mode'.
>
> Also `archive-mode' could derive from `special-mode',
> because `tar-mode' already derives from 'special-mode'.

Note that many of the modes in this discussion are intentionally
non-interactive, and define-minor-mode/define-derived-mode don't have a
way to specify that.




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

end of thread, other threads:[~2012-02-04 13:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01  2:05 /etc/TODO: define-minor-mode & minor-mode-list William Stevenson
2012-02-01  2:32 ` Juanma Barranquero
2012-02-01  2:46   ` William Stevenson
2012-02-01  3:39     ` Juanma Barranquero
2012-02-01  3:14   ` Chong Yidong
2012-02-01 14:06 ` Stefan Monnier
2012-02-01 14:53   ` Juanma Barranquero
2012-02-01 15:14     ` Stefan Monnier
2012-02-02  0:56   ` Juri Linkov
2012-02-02  6:57   ` William Stevenson
2012-02-02 18:40     ` Stefan Monnier
2012-02-02 21:14     ` Juri Linkov
2012-02-04 13:49       ` Johan Bockgård

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