GNU bug report logs - #13212
24.2.90; setf (symbol-function ...) does not set buffer local variable if present

Previous Next

Package: emacs;

Reported by: Burton Samograd <burton <at> samograd.ca>

Date: Mon, 17 Dec 2012 18:39:02 UTC

Severity: normal

Tags: notabug

Found in version 24.2.90

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Burton Samograd <burton <at> samograd.ca>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13212-done <at> debbugs.gnu.org
Subject: bug#13212: 24.2.90; setf (symbol-function ...) does not set buffer local variable if present
Date: Mon, 17 Dec 2012 13:31:29 -0700
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> tags 13212 notabug
> thanks
>
>> (make-local-variable 'cons)
>> (setf (symbol-function 'cons) (lambda (x y) (+ x y)))
>
> buffer-local variables affect only variables, not functions.
> I.e. they affect symbol-value, not symbol-function.  Elisp does not provide
> buffer-local functions, so you have to use things like
> (if (derived-mode-p 'foo-mode) ...) instead.
> An alternative is:
>
>    (defvar-local my-foo-function (lambda () (some (default) behavior)))
>
>    (defun my-foo ()
>      (funcall my-foo-function))

Thanks for the explanation.

--
Burton Samograd




This bug report was last modified 12 years and 217 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.