We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [dynamic-scoping]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
2answers
75 views

Unusual behavior when overriding `calculate-lisp-indent'

I've modified calculate-lisp-indent as a better solution to the indentation questions here, here and here. By "modified" I mean I overrode the function with advice. After doing this when I restarted ...
1
vote
0answers
29 views

Can I set a variable scoped to a perspective?

I have a large monorepo repository and open different parts of it in a persp-mode perspective. It would be nice if for all buffers owned by that perspective I could set for example projectile-project-...
5
votes
1answer
725 views

Scope in lambda

In my .emacs conf file, I've got this function that adds a hook to set the compile-command based on the mode. It looks something like, (defun set-compile-cmd (mode-hook cmd) (add-hook mode-hook (...
0
votes
1answer
56 views

Search in readable eww buffer [duplicate]

I would like to open url in eww in readable-mode and find str. Below is my code that doesn't work: (defun my-eww-searh-readable (str) "Once-off call to `my-eww-searh-readable' after EWW is done ...
2
votes
2answers
52 views

Accessing the global value of a locally altered variable

Is it possible to access the global value of a variable that has been changed locally? (setq foo 2) (let ((foo 3)) ;; can I access the original value here? )
3
votes
1answer
105 views

About closure creation

After reading this article about readable closures, I check that: Since closures are byte-code function objects, they print readably. You can capture an environment in a closure, serialize it, ...
0
votes
1answer
69 views

Forcing lexical-scope in the middle of dynamic-scope

Today I ran head first into lexical vs dynamic scope in Emacs Lisp. Gist of it is I have a macro defined in lexical scope that expands into a `defun'. Let's say something simple like this: ;; -*- ...
0
votes
1answer
35 views

capture and replay a closure later

I am having a problem working with closures. I hope I can explain this clearly. When I try to start a compilation I typically do it like this: (let ((dir (get-dir)) (model-root root) (default-...
10
votes
3answers
171 views

Why does defvar scoping work differently without an initvalue?

Suppose I have a file named elisp-defvar-test.el containing: ;;; elisp-defvar-test.el --- -*- lexical-binding: t -*- (defvar my-dynamic-var) (defun f1 (x) "Should return X." (let ((my-dynamic-...
5
votes
1answer
149 views

Why does calling expand-file-name indirectly produce a different result?

Running the following in ielm in emacs -Q: ELISP> (defun wh/expand-file-name (name &optional default-directory) (expand-file-name name default-directory)) wh/expand-file-name ELISP> (...
2
votes
3answers
88 views

Changing a mode's keymap for the duration of a command's execution

I would like to bind TAB to my company-mode back-end only for the duration of a command's execution. I am trying to achieve this by using dynamic scoping as follows (the irrelevant part of the ...
1
vote
1answer
56 views

How to avoid variable name collisions in my init file?

I noticed spacemacs puts things like autosave and backup files in ~/.emacs.d/.cache/ and I'd like to use that idea in my own setup. From spacemacs/core/core-load-paths.el (defconst spacemacs-cache-...
1
vote
1answer
159 views

How to fix Warning: assignment to free (local) variable in lambda function

The byte compiler just gave me this message 1103:24:Warning: assignment to free variable `orig-win-config on this bit of code: ;; create window config store and restore functions ;; credit to @...