all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kelly Dean <kellydeanch@yahoo.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Unreferenced symbols in closures, and a problem with closures in minor modes
Date: Tue, 28 May 2013 21:44:43 -0700 (PDT)	[thread overview]
Message-ID: <1369802683.65041.YahooMailClassic@web141102.mail.bf1.yahoo.com> (raw)

Stefan Monnier wrote:
[...]
> To add&remove functions from hooks, it's much better to make sure you
> actually pass the exact same object (not just one that should hopefully
> be `equal').

Thanks for the fast help and explanations. Per your suggestion I'm avoiding both the equality testing of functions and the unwanted lexical environment this way:
(defun bar-off () (bar 0))
(define-minor-mode bar "Bar" nil " Bar" nil
  (if bar (add-hook 'foo-hook 'bar-off nil t)
    (remove-hook 'foo-hook 'bar-off t)))

although I was tempted to do it this way just to spite the interpreter :-)
(setq bar-off (lambda () (bar 0)))
(define-minor-mode bar "Bar" nil " Bar" nil
  (if bar (add-hook 'foo-hook (symbol-value 'bar-off) nil t)
    (remove-hook 'foo-hook (symbol-value 'bar-off) t)))




             reply	other threads:[~2013-05-29  4:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-29  4:44 Kelly Dean [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-05-28 22:35 Unreferenced symbols in closures, and a problem with closures in minor modes Kelly Dean
2013-05-29  1:28 ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=1369802683.65041.YahooMailClassic@web141102.mail.bf1.yahoo.com \
    --to=kellydeanch@yahoo.com \
    --cc=help-gnu-emacs@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 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.