Questions tagged [setq]
The setq tag has no usage guidance.
27 questions
8
votes
1
answer
2k
views
I'm unsure which option to use for setting a variable: setq, customize-set-variable, or setopt
I'm a bit uncertain about which method to use for setting a variable: setq, customize-set-variable, or setopt. I did some research online, and it seems that opinions on this matter are quite varied. ...
2
votes
0
answers
91
views
why does the Iterator Yield A Different Value?
I tested two similar generators, and the result confused me.
This iterator yields values as I expected:
ELISP> (iter-defun f (x)
(setq x (iter-yield (1+ x)))
(setq x (iter-yield ...
0
votes
2
answers
228
views
How to set a variable name with a variable?
I want to do this.
(let ((myvar "my/variable")
(myval "Some Value"))
(setq myvar myval))
The manual method is:
(setq "my/variable" "Some Value")
Here ...
0
votes
1
answer
361
views
Ispell does not seem to use hunspell
I tried to set up ispell to use hunspell with this post.
but it seems like ispell is still not using hunspell.
Ispell in Emacs would mark this word as wrong: Schulwochen (German)
$ hunspell -d de_DE
...
1
vote
1
answer
291
views
Setting new values in `org-refile-target` not working
I'm trying to add a new file foo.org and delete an old bar.org from the org-refile-target variable. So doing
(setq org-refile-targets (quote (("~/foo.org" :maxlevel . 2))
should work by ...
1
vote
1
answer
370
views
Backup a variable and store it back
I have problems to get into Lisp. I assume I miss the correct terms to search for.
So I try to "speak in Python".
#!/usr/bin/env python3
foo = 7
backuped_foo = foo
# temporary change the ...
0
votes
1
answer
92
views
vc-mode doesn't evaluate when mode-line-format is set with setq-default
I've this code in my init.el
(setq-default mode-line-format (list
(propertize " %b " 'face 'bufname)
(propertize (concat "...
2
votes
1
answer
49
views
Cannot get a symbol's value for the first time when using `setq-default`
I can use setq-default to set a symbol's default value, as follows:
(with-temp-buffer
(make-local-variable 'bar)
(setq-default bar "xyz")
(symbol-value 'bar))
When I first executed ...
1
vote
1
answer
53
views
Inconsistency in emacs' rules of scope?
I have always felt that emacs' rules of scope are a bit strange
and prone to contradictions. In fact I have even attempted to file
bug reports just to be told that my interpretation of the rules of ...
7
votes
1
answer
288
views
What type of variable binding is setq creating?
What type of variable binding or variable or symbol is setq creating, when the variable hasn't been declared prior setq?
Given following source code:
;; -*- lexical-binding: t; -*-
(defun setq-x ()
...
1
vote
1
answer
84
views
Top-level variables, local variables, variable scoping and the difference between set and setq
I've been reading about emacs dynamic and lexical bindings. While I generally get the difference between the two types, there is one example that is not clear to me.
I've checked this question and I ...
1
vote
1
answer
81
views
Activate a minor mode switching off the other ones in a set of minor modes
I'm developing a set of minor modes that I use in my LaTeX copy-editing work.
I have, e.g.. a list of three minor modes stored in a variable:
(defvar latex-editing-mode
'(preamble-editing-mode
...
1
vote
1
answer
602
views
Modify value of a variable by applying a function to it?
Suppose one of the customizable variables in a package is var, and its default value is a list, list. I understand I can change the value of var to mylist using
(setq var mylist)
in my init.el.
...
1
vote
3
answers
614
views
The global value of a variable I set with setq in my config differs from the local value. How can I get my value to be what I want in every buffer?
I want web-mode-script-padding to be set to 0 at all times.
In my config, I have tried both
(with-eval-after-load 'web-mode
(setq web-mode-script-padding 0)
)
As well as simply,
(setq web-mode-...
1
vote
1
answer
403
views
setq in init file not overriding the default for indent-tabs-mode
It works when using setq-default in place of setq or when customizing through C-h v. C-h v reports that it is set in 'C source code'.
I was thinking it might be affected by my c-default-style, but my ...
9
votes
3
answers
4k
views
When use setq or set '
I tried to find an answer to this seemingly simple question, but the swamp (internet) is a big place.
In the emacs init file in one case I use: (show-paren-mode t)
In another case I use:
(set '...
6
votes
1
answer
356
views
What's really behind an assignment in Emacs lisp?
[Warning : these are noob questions.]
I'm a beginner in Emacs Lisp and I would like to be sure that I understand well what I'm really doing when I set a value to a variable with setq or let.
Here is ...
7
votes
2
answers
4k
views
init.el and trampling of custom-set-variables
My new init.el uses require to load various settings that I have organised into directories and files. This is an attempt to tame what was a very large and messy init.el and custom.el file. Also I ...
0
votes
1
answer
111
views
How to set value vc-git-grep-template within function
I have a working sexp for configuration vc-git-grep:
(setq vc-git-grep-template "git --no-pager grep -n -i -e <R> -- <F>")
Then in dired-mode I evaluate M-x vc-git-grep and everething ...
0
votes
1
answer
552
views
Wrong type argument: symbolp, possible mismatched parenteses in .spacemacs
I am trying to apply a fix to make it easier to change todo status in org mode. The code is the following:
'(
(org :variables org-want-todo-bindings t)
)
from https://github.com/syl20bnr/...
1
vote
1
answer
944
views
Setq doesn't work [duplicate]
Glad that the title got your attention :D
I have this little snippet that's driving me crazy:
(defvar cache '(nil . nil))
(defun init-cache ()
(setq cache '(nil . nil)))
(defun save (value)
(...
0
votes
2
answers
771
views
Bind function to variable and evaluate each time variable is referenced
I want to set a variable to a function that is run every time the variable is used. Like Lazy set in a makefile
(setq counter 0)
(setq counter (+ 1 counter))
counter ; actual: 1 wanted: 1
counter ; ...
3
votes
2
answers
76
views
How to define a bundle of variable-and-function pairs?
I want to define a bundle of variable-and-function pairs, e.g.: vl/path-doc points to my often used path, and vl/open-path-doc is used for open it in dired-mode.
I tried this piece of code:
(setq ...
4
votes
2
answers
1k
views
Should "custom" variables defined without defcustom be set via custom-set-variables or setq?
Should I use custom-set-variables (as opposed to setq) when setting a variable that returns non-nil for custom-variable-p but was not defined by defcustom?
For example, echo-keystrokes is defined in ...
23
votes
1
answer
10k
views
What's the difference between setq and defvar
What is the difference between setq and defvar in Emacs lisp?
I see common lisp version of the same question at https://stackoverflow.com/questions/3855862. Are they same in Elisp?
18
votes
2
answers
846
views
Why do setq and set quote act differently on let-bound variables with lexical scope?
I had a bug in one of my extensions that eventually turned out to be caused by set not working as I expected:
;; -*- lexical-binding: t -*-
(let ((a nil))
(setq a t)
(print a))
(let ((a nil))
...
14
votes
3
answers
3k
views
Assigning same value to multiple variables?
Sometimes I need to set same value to multiple variables.
In Python, I could do
f_loc1 = f_loc2 = "/foo/bar"
But in elisp, I am writing
(setq f_loc1 "/foo/bar" f_loc2 "/foo/bar")
I am wondering ...