Questions tagged [buffer-local]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
32 views

Is it possible to make a function local to the buffer?

I want to override the function helm-swoop-pre-input-optimize in man mode using its hook, but not anywhere else. Is there something similar to make-local-variable for functions?
1
vote
1answer
40 views

How do I clear a global variable that also is buffer-local?

I called add-hook multiple times because I had a few typos in the hook function, and now there are a bunch of broken copies of it in the hook. I want to do (setq after-save-hook nil), but after doing ...
1
vote
1answer
145 views

How can I change external program to open org URLs for one org file only

In my Emacs config, I have set Firefox to be the browser to open URLs with, (setq browse-url-browser-function 'browse-url-firefox) Now, I have one org-mode file, in which I would like to open URLs ...
1
vote
1answer
84 views

Have shell inherit buffer local process-environment

I have made buffer local changes to `process-environment' using the technique described in How can I get buffer-local environment variables via .dir-locals. I then call shell from that buffer. If I ...
0
votes
2answers
432 views

Buffer-local after-save-hook?

I'd like to register an after-save-hook that is only active in certain buffers that I specify. For example, assume there are 3 functions currently registered in my after-save-hook: hook-01, hook-02, ...
2
votes
1answer
218 views

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' ...
3
votes
1answer
524 views

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 ...
5
votes
2answers
362 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 ...
7
votes
2answers
390 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 ...
0
votes
1answer
64 views

Adding to kill-buffer-hook results in “setq: Wrong type argument”

Subtract a buffer's (the file's) size from a variable before killing it. Emacs 26. (defvar cumulative-open-bytes '0 ) (defun buffer-settings-calc-bytes () (interactive) (let ((current-open-file-...
2
votes
1answer
251 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
0answers
16 views

How to preserve buffer local variables through `recompile`?

In a compilation buffer, when I set buffer local variable like so: (setq-local foo 'bar) Doing a (recompile) will unset this variable. Is there a way to keep the buffer local value permanent ...
2
votes
1answer
92 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
votes
1answer
119 views

Set a buffer/file local variable in elisp like a file local variable

I'm looking for a way to set a variable that isn't buffer local in such a way that it will act like one. It's possible to do it with file local variables, but I haven't found a way to set a variable ...
0
votes
1answer
109 views

Setting hl-line-mode for programming modes

In my init file I have this: (add-hook 'prog-mode-hook (lambda () (linum-mode 1))) So it shows line numbers only for programming modes. I tried to do the same with hl-line-mode, but it does not work:...
3
votes
2answers
910 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 ...
1
vote
2answers
281 views

How to get an insert-text-button 'action property accessing a dynamically-bound buffer-local variable

In realgud I have a text button that needs access to a dynamically-bound buffer-local variable. The situation occurs like this. Inside one buffer that has the buffer local variable, there is a ...
1
vote
0answers
217 views

Can I override global-hl-line-mode in a buffer/window?

I have the following line turning hl-line-mode on globally in my init file: (global-hl-line-mode) Most of the time, that's how I like it. But sometimes I want to turn it off. I'd hoped that I could ...
14
votes
1answer
2k views

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 ..) ...
13
votes
1answer
911 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 ...
1
vote
1answer
61 views

Is it possible to associate minor modes with windows rather than buffers?

Does Emacs have some notion of associating minor modes with windows rather than setting them as "global" or "buffer-local"? For example, in a certain window layout I may wish to have a minor mode ...
2
votes
1answer
143 views

Buffer-local hook shadowing default value for subsequently loaded libraries

After having a problem with debugging a package I write, I finally tracked down the problem to the following: auto-revert-mode is making kill-buffer-hook buffer-local (which is fine by me). The ...
3
votes
1answer
1k views

Use `.dir-locals.el' to append to `before-save-hook' as a buffer local variable

I want to use .dir-locals.el to append to the before-save-hook in a project for c++ files. Currently I'm using: (add-hook 'c++-mode-hook (lambda () (add-hook 'before-save-hook '...
1
vote
1answer
49 views

How do buffer local bindings go into effect?

I'm learning to program with buffer local variables. The emacs documentation describes buffer local variables as: A buffer-local variable has a buffer-local binding associated with a particular ...
6
votes
2answers
1k views

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 ...
3
votes
1answer
293 views

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 ...
9
votes
2answers
688 views

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/...
4
votes
1answer
437 views

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 ...
3
votes
1answer
443 views

whitespace-mode ignores whitespace-line-column

In ~/.emacs I've globally enabled whitespace-mode: (require 'whitespace) (setq whitespace-style '(face empty tabs lines-tail trailing)) (global-whitespace-mode t) Example buffer content: -*- fill-...
2
votes
1answer
703 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-...
4
votes
2answers
1k views

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 ...
5
votes
1answer
631 views

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 &...
12
votes
1answer
702 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 ...