Questions tagged [variables]

for variables in Emacs Lisp, which are symbols with values. The symbol’s name is also called the variable name. Most variable names, by convention, consist of lowercase, ordinary words separated by hyphens.

Filter by
Sorted by
Tagged with
0
votes
2answers
399 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 ; ...
2
votes
1answer
170 views

Make a variable visible to some functions only

Consider the following metacode: ;;; -*- lexical-binding: t -*- (defvar var1 ...) (defvar var2 ...) (defun main () "Main entry point" ...) (defun func1 ...) (defun func2 ...) ... (defun funcn ...)...
4
votes
0answers
385 views

list of current variables in a buffer for Python code

I would like to find a way to reproduce the "Workspace" of Matlab or the equivalent "Variables" window of the awesome pudb debugger directly in emacs for python code: it is a window which details the ...
5
votes
3answers
560 views

init.el - setq or defvar

I want to define a trash directory in my user-init-file but I don't know which way to do this is best or most correct. I currently have something like this: (defvar my-trash-dir (expand-file-name "....
0
votes
0answers
67 views

Detect variable use in an elisp function at run time

I try to understand a piece of elisp source code, with many nested and conditional functions calls, and I would like to know if a particular variable is used (and, if so, where in the code) at run ...
5
votes
2answers
490 views

Where are these variables defined? - bytecomp Warnings

Lately I'm getting warnings when compiling the .emacs Warning (bytecomp): reference to free variable ‘url-http-extra-headers’ Warning (bytecomp): reference to free variable ‘oauth--token-data’ ...
0
votes
1answer
311 views

Association list `Symbol's function definition is void` error

I am trying to achieve a slightly smart package management in my init.el file but can't achieve it because of ELisp ignorance. Here is the case. ;; package loader function (defun load-packages-...
9
votes
2answers
690 views

Search through the values of all variables in Emacs

I'd like to find which variables contain a certain value. Is there a way to do a regex search through the values of every variable in Emacs?
7
votes
0answers
754 views

Display all local variables within a edebug session

When using edebug one can get a local variable by command describe-variable (C-h v), but are there any ways to display all local variables? For example in Python you can call locals() in a pdb ...
0
votes
1answer
177 views

Variable user-init-file not found (No Match) when trying to set it, but it's documented and has a value when examined

I'm new to emacs and looking to change my default init file as the current is set to be ~/.emacs and I want it to be ~/.emacs.d/init.el I can clearly C-h v user-init-file to see but but M-x set-...
0
votes
1answer
150 views

How to install evil-snipe-enable-alternate-f-and-t-behaviors on Spacemacs?

I am trying to install "evil-snipe" with evil-snipe-enable-alternate-f-and-t-behaviors on Spacemacs. The instruction on https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Bvim/evil-snipe are ...
2
votes
2answers
370 views

Set an Elisp var on the command line and read it in the init file

I'm trying to set a variable at load-time: # emacs --eval '(defvar myvar t)' Now, in this session, if I C-h v myvar RET I get a nice t. But if I put (message "MYVAR: %s" myvar) in my init file, I ...
0
votes
1answer
140 views

Installing Emacs from source: the command `C-h v` for accessing variables doesn't work

I have installed the latest development version of Emacs on my Mac from the source by cloning the Git repository here ('Emacs source repository' under 'Anonymous clone'), and then executing make in ...
1
vote
3answers
1k views

Insert the value of a variable into the buffer I'm editing

