0

I have variables foo and bar. I have a function that modifies foo and I can't change that function.

How can I redirect the change made to foo so it applies to bar instead?

EDIT :

I want this redirection to track real time change.

What I am trying to achieve :

I want to swap the headerline with the modeline. I did this with this snippet of code :

(defvar og-modeline mode-line-format)
(setq-default mode-line-format header-line-format)
(setq-default header-line-format og-modeline)

It works well but when something from an other package makes change to the headerline it obviously uses header-line-format but I want instead those change to be done to mode-line-format. Thus why I ask if there is the possibility to redirect changes.

6
  • I get the feeling somehow that this is an XY question.
    – NickD
    Jul 31 at 16:00
  • It is, but I don't know how to do it in elisp and, maybe I should have add this bit of explanation : I need this to remind active whenever there is a change made to foo or bar
    – Virgil
    Jul 31 at 16:32
  • Only one question per post, please.
    – Drew
    Jul 31 at 16:36
  • I think you'll need to be more specific in your question. As @NickD hinted, try asking something (much) closer to what you are actually wanting to do.
    – Drew
    Jul 31 at 16:38

1 Answer 1

0

Have a look at this section of the manual: Running a function when a variable is changed

You pass a function to (add-variable-watcher 'mode-line-format #'my-watch-function), and that function gets passed various attributes of the variable when it changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.