You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to associate the various file extensions (such as .crt) with x509-mode (or x509-dwim) such that when I open the .crt file the decoding is done right away and the appropriate rendering is shown in the buffer.
And that seems to work fine. However I noticed a couple of problems:
If the .crt file is inside a .zip file which open in archive-mode, the x509-dwim function is called, the rendering is done and then the buffer reverts back to Fundamental-mode.
After opening a .crt file once, and then killing the buffer, if I open the same file again it now opens in Fundamental-mode.
Overall it feels as if there was an extra call to x509-mode which takes the buffer back to Fundamental-mode.
Should this be working as one would expect, or is the design of the code precluding the use of auto-mode-alist association?
The text was updated successfully, but these errors were encountered:
auto-mode-alist is intended to apply a mode in the buffer itself. In the case of opening a .crt-file and running x509-dwim, what happens is that the original .crt-file remains open. When the x509 buffer is closed, the original file remains open in a (buried) buffer. When opening the same file again, that buffer is simply switched to and auto-mode-alist does not come into play. The problem is that x509-dwim is not a mode itself applied to the opened file and therefor it doesn't quite work with auto-mode-alist. Unfortunately I don't know how to make this better but it might help you to know what's going on.
When opening a file from an archive the behavior is even stranger. It seems the buffer with the archive file is switched to after x509-dwim is run. You can see this by manually switching to the corresponding x509 buffer, typically named something beginning with "*x-". This is probably caused by how archive files are opened. To help the situation somewhat, the generated x509 buffer can be automatically switched to in the archive-extract-hook.
(add-to-list'auto-mode-alist '("\\.crt\\'". x509-dwim))
(defunmy-archive-extract-hook()
"Switch to a x509 buffer with same basename as the current buffer."
(if-let* ((x-buffer (get-buffer (format"*x-%s*" (buffer-name)))))
(switch-to-buffer x-buffer)))
(add-to-list'archive-extract-hook'my-archive-extract-hook)
Thank you for the explanation! I'll look into it later after first learning more about the archive-mode and reading your code so I can understand better.
Hi,
Thanks for this code, it's really useful!
I am trying to associate the various file extensions (such as
.crt
) withx509-mode
(orx509-dwim
) such that when I open the.crt
file the decoding is done right away and the appropriate rendering is shown in the buffer.I used
And that seems to work fine. However I noticed a couple of problems:
.crt
file is inside a.zip
file which open inarchive-mode
, thex509-dwim
function is called, the rendering is done and then the buffer reverts back to Fundamental-mode..crt
file once, and then killing the buffer, if I open the same file again it now opens in Fundamental-mode.Overall it feels as if there was an extra call to
x509-mode
which takes the buffer back to Fundamental-mode.Should this be working as one would expect, or is the design of the code precluding the use of
auto-mode-alist
association?The text was updated successfully, but these errors were encountered: