all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Hook on other minor modes
@ 2023-06-26 19:20 uzibalqa
  2023-06-26 19:28 ` [External] : " Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: uzibalqa @ 2023-06-26 19:20 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor

What does the following do ?

(add-hook 'outline-minor-mode-hook 'tika-minor-mode nil t)

Does it enable tika-minor-mode when outline-minor-mode gets activated




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

* RE: [External] : Hook on other minor modes
  2023-06-26 19:20 Hook on other minor modes uzibalqa
@ 2023-06-26 19:28 ` Drew Adams
  2023-06-26 19:42   ` uzibalqa
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2023-06-26 19:28 UTC (permalink / raw)
  To: uzibalqa, 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

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

> What does the following do ?
> 
> (add-hook 'outline-minor-mode-hook 'tika-minor-mode nil t)
> 
> Does it enable tika-minor-mode when outline-minor-mode gets activated

It enables minor mode `tika-minor-mode' when minor mode `outline-minor-mode' is enabled AND when `outline-minor-mode' is disabled.

See `C-h f define-minor-mode':

 When called from Lisp, the mode command toggles the mode if the
 argument is `toggle', disables the mode if the argument is a
 non-positive integer, and enables the mode otherwise (including
 if the argument is omitted or nil or a positive integer).


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13067 bytes --]

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

* RE: [External] : Hook on other minor modes
  2023-06-26 19:28 ` [External] : " Drew Adams
@ 2023-06-26 19:42   ` uzibalqa
  2023-06-26 21:28     ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: uzibalqa @ 2023-06-26 19:42 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'


------- Original Message -------
On Tuesday, June 27th, 2023 at 7:28 AM, Drew Adams <drew.adams@oracle.com> wrote:


> > What does the following do ?
> > 
> > (add-hook 'outline-minor-mode-hook 'tika-minor-mode nil t)
> > 
> > Does it enable tika-minor-mode when outline-minor-mode gets activated
> 
> 
> It enables minor mode `tika-minor-mode' when minor mode` outline-minor-mode' is enabled AND when `outline-minor-mode' is disabled. See` C-h f define-minor-mode':

It does not seem of much good use then to do such a thing.
 
> When called from Lisp, the mode command toggles the mode if the
> argument is `toggle', disables the mode if the argument is a
> non-positive integer, and enables the mode otherwise (including
> if the argument is omitted or nil or a positive integer).



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

* RE: [External] : Hook on other minor modes
  2023-06-26 19:42   ` uzibalqa
@ 2023-06-26 21:28     ` Drew Adams
  2023-06-26 22:10       ` uzibalqa
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2023-06-26 21:28 UTC (permalink / raw)
  To: uzibalqa; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

> > It enables minor mode `tika-minor-mode' when minor mode` outline-minor-
> mode' is enabled AND when `outline-minor-mode' is disabled. See` C-h f
> define-minor-mode':
> 
> It does not seem of much good use then to do such a thing.

It's useful if you want to provide behavior for when it's enabled OR when it's disabled, OR both.  You can do any of those things.  Pretty useful, I'd say.

But send your suggestions for improvement, with reasons, to `M-x report-emacs-bug'.


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

* RE: [External] : Hook on other minor modes
  2023-06-26 21:28     ` Drew Adams
@ 2023-06-26 22:10       ` uzibalqa
  2023-06-26 23:50         ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: uzibalqa @ 2023-06-26 22:10 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'


------- Original Message -------
On Tuesday, June 27th, 2023 at 9:28 AM, Drew Adams <drew.adams@oracle.com> wrote:


> > > It enables minor mode `tika-minor-mode' when minor mode` outline-minor-
> > > mode' is enabled AND when `outline-minor-mode' is disabled. See` C-h f
> > > define-minor-mode':
> > 
> > It does not seem of much good use then to do such a thing.
> 
> 
> It's useful if you want to provide behavior for when it's enabled OR when it's disabled, OR both. You can do any of those things. Pretty useful, I'd say.

Can't one simply enable something.  Because either way, they does not seem to exist an association
between the two modes - they are completely independent.
 
> But send your suggestions for improvement, with reasons, to `M-x report-emacs-bug'.



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

