I donโt know that Rudel gave a 100% solution well enough, but what you want to do is something like this:
(add-hook 'rudel-document-attach-hook 'my-rudel-set-mode-appropriately) (defun my-rudel-set-mode-appropriately (document buffer) "try to set the mode appropriately" (set-buffer buffer) (let ((buffer-file-name ...get-name-from-document...)) (set-auto-mode)))
Only you need to replace part of the code ...get-name-from-document... code that evaluates the name of the file you want, for example, if the buffer is called myfile.py , then you can change it to (buffer-name) , But if buffers get odd names, maybe you need to extract the name from the document object (Rudel internally uses the document object to represent what you are sharing). So, if (buffer-name) doesn't work, you can try (rudel-suggested-buffer-name document) .
i.e. try the above code, but using one of the following lines:
(let ((buffer-file-name (buffer-name)))
and
(let ((buffer-file-name (rudel-suggested-buffer-name document)))
set-auto-mode will use the value of buffer-file-name to determine the main mode using common Emacs mechanisms .
source share