codethrasher · 2022-09-02 22:49
I'm wondering how to recreate the functionality of the ` *Messages*` buffer. My use case is storing org-links to a specific org file while I'm working in, say, "buffer A".
Explicitly, if I'm writing in a buffer named `bufferA.org`, I'd like `bufferB.org` to have text written to it if I do some "action" (e.g. a specific key-stroke), but without flashing `bufferB.org` in any of my windows. How would I achieve this?
My terminology may be off, which might explain why I can't find my own solution.
ambihelical · 2022-09-02 23:19
Probably your best bet is \`C-h i\` and then selecting the Emacs Lisp Intro, this covers something very similar to this, namely where it goes into the implementation of the \`append-to-buffer\` function, which is one function you will need to use. You don't need to copy the implementation shown in the manual, the function exists already, but it's useful to learn from. Other bits you will need you can probably find in other places in this manual.
lebensterben · 2022-09-02 23:25
Check `with-current-buffer`
arthurno1 · 2022-09-03 02:08
> have text written to it if I do some "action" (e.g. a specific key-stroke), but without flashing bufferB.org in any of my windows. How would I achieve this?
(with-current-buffer (get-buffer-create " my-buffer")
(insert "hello world\n"))
If you start a buffer name with a space, it won't appear in completion lists by you can still type manually its name and switch to it with C-x b when you need to debug your stuff.
billydeath · 2022-09-03 03:13
Mickey Peterson's excellent article 'Demystifying Emacs's Window Manager' will set you straight. Longish read, but you'll should be able to achieve what you're after if you spend the time.
https://www.masteringemacs.org/article/demystifying-emacs-window-manager
akirakom · 2022-09-03 11:44
I think you can call `org-store-link` inside a `with-current-buffer` block.
Alternatively, you can build a link string using `org-link-make-string` and insert it into the current buffer using `insert`.
ieure · 2022-09-03 16:00
> My use case is storing org-links to a specific org file while I'm working in, say, "buffer A".
[Org capture](https://orgmode.org/manual/Capture.html#Capture) is the already-existing mechanism for doing this kind of thing; no need to build your own. `%a` in the template will expand to a link back to whatever you were doing when you initiated the capture.