4

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?

4
  • Please add the missing parenthesis for your code. (And consider getting rid of the backquote and comma.) Commented 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. Commented May 22, 2016 at 5:30
  • This is a good idea. Commented 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. Commented May 22, 2016 at 7:38

1 Answer 1

-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.

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.