3 ms·
The with-current-directory part is the dynamic part - i.e. within its dynamic scope, the current directory is now dir. The scoping of the dir variable itself i
by mst 12y ago
The with-current-directory part is the dynamic part - i.e. within its dynamic scope, the current directory is now dir.
The scoping of the dir variable itself is irrelevant.
- hollerith 12y ago`with-current-directory` has to be a macro because if it is not, then the evaluation of (delete-all-files-recursively) happens before the definition of with-current-directory can change the current directory. What the person meant when he wrote, "In those times I wish I could use the emacs lisp way," is, "In those times I wish I could use a lisp _macro_" -- particularly, one of those macros that makes a change, runs some code ("the body") then undoes the change. Since all lisps have macros, the code above would work in any lisp -- not just Emacs Lisp. Among lisps, Emacs Lisp is famous for its dynamically scoped variables. Consequently, the specific reference to Emacs Lisp perpetuates the confusion that how variables are scoped has anything to do with what we have been talking about.
- swah 12y agoYes, but emacs lisp is the only lisp I used, and lives in an environment where those macros are really useful. with-auto-compression-mode with-case-table with-category-table with-coding-priority with-current-buffer with-decoded-time-value with-demoted-errors with-electric-help with-help-window with-local-quit with-no-warnings with-output-to-string with-output-to-temp-buffer with-selected-frame with-selected-window with-silent-modifications with-syntax-table with-temp-buffer with-temp-buffer-window with-temp-file with-temp-message with-timeout with-timeout-suspend with-timeout-unsuspend with-wrapper-hook