This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-18
Channels
- # announcements (12)
- # babashka (6)
- # beginners (62)
- # calva (3)
- # cider (41)
- # clerk (5)
- # clojure (192)
- # clojure-bay-area (1)
- # clojure-europe (14)
- # clojure-norway (97)
- # clojure-uk (6)
- # clojuredesign-podcast (4)
- # clojurescript (30)
- # code-reviews (7)
- # cursive (32)
- # datahike (4)
- # datomic (35)
- # docker (8)
- # emacs (8)
- # events (1)
- # fulcro (13)
- # helix (19)
- # hoplon (4)
- # hyperfiddle (37)
- # jobs-discuss (10)
- # membrane (11)
- # missionary (19)
- # off-topic (28)
- # polylith (8)
- # portal (10)
- # practicalli (8)
- # re-frame (31)
- # reitit (6)
- # shadow-cljs (39)
- # timbre (3)
- # vim (1)
- # xtdb (6)
Is there a way to prevent a particular
buffer-local-value
'd variable from getting wiped upon changing the major mode of a buffer?
To prevent XY: I'm a heavy user of @ag’s amazing "edit-with-emacs" Spacehammer functionality, which allows me to edit text from any copy-pasteable thing on the computer inside an Emacs buffer.
Upon invocation, it gives me an editing buffer on fundamental-mode
.
When I change it to something more appropriate for the text in question, (e.g. markdown-mode
), an important buffer-bound variable (`spacehammer--caller-pid`) becomes nil
and the whole thing expectedly stops working 😞
Really? Oh wow. You made my day. I thought nobody except myself used that feature of Spacehammer. That was the real reason why I wrote it to begin with. There are some hooks that spacehammer.el exposes. You can utilize them for setting vars for the buffer. Here's an example for setting markdown mode
(defun spacehammer-edit-with-emacs-h (buffer-name pid title)
(with-current-buffer (get-buffer buffer-name)
(markdown-mode)
(setq-local spacehammer--caller-pid pid)))
(add-hook 'spacehammer-edit-with-emacs-hook #'spacehammer-edit-with-emacs-h)
There's also spacehammer-global-edit-with-emacs-mode
. It made to forcefully set spacehammer-edit mode in the edit buffer even if you change its major mode, but I think it's not working well. I need to take a look.Thank you - that works perfectly! Just edited the message above with it 😄 I'll take a look at the global mode, since sometimes I edit non-markdown things (and, IIUC, I have to pick the mode in advance on the hook)
I pushed a fix https://github.com/agzam/spacehammer/pull/184 Allow me to test it for a day or two, and I'll merge it. Unless I find some issues with the approach. But it should work fine.
A bit less trivial example you can find in my dotemacs here: https://github.com/agzam/.doom.d/blob/main/modules/custom/writing/config.el#L8
I'll take a look at the global modeYou don't have to. The package takes care of that. It sets the mode automatically upon the load. I was just trying to explain how it got broken.
Thank you! Oh, boy - even more gems on that repo! https://github.com/agzam/.doom.d/blob/68f9b8159d260253256e0cd6050af861315661ed/modules/custom/writing/autoload.el#L19-L19