I am working with Quarto, which is based on mixing Markdown with code snippets from various languages. Hence it relies on polymode.
Sometimes when I have multiple Quarto .qmd files open and want to save the buffer to file, the minibuffer sometimes prompts me whether I want to overwrite the contents to another .qmd file than the one I'm working on, and if I enter [y] then the original contents of the other file is overwritten and lost.
This only happens in with this type of file, and maybe due to polymode it seems there might be multiple buffers associated with the same file. For instance, for a file called "file.qmd", there may be a buffer called "file.qmd [Python]" and "file.qmd", and so on, from what I see in the buffer list.
Has anyone had this experience and know a workaround? I suppose I need to reassociate a buffer with the correct file but not sure how to do that or if there is a better way.
C-h v buffer-file-nameholds the path of the visited file, so that will be what's being changed to the wrong value. If you useC-x C-w(write-file) you can write to any file, updating that variable. Or you could set the variable directly.M-x set-visited-file-name(which does quite a lot more than just settingbuffer-file-name... it might be the better method of recovery... it's a bit hard to know for sure, though.)buffer-file-nameand useset-visited-file-nameat next occurrence. Many thanks.