Function to change the extension of current file in Emacs lisp
Today, I was going through my draft files on this blog and many of them where
.html files exported from Blogger (where I previously hosted this blog). And
I wanted to change them to
markdown files with .md extension. I could
obviously use my script to change extension of multiple
, but I thought, there should be a
way to do this within emacs.
So I took a deep dive into Emacs documentation and the end result was this function:
Change file extension in Elisp
The above function will ask the user for the new extension, and then rename the file, buffer and also set the visited file name to the filename with new extension.
And on my Spacemacs , I added this key-binding to that function. “o” is reserved for user defined functions in Spacemacs.
If you know a better way of doing this, please feel free to add a comment. Any other suggestions welcome as well.