unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Cancel enabling of minor-mode.
@ 2013-11-27  8:27 Constantin Kulikov
  2013-11-27 20:53 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Constantin Kulikov @ 2013-11-27  8:27 UTC (permalink / raw)
  To: help-gnu-emacs

Can I somehow cancel enabling of my minor-mode?

Example of what I want:

(define-minor-mode test-mode
    "documentation"
    :init-value nil
    (if test-mode
        (if some-condition
            cancel enabling of test-mode. exit
          actions-when-enabling)
      actions-when-disabling))


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

* Re: Cancel enabling of minor-mode.
  2013-11-27  8:27 Cancel enabling of minor-mode Constantin Kulikov
@ 2013-11-27 20:53 ` Stefan Monnier
  2013-11-28 12:22   ` Nicolas Richard
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-11-27 20:53 UTC (permalink / raw)
  To: help-gnu-emacs

> Can I somehow cancel enabling of my minor-mode?
> Example of what I want:

> (define-minor-mode test-mode
>     "documentation"
>     :init-value nil
>     (if test-mode
>         (if some-condition
>             cancel enabling of test-mode. exit
>           actions-when-enabling)
>       actions-when-disabling))

To cancel, you can (setq test-mode nil).


        Stefan




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

* Re: Cancel enabling of minor-mode.
  2013-11-27 20:53 ` Stefan Monnier
@ 2013-11-28 12:22   ` Nicolas Richard
  2013-11-28 15:06     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Richard @ 2013-11-28 12:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

>> Can I somehow cancel enabling of my minor-mode?
>
> To cancel, you can (setq test-mode nil).

IIUC, it will still run any hook associated with the mode like for any
mode change (+ show the message "Test mode disabled"). Not too bad, but
not exactly like cancelling either. Perhaps some (user-error ...) would
be ok in that case ?

Otherwise, the OP could define a helper function `test-mode-maybe'
which would check and only activate if it's ok.

-- 
Nico.



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

* Re: Cancel enabling of minor-mode.
  2013-11-28 12:22   ` Nicolas Richard
@ 2013-11-28 15:06     ` Stefan Monnier
       [not found]       ` <CAFkz2yo0dCmyoyNZanfG3e8Rj0V-aEanxevThLntWSE_zDQUKQ@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-11-28 15:06 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: help-gnu-emacs

> IIUC, it will still run any hook associated with the mode like for any
> mode change (+ show the message "Test mode disabled"). Not too bad, but
> not exactly like cancelling either.

I guess it depends on your definition of "canceling".


        Stefan



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

* Re: Cancel enabling of minor-mode.
       [not found]       ` <CAFkz2yo0dCmyoyNZanfG3e8Rj0V-aEanxevThLntWSE_zDQUKQ@mail.gmail.com>
@ 2013-11-28 17:17         ` Constantin Kulikov
  0 siblings, 0 replies; 5+ messages in thread
From: Constantin Kulikov @ 2013-11-28 17:17 UTC (permalink / raw)
  To: help-gnu-emacs

> it depends on your definition of "canceling"
As for me the (setq test-mode nil) works as I want. Thanks.

// But also it would be nice if I can avoid running hooks.


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

end of thread, other threads:[~2013-11-28 17:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-27  8:27 Cancel enabling of minor-mode Constantin Kulikov
2013-11-27 20:53 ` Stefan Monnier
2013-11-28 12:22   ` Nicolas Richard
2013-11-28 15:06     ` Stefan Monnier
     [not found]       ` <CAFkz2yo0dCmyoyNZanfG3e8Rj0V-aEanxevThLntWSE_zDQUKQ@mail.gmail.com>
2013-11-28 17:17         ` Constantin Kulikov

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