reddit / emacs

Associate certain types of files/buffers with each other, often by calling a function (instead of a simple alist of actual buffers and files)?

Jack-o-tall-tales · 2022-10-07 09:46
Looking for package/software recommendations, or ideas on implementation if this doesn't already exist. I have several common workflows which involve switching between buffers for files (that is, switching between buffers if the relevant file is already visited, or opening a new buffer visiting the file if not). There are generally two or three buffers or files in each group. I don't particularly need any new workflow tools for switching between groups, just between files *within* a group. What's important though is that these workflows are about switching between different *types* of file -- it would be very cumbersome to add all of the different pairs manually. Some examples to illustrate. I use org-roam to organise my notes on various literature I read, and I use ebib and citar to organise the literature itself. Most of the lit is stored as pdfs. It would be great if I could hit a key while in the pdf and (whether the file was open already or not) jump to the note. Similarly, when in the note, I could hit the same key and jump back to the file. A sort `switch-to-associated-buffer-or-file` command, which would jump between them. Similar thing with latex and compiled pdfs. I could go straight from the source to the pdf, and then from the pdf to the source. Similar again with org exports -- switch between the original org doc and its exported latex/html/whatever buffer (making more than one export is a good example of having more than one buffer in the group -- the source and all exports could be associated). The org roam notes illustrate well why I can't just add each file to something like [torus](https://github.com/chimay/torus/blob/master/torus.el) individually -- I have hundreds of notes on literature and adding them all by hand would take forever. But I *could* write a function which would return, for each buffer, the relevant other file. Each lit not has an `ROAM_REFS` property, which holds the key for the literature in my bib file, and then ebib and citar have enough code that I could write a function for going from *that* to the pdf file. I would be happy to write that function, but I need a package to knit the whole thing together. It should lookup the right command for the right buffer and jump to it. Before someone tells me to just write a function for the org-roam notes, another for latex, and another for org exports: I know I could do that. The point is that these operations all seem similar enough that it would be good to have a general system for switching between such associations, and I'd like to see if one already exists. Any ideas appreciated!
7890yuiop · 2022-10-07 10:00
`C-h f ff-find-other-file`. It's configurable. `ff-other-file-alist` will be of interest, for starters. Documentation at: `M-x finder-commentary RET find-file` https://stackoverflow.com/search?q=%5Bemacs%5D+%22ff-find-other-file%22 ---- See also https://lists.gnu.org/archive/html/emacs-devel/2022-09/msg00300.html
Jack-o-tall-tales · 2022-10-07 10:32
Looks perfect, TYSM!
akirakom · 2022-10-07 10:41
Use file-sibling-file-search, if your groups follow simple filename conventions.
ireallywantfreedom · 2022-10-07 13:46
There was a recent thread about this sort of thing that might be relevant - https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58071.