* RE: [External] : Hook on other minor modes
  2023-06-26 22:10       ` uzibalqa
@ 2023-06-26 23:50         ` Drew Adams
  2023-06-27 14:10           ` uzibalqa
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2023-06-26 23:50 UTC (permalink / raw)
  To: uzibalqa; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

> > > > It enables minor mode `tika-minor-mode' when minor mode `outline-minor-mode' is enabled AND when `outline-minor-mode' is disabled. See` C-h f
> > > > define-minor-mode':
> > It's useful if you want to provide behavior for when it's enabled OR
> when it's disabled, OR both. You can do any of those things. Pretty
> useful, I'd say.
> 
> Can't one simply enable something.

Put a function `foo' on `outline-minor-mode-hook'.  Define `foo' so that it enables `tika-minor-mode when `outline-minor-mode' is non-nil.  That's all it has to do.  Is that so hard?

The point is that by having the hook run when the hook's minor-mode is enabled AND when it's disabled you can do whatever you want.  That includes only enabling some other mode when the hook's mode is enabled.

Simple, flexible, elegant.  Que demande le peuple ?

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

* RE: [External] : Hook on other minor modes
  2023-06-26 23:50         ` Drew Adams
@ 2023-06-27 14:10           ` uzibalqa
  2023-06-27 19:44             ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: uzibalqa @ 2023-06-27 14:10 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'


------- Original Message -------
On Tuesday, June 27th, 2023 at 11:50 AM, Drew Adams <drew.adams@oracle.com> wrote:


> > > > > It enables minor mode `tika-minor-mode' when minor mode` outline-minor-mode' is enabled AND when `outline-minor-mode' is disabled. See` C-h f
> > > > > define-minor-mode':
> > > > > It's useful if you want to provide behavior for when it's enabled OR
> > > > > when it's disabled, OR both. You can do any of those things. Pretty
> > > > > useful, I'd say.
> > 
> > Can't one simply enable something.
> 
> 
> Put a function `foo' on` outline-minor-mode-hook'. Define `foo' so that it enables` tika-minor-mode when `outline-minor-mode' is non-nil. That's all it has to do. Is that so hard?  

It is the thing that makes sense.

Had been concentrated upon 

(add-hook 'outline-minor-mode 'tika-minor-mode)

which could produce unintended consequences if one wants to activate tika-minor-mode 
only when outline-minor-mode is activated.

-------------

For things like

(add-hook 'fortran-mode-hook #'tika-minor-mode)

where I want to enable tika-minor-mode when fortran mode is enabled.  Would you
suggest using a function that checks whether fortran-mode is activated ?





 
> The point is that by having the hook run when the hook's minor-mode is enabled AND when it's disabled you can do whatever you want. That includes only enabling some other mode when the hook's mode is enabled.
> 
> Simple, flexible, elegant. Que demande le peuple ?



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

* RE: [External] : Hook on other minor modes
  2023-06-27 14:10           ` uzibalqa
@ 2023-06-27 19:44             ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2023-06-27 19:44 UTC (permalink / raw)
  To: uzibalqa; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

> For things like
> 
> (add-hook 'fortran-mode-hook #'tika-minor-mode)
> 
> where I want to enable tika-minor-mode when fortran mode is enabled.
> Would you
> suggest using a function that checks whether fortran-mode is activated ?

Fortran mode is a major mode, so no.
Its hook is run only when the mode is enabled.

Ask Emacs: 

https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Hooks.html

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

end of thread, other threads:[~2023-06-27 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-26 19:20 Hook on other minor modes uzibalqa
2023-06-26 19:28 ` [External] : " Drew Adams
2023-06-26 19:42   ` uzibalqa
2023-06-26 21:28     ` Drew Adams
2023-06-26 22:10       ` uzibalqa
2023-06-26 23:50         ` Drew Adams
2023-06-27 14:10           ` uzibalqa
2023-06-27 19:44             ` Drew Adams

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.