unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: [drew.adams@oracle.com: Info on define-minor-mode - :init-value or :initial-value?]
Date: Fri, 29 Jul 2005 13:10:14 -0400	[thread overview]
Message-ID: <jwvslxxzgtp.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <200507290148.j6T1m9j18171@raven.dms.auburn.edu> (Luc Teirlinck's message of "Thu, 28 Jul 2005 20:48:09 -0500 (CDT)")

>> There is more.  You can not specify a non-nil :init-value, unless
>> either the minor mode is enabled by just setting the variable or
>> unless you do something extra.

>    In what way is this a limitation?
>    I.e. if you don't use define-minor-mode, how would you do it differently?
>    [ I don't mean to say that "manual" code can't do it differently, but
>    that if it does it differently, it'll most likely break the convention
>    that just loading a file shouldn't make any visible changes. ]

> Suppose that you have a minor mode that only makes a difference when
> you are using the speedbar.  (I just take this as an example; any
> option that is itself not enabled by default will do.)  The minor mode
> would be part of the intended default behavior of speedbar, but not
> everybody might like it, hence the need for a defcustom with default
> t.  You use `custom-initialize-set' as the :initialize function.  You
> put the minor mode code in speedbar.el.  Now loading speedbar.el will
> enable the minor mode, unless the user overwrote that by setting the
> minor mode variable to nil.  However, this will not change the behavior
> of Emacs in any way that is unrelated to the speedbar.

That's an interesting case indeed.
With define-minor-mode you'd have to add

  (if foo-mode (foo-mode 1))

at the end of the file.  It may not be the best solution, but it doesn't
seem much worse than using custom-initialize-set since it saves you from
having to worry about the ordering of defcustoms and defuns and it makes it
very clear that code is run at the toplevel and that it thus needs to be
checked for "no visible effect".


        Stefan

      reply	other threads:[~2005-07-29 17:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-27 14:57 [drew.adams@oracle.com: Info on define-minor-mode - :init-value or :initial-value?] Richard M. Stallman
2005-07-27 16:04 ` Luc Teirlinck
2005-07-28 16:58   ` Stefan Monnier
2005-07-28 17:43     ` [drew.adams@oracle.com: Info on define-minor-mode - :init-valueor :initial-value?] Drew Adams
2005-07-29  2:56       ` Luc Teirlinck
2005-07-30 23:44         ` Richard M. Stallman
2005-07-31  0:43           ` Luc Teirlinck
2005-07-31 14:58             ` Juanma Barranquero
2005-08-01  0:45             ` Richard M. Stallman
2005-08-01  1:47               ` Luc Teirlinck
2005-08-01  5:33               ` Juanma Barranquero
2005-08-01 16:46                 ` Richard M. Stallman
2005-07-31  1:02           ` Luc Teirlinck
2005-08-01  0:45             ` Richard M. Stallman
2005-07-29 15:59       ` Stefan Monnier
2005-07-29 17:43         ` Drew Adams
2005-07-30  4:22         ` Luc Teirlinck
2005-07-30 13:58           ` [drew.adams@oracle.com: Info on define-minor-mode -:init-valueor :initial-value?] Drew Adams
2005-07-30 21:46             ` Luc Teirlinck
2005-07-29  1:48     ` [drew.adams@oracle.com: Info on define-minor-mode - :init-value or :initial-value?] Luc Teirlinck
2005-07-29 17:10       ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvslxxzgtp.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).