Questions tagged [buffer-local]
56 questions
22
votes
1 answer
What does `setq-local` do, and when should I use it?
I'm not quite clear on all the variations of buffer-local variables, even
after reading all the doc and a bunch of postings here on SX.
Here's a summary of my understandings:
(defvar foo ..) declares a dynamic variable for the file. But the
variable…

Kevin
- 1,308
- 8
- 20
15
votes
1 answer
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 page I linked to says that any integer value is…

Brendan
- 303
- 1
- 5
14
votes
1 answer
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 foo")
but the variable is still buffer local and…

Maciej Goszczycki
- 1,777
- 13
- 18
11
votes
2 answers
How to Persist Evil Markers?
I want to be able to save my buffer local evil markers (m to mark a location and then ' or ` to jump to it) across emacs sessions/instances. I'm not really sure how to do this. I tried installing/using session and adding them like so:
(add-to-list…

noctuid
- 429
- 3
- 11
8
votes
2 answers
How to modify-face for a specific buffer?
I work with a lot of tabular data files and use stripe-buffer.el make them easier to read. But I also work with more than one, so I'd like to make it easier to distinguish among them as well and want to change the stripe colors per buffer.
I can…

wdkrnls
- 3,657
- 2
- 27
- 46
7
votes
2 answers
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 following code:
(let ((foo "b"))
(with-temp-buffer
…

cutejumper
- 787
- 5
- 12
6
votes
1 answer
How can I get buffer-local environment variables via .dir-locals?
I'm using emacs for many different projects. For some of them, I need, for example, different entries in $PATH, or different $MAKEFLAGS, whatever, you name it...
I thought this would be possible somehow like this in .dir-locals:
((c++-mode
…

Markus
- 471
- 2
- 12
6
votes
2 answers
How do you disable the buffer end/beginning warnings in the minibuffer?
I see that I can do something like this:
(defun limit-warnings ()
(set (make-local-variable 'warning-minimum-level) 'fatal))
(add-hook 'minibuffer-setup-hook 'disable-warnings)
(Sorry for syntax errors; I'm not very familiar with Lisp and the…

bright-star
- 839
- 9
- 17
5
votes
1 answer
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-language))
(my-package-insert text))
In the…

Andrii Tykhonov
- 452
- 2
- 13
5
votes
2 answers
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 the current buffer, i.e. can I explicitly specify…

ivan
- 1,928
- 10
- 20
5
votes
2 answers
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 or directory local variable to determine major mode…

sfridman
- 151
- 4
5
votes
1 answer
What is the difference between setq-mode-local and setq-local
I don't understand how setq-mode-local works (mode-local is a package from cedet).
The macro's documentation says:
setq-mode-local is a Lisp macro in `mode-local.el'.
(setq-mode-local MODE &rest ARGS)
Assign new values to variables local in MODE.
…

Łukasz Gruner
- 1,008
- 8
- 16
4
votes
1 answer
org-mode: have flycheck resolve relative config while editing code blocks
Desired behaviour
While editing code blocks with org-mode by pressing C-c ' I'd like Flycheck to resolve relevant configuration
the same way it does for normal files. I'm using JavaScript, and these are .jshintrc files within the same ancestry.
To…

Mike McFarland
- 439
- 3
- 11
4
votes
1 answer
buffer-local advice
I am trying to create a buffer local advice to run some code when a minor mode is disabled. I looked through the documentation for add-function and saw this
If PLACE is a symbol, its `default-value' will be affected.
Use (local 'SYMBOL) if you want…

Prgrm.celeritas
- 849
- 6
- 15
4
votes
1 answer
How to find out if variable is buffer-local?
I'm trying to get rid of tabs, following this guide:
(setq-default indent-tabs-mode nil)
So: why setq-default and not setq? I know I would need to use setq-default for a buffer-local variable, but I can't actually determine (except from inferring…

djechlin
- 923
- 8
- 21