The general issue is that you need x and y to be evaluated before they get inserted in somelist. The issue with the quoted list (with ' as reader syntax) is that quote is a special form that does not evaluate its argument. According to the docstring:
Return the argument, without evaluating it. (quote x) yields x.
Warning: quote does ...
C-hig (elisp) Variable Definitions
Internally, defcustom uses the symbol property standard-value to record the expression for the standard value, saved-value to record the value saved by the user with the customization buffer, and customized-value to record the value set by the user with the customization buffer, but not saved. See Symbol Properties. ...
setq returns the value, so you can just:
(setq f-loc1 (setq f-loc2 "/foo/bar"))
Of if you don't want to rely on that, then use:
(setq f-loc1 "/foo/bar" f-loc2 f-loc1)
Personally I would avoid the latter and instead write:
(setq f-loc1 "/foo/bar"
(setq f-loc1 "/foo/bar")
(setq f-loc2 f-loc1)
And the very first approach I ...
Do not quote the cons cell, because quoted expressions are not evaluated. That's exactly why one quotes - to prevent evaluation. But that's not what you want, so don't.
Instead use the form that creates a cons cell from two evaluated values, its arguments.
(cons x y)
Of course you can also quasiquote but that doesn't really make sense here, and looks ...
It means that when there is more than one binding the variables are bound sequentially, so that each can depend on the values bound to those that are bound before it, i.e., those that come before it in the let* bindings.
For let (no asterisk), none of the bindings can be assumed to occur before any of the others (the variables could, in principle, be bound ...
Another, probably cleaner, way to reset the value of a variable:
custom-reevaluate-setting is a compiled Lisp function in custom.el.
Reset the value of SYMBOL by re-evaluating its saved or standard value.
Use the :set function to do so. This is useful for customizable options
that are defined before their ...
A macro to do what you want
As an exercise of a sort:
(defmacro setq-every (value &rest vars)
"Set every variable from VARS to value VALUE."
`(progn ,@(mapcar (lambda (x) (list 'setq x value)) vars)))
Now try it:
(setq-every "/foo/bar" f-loc1 f-loc2)
How does it work
Since people are curious how it works (according to comments), here is
Does apropos-value do what you're looking for?
(apropos-value PATTERN &optional DO-ALL)
Show all symbols whose value’s printed representation matches PATTERN.
PATTERN can be a word, a list of words (separated by spaces),
or a regexp (using some regexp special characters). If it is a word,
search for matches for that word as a substring. If it is a ...
No, it shouldn't, if you use dynamic binding. Here are two choices (alternatives) that can help:
Use lexical binding. Set variable lexical-binding for the file.
Use dynamic binding (what you are doing now, no doubt), but also substitute the value of the variable cmd for the variable cmd in the lambda body. You can do this only if the function body of the ...
Emacs comes with auth-source.el. I would not try to roll my own version of it.
auth-source makes it easy to read from ~/.authinfo.gpg. Good programs will already support authinfo. A quick search suggests that ERC can use authinfo.
For your random off the shelf MELPA programs you can easily use authinfo to retrieve your password from ~/.authinfo.gpg like ...
If the sole purpose of defining my-trash-dir is to use its value to set the user option trash-directory, then you should just write
(setq trash-directory (expand-file-name ".trash" user-emacs-directory))
or (if you don't mind wasting a millisecond or two at startup) even
(setq trash-directory (locate-user-emacs-file ".trash"))
This is because trash-...
A special—a dynamically bound variable that is—variable can surely be void. From Void Variables (emphasis mine):
We say that a variable is void if its symbol has an unassigned value cell (see Symbol Components).
Under Emacs Lisp’s default dynamic scoping rule (see Variable Scoping), the value cell stores the variable’s current (local or global) ...
Either enable lexical binding as a file-local variable in the file's first line, as described in the Elisp manual, node Using Lexical Binding, or just use this with dynamic binding (which is the default):
(setq-default fci-rule-column ',num)
(The ' before ,num is not needed, except if you are unsure whether NUM will be a ...
In case someone else runs into this, I had enabled TeX-auto-save, which saves settings to an auto/ directory and loads them when a file is revisited.
Any change to the variable is equivalent here, so just M-x set-variable or (setq THE-VAR A-NEW-VALUE) is sufficient.
The function called when you click Set for Current Session is custom-variable-set. (Well, actually it is more complicated - it boils down to calling either the value of (get SYMBOL 'custom-set), where SYMBOL is the option symbol or function ...
Since you can use and manipulate symbols in lisp, you could simply loop over a list of symbols and use set.
(dolist (var '(foo bar baz)) (set var 10))
(mapc (lambda (var) (set var 10)) '(foo bar baz))
(loop for var in '(foo bar baz) do (set var 11))
(--each '(foo bar baz) (set it 10))
A live object is one that you can reach by following pointers from other live objects. Functions and variables are live because they are reachable from the global list of definitions. Setting a definition to nil means that it no longer points to the value it once did, potentially creating garbage. The GC will collect that garbage in fairly short order. As ...
Replace func2 with #'func2:
(defun func2 (arg)
(if (listp arg)
(mapcar #'func2 arg)
Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).
I.e., every symbol in ELisp has a
"value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "...
is there a way to do this without changing the current buffer
No, but buffer-local-value is a Generalized Variable, so you can use setf to take care of the buffer switching for you:
(setf (buffer-local-value 'some-var B) 'some-val)
This macroexpands to essentially the same code as what your wrote above:
(let* ((#1=#:v B))
This variable is an alias for ‘js-indent-level’.
That's the clue. If you're running Emacs ≥25 then js2-mode defines js2-basic-offset as an alias of the variable js-indent-level. At the point where the variable is made an alias, any value that it had is forgotten. Only the value of the base variable (js-indent-level) matters.
If you set it later then the ...
The path you have chosen introducing symbols to keep the colors requires you to convert the names you get by system-name to those symbols and evaluate them to get the color.
You could achieve this by
(symbol-value (intern (nth 0 (split-string (system-name) "\\.")))))
Although doable I think the above is rather unconventional.
custom-set-variables is weird – I'm not 100% sure it can handle cases like this. You may try (eval `(custom-set-variables … (erc-password … ,(special-value) …) …), but that strikes me as a dirty hack-around.
Just put the extra information in a file with the gpg extension, save it, give a password, and then load the file. You'll have to put the password ...
The answer to your question is: Yes, you won't hear about the new and exciting modules. But you can write:
(setq foo (remq 'c foo))
to remove c from foo. Or clone the repository and use standard version control tools for making any changes to the source you want.
I, as a package author, bind case-fold-search to nil in the outer let, and I want to use the default value (it might or might not be set by the user) in the with-temp-buffer,
In this case I would recommend
(let ((case-fold-search (progn (make-local-variable 'case-fold-search)
This topic confuses me sometimes, so let's start with some definitions, namely those of let:
let is a special form in ‘C source code’.
(let VARLIST BODY...)
Bind variables according to VARLIST then eval BODY.
The value of the last form in BODY is returned.
Each element of VARLIST is a symbol (which is bound to nil)
or a list (SYMBOL VALUEFORM)...
Load library Bookmark+ and use a variable-list bookmark.
A variable-list bookmark saves and restores the values of a set of variables.
prompts you for the variables to include in the list and then sets the bookmark. Non-interactively, you can use function bmkp-create-variable-list-bookmark to create or update a ...
Autoloading only applies to the function value slot of a symbol. In particular, there is no such thing as autoloading a variable.
It is probably bad form for a package to contain variables for user customization whose default value is a nonempty list, precisely because it becomes difficult to customize the variable in that case. Worse, if the default value ...
permanent-local is fundamentally a way to distinguish whether the variable's buffer-local value is really specific to this buffer or is specific to the mode currently in use in this buffer.
Sadly, in practice, for many buffer-local variables which are not specific to a particular package, whether the setting belongs to the buffer or to the mode will depend ...
1) It's not an association list, strictly speaking, even though the name seems to say it is. An alist is a list of (key . value) dotted pairs. org-publish-project-alist is just a list of lists, where each of the sublists contains a tag (the first element) and a property list (the rest of it). But property lists consist of key-value pairs (pairs in a more ...