unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Platon Pronko <platon7pronko@gmail.com>
To: uzibalqa <uzibalqa@proton.me>,
	uzibalqa via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: add-hook without need for intermediate functions
Date: Sat, 10 Jun 2023 16:20:48 +0800	[thread overview]
Message-ID: <86d4a1ab-3214-f8be-62f2-2f68c9ae1cf2@gmail.com> (raw)
In-Reply-To: <lVCijGXhhEWJmzNLYC4UwTaSixb6QR869aYvZ8gew048BTKaxdbjp7rytoSXayTRpcxpK6qoYF0cAwHnSIO5kH3YC5eADU5URLHQHCsWs_k=@proton.me>

On 2023-06-09 23:48, uzibalqa wrote:
> 
> I have seen that since Emacs 24.1 one does not need the intermediate 'turn-on-foo-mode'
> style functions when using hooks.
> 
> Does this apply to all modes, including minor modes ?
> 
> And thusly one can write
> 
> (add-hook 'emacs-lisp-mode-hook #'foo-minor-mode)
> 
> 
> 

foo-minor-mode is just a function, so it is called when hook executes. Any other modes that are turned on via a single function call will also "work".

However note that this won't work for your use-case (from previous thread) - hook is called both when mode is turned on, and when it is turned off. So in your code snippet foo-minor-mode will be turned on when emacs-lisp-mode is turned off, which is probably not something you would want.

-- 
Best regards,
Platon Pronko
PGP 2A62D77A7A2CB94E




  parent reply	other threads:[~2023-06-10  8:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 15:48 add-hook without need for intermediate functions uzibalqa
2023-06-09 16:56 ` [External] : " Drew Adams
2023-06-09 17:05   ` uzibalqa
2023-06-09 17:15     ` Drew Adams
2023-06-09 17:30       ` uzibalqa
2023-06-09 20:07       ` Emanuel Berg
2023-06-10 21:05         ` Drew Adams
2023-06-10  8:20 ` Platon Pronko [this message]
2023-06-10 15:21   ` uzibalqa
2023-06-11  1:37     ` Platon Pronko

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=86d4a1ab-3214-f8be-62f2-2f68c9ae1cf2@gmail.com \
    --to=platon7pronko@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=uzibalqa@proton.me \
    /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.
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).