Let's say, If I have a directory variable named a-directory with its value. Also I have another variable named b-directory which gets its value from the previous variable.

(setq a-directory "C:/Users/Paper")
(setq b-directory (expand-file-name "org-mode.org" a-directory))

Every time when I change the value of a-directory, I need to eval the b-directory again to get its new value. So here comes the question: How can I get the updated value without evaling b-directory when changing the value of a-directory?

  • Please add the missing parenthesis for your code. (And consider getting rid of the backquote and comma.)
    – Drew
    May 22, 2016 at 3:15
  • 4
    Instead of being a variable, b-directory could be a function: (defun b-directory () (expand-file-name "org-mode.org" a-directory)) - in this case it will evaluate the expression every time (slight overhead), but will be always up to date.
    – wvxvw
    May 22, 2016 at 5:30
  • This is a good idea.
    – Leu_Grady
    May 22, 2016 at 5:47
  • 3
    You could also never change a-directory directly through setq but from a change-a-directory function that would update both a-directory and b-directory.
    – JeanPierre
    May 22, 2016 at 7:38

1 Answer 1


Described behavior similar to reactive programming, you may found some implementations for elisp.

But I have no experience with them yet. Please, feel free to add usage examples bellow.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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