all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ messages in thread

* Re: Cancel enabling of minor-mode.
  2013-11-28 12:22   ` Nicolas Richard
@ 2013-11-28 15:06     ` Stefan Monnier
  2013-11-28 17:13       ` Constantin Kulikov
  0 siblings, 1 reply; 7+ 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] 7+ messages in thread

* Re: Cancel enabling of minor-mode.
  2013-11-28 15:06     ` Stefan Monnier
@ 2013-11-28 17:13       ` Constantin Kulikov
  2013-11-28 17:17         ` Constantin Kulikov
  2013-11-28 17:22         ` Constantin Kulikov
  0 siblings, 2 replies; 7+ messages in thread
From: Constantin Kulikov @ 2013-11-28 17:13 UTC (permalink / raw)
  To: Stefan Monnier, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

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



On 28 November 2013 19:06, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

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

[-- Attachment #2: Type: text/html, Size: 1008 bytes --]

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

* Re: Cancel enabling of minor-mode.
  2013-11-28 17:13       ` Constantin Kulikov
@ 2013-11-28 17:17         ` Constantin Kulikov
  2013-11-28 17:22         ` Constantin Kulikov
  1 sibling, 0 replies; 7+ 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] 7+ messages in thread

* Re: Cancel enabling of minor-mode.
  2013-11-28 17:13       ` Constantin Kulikov
  2013-11-28 17:17         ` Constantin Kulikov
@ 2013-11-28 17:22         ` Constantin Kulikov
  1 sibling, 0 replies; 7+ messages in thread
From: Constantin Kulikov @ 2013-11-28 17:22 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 90 bytes --]

sorry, sent to wrong adress,
autocomplete fail :(
Please delete this thread or ignore it.

[-- Attachment #2: Type: text/html, Size: 136 bytes --]

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

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

Thread overview: 7+ 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
2013-11-28 17:13       ` Constantin Kulikov
2013-11-28 17:17         ` Constantin Kulikov
2013-11-28 17:22         ` Constantin Kulikov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.