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
1
vote
1answer
75 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 ...
1
vote
1answer
15 views

Validating Arguments to a Function

I would like to validate the argument to a function before its action is executed. The main concern is the passing of a void variable. How can I trap this? (defun is-it-bound(item) (if (boundp 'item)...
0
votes
1answer
59 views

How to read the shell environment variables?

I have the following command in my .emacs (setq org-roam-directory (concat (getenv "BASEDIR") "/data/org-roam/")) The purpose is to the set the directory for org-roam (but ...
3
votes
1answer
33 views

Use of defvar in straight.el's bootstrapping

The package straight.el requires the following bootstrapping code in your emacs config: (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/...
0
votes
0answers
26 views

I want to make an alias to `org-babel-execute:emacs lisp`. the problem is with the space on `emacs lisp`

I'm using org-beamer exporter, and I would like to do the following: (defalias 'org-babel-execute:emacs-lisp lisp 'org-babel-execute:emacs lisp) My problem is 'org-babel-execute:emacs lisp has a ...
2
votes
1answer
20 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
1answer
31 views

Is there a way to check if a symbol is a built-in variable?

This is how you check if an object is a built-in function: (subrp (symbol-function 'assoc)) => t Is there an equivalent way to do this for variables as well?
1
vote
0answers
14 views

Passing string as arg to apply function [duplicate]

I want to call clone-indirect-buffer or clone-indirect-buffer-other-window within a function dependent on the prefix. To do this, I assign the appropriate clone function to a variable using let. ...
3
votes
1answer
42 views

Function add-variable-watcher does not watch "last-command" variable

I have added a watcher function to watch the last-command variable. (defun my-watch (symbol newval op where) (message "Hello")) (add-variable-watcher 'last-command #'my-watch) The ...
1
vote
0answers
40 views

why doesn't use-package :defines stop this "variable is void" error?

Error (use-package): w3m/:config: Symbol’s value as variable is void: w3m-filter-configuration I have a use-package statement that was producing an error because apparently emacs-w3m doesn't configure ...
7
votes
1answer
176 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
1answer
27 views

How to use a delayed evaluation function where a string is expected?

I have a variable that expects a string, and I want to set it to a function that will return a string whenever the variable is used. Right now, I have (setq bibtex-autokey-prefix-string (format-time-...
3
votes
1answer
73 views

Can font faces be dynamically assigned with font-lock-add-keywords?

In all the examples of font-lock-add-keywords I've seen, the font face is static. That is, there is a regex or a matcher function and a literal font face identifier. Is it possible to set the face ...
1
vote
1answer
26 views

Storing some text from a buffer into a variable

What is the "standard" way to store some text obtained from a buffer into a variable? The only way I could think of was to use something along the lines of (let ((beg (point))) (end-of-line) ...
1
vote
1answer
44 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
2answers
75 views

How do I pass a variable definition as a parameter to a command in the minibuffer?

I am an emacs novice. I am familiarizing myself with making basic changes to the init.el file. Currently, when I want to load init.el, I first C-h v user-init-file RET, this opens a *Help* screen ...
0
votes
0answers
54 views

How to store a buffer in a variable so that the value of the variable isn't influenced by the fate of the buffer?

Say I'm in a buffer named init.el and I run (setq mybuffer (current-buffer)) If I evaluate mybuffer I get #<buffer init.el>. Now I kill this buffer and evaluate mybuffer again. Emacs returns #&...
1
vote
2answers
72 views

How can I show a tabular list of variables and their values?

Is there a way to see the values of a list of variables? E.g., if I have var1, var2 and var3, is there a standard elisp function that shows me the values of these variables at the same time? I mean ...
0
votes
1answer
79 views

Dynamic name for org-capture template file [duplicate]

I am new to org-mode (and to Emacs in general) and am trying to set up org-capture. I would like to define a todo capture item whose template is located in the file ~/.emacs.d/org-templates/todo.tmpl....
0
votes
0answers
19 views

savehist-mode: Lisp error: (void-variable pell-buffer)

I am using GNU Emacs 26.3 in macOS. For (savehist-mode 1) I keep getting following error: Debugger entered--Lisp error: (void-variable pell-buffer) signal(void-variable (pell-buffer)) savehist-...
0
votes
1answer
39 views

How to use header-args variables to fill cell values of a table

I have an org-mode file as such: * Header level 1 :header-args: :var filename="somefile.csv" ** Header level 2 :header-args: :var foo="bar" #+begin_src emacs-lisp foo #+end_src #+...
1
vote
1answer
41 views

Is there a tagged union/sum type in elisp? If not, what to use instead?

In many programming languages, if one wants a variable that can take a discrete number of values, one has the capacity to define the permissible values in advance, using something like an enum. Does ...
0
votes
0answers
17 views

Symbol's value as variable is void: org-format-latex-options [duplicate]

I am trying to set :scale 2.0 in org-format-latex-options with the follows line in my .emacs file: (plist-put org-format-latex-options :scale 2.0) However I get the error: Symbol's value as variable ...
2
votes
1answer
41 views

storing string in variable fails to work in `early-init.el`

Putting the following code in my early-init.el causes my emacs not to startup. (require 'cl-lib) (defvar void-initial-frame-font (cl-find-if (lambda (font) (find-font (font-spec :name font))) ...
0
votes
0answers
57 views

How do you avoid pollution of Emacs namespace with "private" variables?

Probably it is misunderstanding of Elisp execution model by I think some variables are only pollute runtime. For example let's consider read-string argument HISTORY. Probably user don't need to know ...
2
votes
0answers
49 views

How to find out the name of a variable Customize is customizing

I'd like to have a function that when run from within a Customize buffer will return the name of the variable that would be customized at point.
0
votes
0answers
16 views

Why won't emacs permanently save my buffer-local var?

For many files I have file-local variables which asked me once if they were safe and I could add them permanently to my "trusted" list, never to be asked again. However, I get asked every ...
1
vote
1answer
66 views

How to add more default face highlight colors

Using (highlight-symbol-at-point) at some point the highlight start repeating colors. I find the variable that holds the default face highlight color values in Emacs is: hi-lock-face-defaults It ...
1
vote
1answer
55 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. ...
0
votes
1answer
55 views

Can't save safe variables for further

When I start Emacs it asks me if I want to allow "unsafe" variables which I agree and press '!' to save them for the future. Despite that, it still keeps asking me about it on every launch. ...
0
votes
2answers
175 views

Change $PATH once emacs is running

In my shell (Bash), I can switch among several LaTeX distros setting the $PATH variable. E.g.: export PATH=/usr/local/texlive/2016/bin/x86_64-linux:$PATH or export PATH=/usr/local/texlive/2018/bin/...
0
votes
0answers
29 views

It is safe to delete set free variables?

For example I have followins line of code (usually I get these code from answers). (projectile-global-mode) ; smerge-mode (setq smerge-command-prefix "\C-cv") (setq undo-tree-show-...
5
votes
1answer
3k views

Symbol’s function definition is void

I am trying to make an interactive toggle in emacs 27.0.90 When I eval-region no warnings or errors are shown. However, when I do (helm/toggle-frame) in ielm it throws Symbol’s function definition is ...
1
vote
2answers
375 views

Is there a way to spread a list like in Typescript or Golang?

I have a variable with some common values between dap-mode debug templates and I want to use that variable along with other cons elements for :environment-variable in languages like Golang or ...
1
vote
3answers
186 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
1answer
54 views

How to change a variable value in the current buffer?

I spent a long time looking for this and kept getting reference to M-x customize. But, that didn't give me access to certain variables like comment-start. I couldn't access comment-start with M-x ...
0
votes
1answer
66 views

Add element to org-refile-targets

I am keeping a common init.el for work and private on separate machines. So dependent on my machine I have common settings and machine dependent settings. How do I get to add an element to the org-...
0
votes
0answers
46 views

Multiple cursors has undefined variables

I installed multiple cursors mode. My init.el has the following at the bottom: (require 'bytecomp) (require 'multiple-cursors) (multiple-cursors-mode 1) (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-...
1
vote
1answer
66 views

Wrong type argument: symbolp, 10

I would like create function that ask me how length I want the Pomodoro but it say wrong type argument. (defun changePomoLength () (interactive) (set-variable org-pomodoro-length (read-string "...
2
votes
1answer
26 views

Giving faces compliant names

The description of defface in (info "(elisp) Defining Faces") says that the name of a face should not end in -face. But most faces declared in font-lock.el do use the suffix -face. How does this fit ...
0
votes
1answer
36 views

What does translation-table-for-input in function zap-to-char

I am reading the 8.1.2 The Body of zap-to-char of Elisp Introduction The body of zap-to-char (if (char-table-p translation-table-for-input) (setq char (or (aref translation-table-for-input char) ...
2
votes
1answer
188 views

How can I get the effect of buffer-local symbol plist property values?

Does Emacs have a way to set buffer-local properties on symbols? It's well-known that there are buffer-local variables. But a property belongs to a symbol, not to a variable. Hence, if I have ...
0
votes
1answer
67 views

How to set a variable that matches different type of strings?

I have these strings: First Type: arXiv:1234.56789 arXiv:1234.56789v1 Second type: hep-th/123456789 hep-th.AB/12345689 hep-th/123456789v1 hep-th.AB/12345689 Belong to the second type even strings ...
0
votes
2answers
48 views

Make/unmake a variable globally buffer-local depending on another variable

I have a package with the variable my-package--my-var that needs to be buffer-local when my-package-buffer-only is t but global if my-package-buffer-only is nil. This is what I have so far: (...
6
votes
1answer
188 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 ...
2
votes
1answer
96 views

Get value of a variable from another session in org-mode

How to share variables' values in org-mode between different sessions? Simple example: in session one I create _gpg_tmpdir #+name: make_temporary_directories #+begin_src bash :session *one* ...
1
vote
1answer
150 views

Keep ivy-initial-inputs-alist nil after counsel loaded

I want to keep the alist ivy-initial-inputs-alist nil after ivy and counsel are loaded. Therefore, I have the following configuration: (use-package ivy :ensure t :config ;; some keybindings ...
1
vote
1answer
35 views

Evaluate allows for combinations whose operators are compound expressions

I find the amazing power of scheme in sicp Exercise 1.4. Observe that our model of evaluation allows for combinations whose operators are compound expressions. Use this observation to describe ...
0
votes
0answers
47 views

How to extract symbols from an elisp buffer?

While I could parse the elisp myself, is there a way to extract symbols from an elisp buffer? That is, variable names, macros & functions - not part of strings.
0
votes
1answer
121 views

Regular expression gives different results as variable and as literal

In the Emacs *scratch* buffer, I get different results when I use the same regular expression as a variable compared to a literal: (setq splitter-string "9:20") "9:20" (string-match "[0-9]?[0-9]:[0-...