I asked How can I script emacs to install packages from list? and got this answer. (setq package-selected-packages '(async epl evil goto-chg helm helm-ag ...
2
votes
1answer
91 views

practical relevance of storing value and function into one symbol

With Emacs Lisp it is possible to store a value and a function within the same symbol. (setq foo 6) (defun foo () (message "blah %d" foo))) Then you can do: (symbol-function 'foo) which returns the ...
4
votes
1answer
678 views

Define a function alias within a let binding?

How can I define an alias within a script with let-binding? I tried (let (b-s) (defalias 'b-s 'buffer-string)) But it doesn't work. I figured out to let-bind the variable where aliases as stored ...
1
vote
2answers
798 views

customize creates custom-set-faces unintentionally

I just edited the variable org-M-RET-may-split-line with easy costumize, saved and applied. I checked my dotfile right afterwards and noticed that (custom-set-faces '(default ((t (:foreground "#...
4
votes
1answer
134 views

Why isn't this variable being set although it is set in my .emacs?

In my init.el file I have the following line (setq js2-basic-offset 2) The last line in my .init.el file is (add-hook 'after-init-hook (lambda () (message "Welcome home %s" (user-...
0
votes
1answer
174 views

Save and restore variable

I am working on Spacemacs which gives you the ability toggle between Emacs "holy-mode" and Vim "evil-mode". However the evil-escape minor mode is still enabled. I am trying to find some way to disable ...
5
votes
2answers
589 views

Set buffer-local variable in buffer other than the current one?

I'm in buffer A and I want to set a buffer-local variable in buffer B. I'm currently doing: (with-current-buffer B (setq-local some-var 'some-val)) but is there a way to do this without changing ...
1
vote
1answer
350 views

“require ('org-journal')” creates “Symbol's value as variable is void: require”

I added require ('org-journal) to my .emacs. Now I get the error message: 'Symbol's value as variable is void: require', when emacs is started. Without require ('org-journal) there is no error message....
0
votes
1answer
26 views

Why “mobile-inbox.org” filename cannot be changed?

I have (setq org-mobile-inbox-for-pull "~/org/m-Inbox.org") in my .emacs (also set the var manually to the same effect), and still when doing (org-mobile-pull) emacs stores new entries in the file ...
3
votes
2answers
672 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 ...
1
vote
2answers
811 views

org mode - babel params variable is void

After upgrade org mode version to 9, the babel variable params is void. Below example works fine in org 8 version: #+BEGIN_SRC emacs-lisp :results output (print params) #+END_SRC #+RESULTS: : : ((:...
2
votes
1answer
404 views

Fixing “reference/assignment to free variable” warning during compilation if variable is dynamically bounded

For: (defun my-ag/font-lock-extend-region () (save-excursion (goto-char font-lock-beg) (forward-line 2) (setq font-lock-beg (point)))) I've got: Warning: reference to free variable '...
2
votes
1answer
221 views

Controling what an org-link points to with variables

Let's say I have the following: #+NAME: output-directory /path/to/output/directory Results can be found [[file+emacs:/path/to/output/directory][here]]. Is there a way for me to have an org link to ...
0
votes
1answer
80 views

elisp - simplify a stranger data structure [duplicate]

I wish to define a variable to replace the hardcode string below: (setq org-publish-project-alist '( ("blog" :components ("org-blog-docs" "org-blog-static")) ("org-blog-docs" ...
7
votes
2answers
632 views

The default value of buffer-local variable not set until first `setq`

Say I define a buffer-local variable foo, and its default value is "a": (defvar foo "a") (make-variable-buffer-local 'foo) (default-value 'foo) ;; => "a" Immediately after this I run the ...
1
vote
1answer
680 views

Passing a symbol as an argument to a function

I'm trying to understand why this doesn't work, and how to make it work: (defvar test/var-1 nil) (defvar test/var-2 nil) (defun make-setter (var-to-set) (lambda (val-to-set) (setq var-to-set ...
2
votes
1answer
126 views

Why isn't face-remapping-alist permanent-local by default?

text-scale-mode uses a buffer-local face-remapping-alist to scale the buffer's text, adding values like (:height 1.2). It stores a "cookie" with the scaling it has applied in another local variable, ...
1
vote
0answers
380 views

load environment variables of virtual environment in emacs

What is the best way to load in emacs the environment variables of a virtualenv? I seem to have got virtualenvwrapper.el working. For example, after using venv-workon my_venv, then M-! printenv ...
0
votes
2answers
130 views

Warning assigning variables

I'm rebuilding my emacs configuration, and trying to compile without warnings. I'm using also cask. I have this case: (require 'magit) ;; Enable a right limit of 70 chars for git logs (add-hook '...
4
votes
1answer
1k views

Error void-variable on function name

What is the difference between the two functions func1 and func2? (defun func1 (arg) (if (listp arg) (mapcar (lambda (x) (func1 x)) arg) arg)) (func1 (list 1 2 3)) (defun func2 (arg) (...
3
votes
2answers
1k views

How do I insert code block header :var in exported code block in org-mode

GNU Emacs 26.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-10-06 Org-mode version 8.3.5 (release_8.3.5-1131-g7eecb2 @ ~/.emacs.d/el-get/org-mode/lisp/) I have come to share my projects as ...
4
votes
3answers
626 views

How can I create mode-local variables?

I'm looking to create a command which stores a kind of "history" for the current major-mode. I need the variable to be independent for each major mode, but consistent across all buffers in any ...
10
votes
4answers
418 views

Can I reload a library and have defvar re-assign values?

I am developing a library and would like to reload it after editing without exiting Emacs (assume that it is on load-path): (load-library "myname") When I do this, Emacs doesn't pick up changes to ...
0
votes
1answer
1k views

Symbol's function definition is void on built-in variables?

For some reason I am getting errors for built-in variables that are available in the documentation. For instance, evaluating in the scratch buffer the following all return: Symbol's function ...
1
vote
1answer
236 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 @...
3
votes
1answer
612 views

change value of a defvar after loading package

I load a package that defines a list of radio stations with defvar (defvar default-list '((station1) (station2))) I want to redefine this list after loading the package (I am using require) because ...
4
votes
1answer
124 views

Update variable value without eval again

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:/...
1
vote
1answer
55 views

Expression as var

Is it possible for a variable to be set to an expression that will be evaluated each time that variable is accessed? The idea would be that a user could then set the variable to be either a string or ...
4
votes
2answers
71 views

describe-variable show characters instead of numbers

Is there a way to have describe-variable show characters instead of numbers where it makes sense? Here's for example output of describe-variable word-separating-categories: word-separating-...
1
vote
1answer
83 views

Jump to a bookmark+ dired bookmark from Lisp code

According to the docu of Bookmark+ this code: (bmkp-dired-jump BOOKMARK-NAME &optional FLIP-USE-REGION-P) should allow to quickly jump to a dired buffer that has been bookmarked. I try to eval (...
3
votes
1answer
113 views

What happens if variable changed through customize is later changed by package maintainers?

For example, lets say a package defines a variable foo: (A B C), but through customize, I remove C from the list. Now the variable foo is (A B). What happens if later, the package maintainers change ...
4
votes
2answers
116 views

Is there a list of Russian holidays?

I want to add Russian holidays to variable holiday-local-holidays formatted like: ((holiday-fixed 1 1 "New Year's Day") (holiday-float 1 1 3 "Martin Luther King Day")) Is there any list I can use ...
1
vote
1answer
59 views

How to properly use VARIABLE-TAG in Wisent?

I try to get around Wisent/Semantic and I'm playing with toy languages at this point. Issue I'm stuck with is how to mark multiple variable declarations. My toy language has only WORD terminal and ...
6
votes
1answer
251 views

Best way to support obsolete variables

Emacs 25.1 obsoletes a variable isearch-word and recommends to use the new isearch-regexp-function instead. Because Emacs 24 does not have the new variable, I can't just replace it like: (if isearch-...
4
votes
1answer
225 views

Why emacs can not see outer variable in lambda function?

I had a simple config to set fci-rule-column to different values depend on file types: (use-package fill-column-indicator :ensure t :config (setq fci-rule-color "LightSlateBlue") (setq fci-...
3
votes
1answer
146 views

how to sort describe-variable completion list by recency (or frequency)?

When I run describe-variable, then choose something, I often wind up looking at the same variable again later or next session. However, when I do describe-variable again, the helm list of variables ...
4
votes
1answer
373 views

How to store the variable value after Emacs was closed

Suppose, we have a variable defined in ~/.emacs: (defvar *my-var* "") Then in **scratch** buffer we set some value to it: (setq *my-var* "value") After we close emacs the value will be lost. How ...