help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replacing a function with another one


From: Michael Heerdegen
Subject: Re: replacing a function with another one
Date: Tue, 11 Mar 2014 06:01:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

lee <lee@yun.yagibdah.de> writes:

> Sigh ... Any idea why the following does not work:

Your code does something you definitely shouldn't do: your advices make
`hi-lock-set-file-patterns' and `hi-lock-find-patterns' switch to a
different buffer (persistently!).  When you need the context of another
buffer, use `with-current-buffer' to switch to it temporarily.

Maybe the following illustration may help:

(defvar-local foo)

Suppose we have two buffers buffer-a and buffer-b.  buffer-a is current,
and we want to set `foo's binding in buffer-a to `foo's value in
buffer-b (I think this is what you try to do, more or less).  This is
how you can do it

--8<---------------cut here---------------start------------->8---
(let (helper)    ; temporary variable (not buffer local)
  
  (with-current-buffer buffer-b
    ;; set it to `foo's binding in buffer-b
    (setq helper foo))
  
  ;;back in buffer-a
  (setq foo helper))
--8<---------------cut here---------------end--------------->8---


BTW, did you have a look at my example?  I think it's quite close to
what you want to achieve.

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]