I am dabbling in Emacs Lisp and I am trying to write the following function:
(defun buffer-file-name-body ()
(last (split-string (buffer-file-name) "/")))
What I am trying to achieve is to extract just the file name and extension from the full path given by (buffer-file-name). However, this implementation returns a list of one item ("scratch.el") ... I tried several things such as passing the result of (last) through (string) but that raises an error... Google did not return anything useful when I searched for Emacs List convert list to string. How to I do this?
file-name-nondirectory. (Also, if you allow me the small hint, your function will barf on buffers that do not visit a file, such as e.g., *scratch*.)