Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [local-variables]

The tag has no usage guidance.

2
votes
2answers
97 views

How to customize DONE headlines per-file in org-mode?

I would like to customize the headline and keyword inside of an org file. In this question is shown how to change the faces of each keyword, but not the headlines. For the moment, I haven't achieve ...
1
vote
2answers
66 views

When local variables are “calculated”?

Does elisp calculate values of local variables at declaration or when calling them? Say i want to find out what headlines in buffer are lvl2, and do stuff to them: (defun map-org-heads () (org-...
0
votes
1answer
198 views

Enable .dir-locals.el variables inside just opened buffer

I'm programmtically create a new buffer as a result of shell command (defun jira-ticket-view (&optional jira-ticket) "Open Jira Ticket Inside Emacs" (interactive) (setq jiraURL (get-jira-...
1
vote
1answer
146 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 ...)...
0
votes
1answer
24 views

How not to propagate dired-actual-switches as a directory variable to the sub directories

I want to set dired-actual-switches for the directory /path/to/data, but not for data's subdirectories. So I generated the following .dir-locals.el file in /path/to/data: ;;; Directory Local ...
3
votes
0answers
363 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
2answers
79 views

write-file-functions: Clarification as to permanent local behavior with add-hook

According to the write-file-functions doc-string, "[t]his variable's value is permanent if it is given a local binding." Step 1: Start from emacs -q using Emacs 25.2.1. Step 2: Switch to the *...
3
votes
1answer
492 views

.dir-local.el misunderstanding

I generated a .dir-locals.el by calling the function add-dir-local-variable, giving it the path for the project for which I want the variable, the variable itself, and its value. The generated file ...
0
votes
1answer
46 views

Idiomatic way to improve `insert-pair`

I have the following custom implementation of insert-pair: (defun *-insert-pair (&optional arg open close) "Wrap next ARG sexps in parentheses. If there is no next sexp, insert a new pair of ...
1
vote
1answer
203 views

Using local variables in cl-loop

This is my first time trying to write my own elisp code, so bear with me. I have the following cl-loop: data contains the following: ((refs . [((file . "api/user.js") (start . 266) (end . 269)) ((...
1
vote
1answer
209 views

Making a variable window-local

I am developing a feature to adapt a mode-line to the width of the window. I have developped it so far using buffer-local variables to store the state of the mode-line, however, when I open the same ...
2
votes
1answer
516 views

How can I automatically add some local variables info to a C-x C-f new (.tex) file?

I use auctex to edit my .tex files. Each time I create a new file .tex file via C-x C-f, I want to insert two local variables informations: % Local Variables: % coding: utf-8-unix % TeX-engine: ...
4
votes
3answers
385 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 ...
4
votes
2answers
769 views

How to customize major mode initialization with local variables?

Seems like most major modes clear all local variables before initializing. It also seems like many major modes read variables while initializing to customize their behavior. If I want to set a file ...
0
votes
2answers
130 views

Combine setq and concat

Could you help me with smarter way of handling package-archives? At the moment I have the following in my init.el ;; This is dumb but... (if (eq system-type 'windows-nt) (setq package-archives '((...
2
votes
1answer
113 views

How to reference a local variable inside the definition of a function?

Is it possible to reference a local variable inside the definition of a function? Here's an example: I have an alist text-alist consisting of keys and text snippets. I want each text snippet bound to ...
13
votes
1answer
759 views

Mark a local variable safe for any value

The variable safe-local-variable-values can store name/value pairs that are safe as file-local or directory-local. However sometimes I want to say any value is valid for a given variable. The manual ...
7
votes
2answers
374 views

Prevent folding org files opened by ediff

Folding gets in the way when merging two org files using ediff, so I'm trying to disable all folding in org-mode buffers created by ediff. Non-ediff folding behavior should remain unaffected. ...
4
votes
2answers
130 views

Match against a variable with pcase

I'm trying to get pcase to match against a let-bound variable. However, I can't seem to get pcase to recognize the variable correctly. See this minimal example: (let ((a 1)) (pcase 2 (a 7))) => ...
1
vote
0answers
130 views

My function seems to not know a variable has changed and gives the wrong output

I want to change the shebang string every time I create a new Python file, some projects use Python 2 and other use Python 3, so the shebang should change according to the value of a variable in the ....
14
votes
2answers
1k views

Remember permission to execute “risky” local variables

In many of my projects I use .dir-locals.el files to setup project specific variables such as compile commands. Upon opening a file within a directory containing such a file, emacs complains about "...
5
votes
2answers
291 views

Using different theme on tramp buffers (and buffer-related themes in general)?

Is it possible to configure emacs so it uses different theme for tramp buffers than for defaults? Say, I use twilight by default, but while editing sth via ssh I'd like to switch to pastels-on-dark... ...
3
votes
1answer
642 views

Set variables based on path without using directory-local variables

I want to set variables, in particular, compile-command and tabbing related variables based on the path of the file I'm editing. In my .vimrc I use the following to do this. autocmd BufRead,...
2
votes
1answer
636 views

How to get an value from a buffer local variable

I have the following code in the file1.el: (with-current-buffer (get-buffer-create "TestBuffer") (read-only-mode -1) (erase-buffer) (make-local-variable 'source) (setq source (get-source-...
15
votes
2answers
450 views

Is there a way to daisy chain .dir-locals.el files?

Suppose I have a directory with these files. /foo/bar/baz/.dir-locals.el /foo/bar/.dir-locals.el /foo/.dir-locals.el When I go to create a file in /foo/bar/baz/, I'd like to daisy chain them ...
2
votes
1answer
219 views

How to activate whitespace-mode for a cc-mode buffer from .dir-locals.el?

I'd like to enable whitespace-mode from a .dir-locals.el file such that when I open a file managed by cc-mode, I will see trailing spaces highlighted with the whitespace face. I think I'm close. This ...
8
votes
2answers
1k views

Only enable whitespace mode in certain buffers

I would like to have whitespace mode turned on for all buffer except for org-mode ones. It is easy to do this when emacs starts up, but since I use a persistant copy of emacs with emacs daemon mode I ...
6
votes
1answer
1k views

How do I use company-mode in some buffers and auto-complete-mode in others?

My init.el loads company with (global-company-mode). I want to make an exception for Javascript buffers, and instead use auto-complete-mode for that mode. Q: I am struggling to find a way to unhook ...
9
votes
2answers
698 views

Can I set a particular file to automatically and silently accept changes?

That is, can I specify for a particular file that I don't want Emacs to notify me that the file has changed on disk and prompt me about whether I want to accept changes or not? I don't want to do ...
5
votes
2answers
69 views

How can I make documents 'portable' between Emacsen?

I put 'portable' in quotes because, as we all know, Emacs works with plain text and this plain text is innately portable. However, the format of this plain text is not. My particular use-case is with ...
8
votes
2answers
2k views

How can I prevent flycheck-mode from checking certain files?

I've configured Emacs to open files named *.cfg in shell-script-mode. These are config files, of course, rather than shell scripts, but 90% of the time it does what I want (mainly, good guesses about ...
12
votes
1answer
652 views

Make a buffer-local variable become global again

I was experimenting with local variables and set: (defvar-local foo nil "Buffer local foo") I later redesigned my program to use a global variable instead using: (defvar foo nil "Not buffer local ...