My files have long filenames and a part of the filename is a date and a version number. Often I'd like to save the file in the buffer using nearly the same name, just change version number or date.
This would be much easier, if I had a command which puts the filename of the current buffer into the kill ring, so that I can open a file, then type
C-x C-w (write file), yank the current name with C-y, change it and save it.
I'm using Emacs 24.3 on Windows and 24.4 on Linux. I have to use different filenames and not git for various reasons. I'd be happy if this command worked with AUCTeX / LaTeX as major mode.
I made a mistake: I don't want to type
C-x C-f (=find file), but
C-x C-w (=write file). I corrected this above.
Found a duplicate question and answer: https://unix.stackexchange.com/a/45381 But there is no better anwswer!
Here: http://www.gnu.org/software/emacs/manual/html_node/elisp/File-Name-Components.html is a function, which selects the "nondirectory" part of the filname:
Function: file-name-nondirectory filename
This function returns the nondirectory part of filename. (file-name-nondirectory "lewis/foo") ⇒ "foo" (file-name-nondirectory "foo") ⇒ "foo" (file-name-nondirectory "lewis/") ⇒ ""
If I only knew lisp...