My first emacs snippet (show current buffer file name)

  2015-09-04


This might be ugly, but its mine.

I am a console guy, I like doing many things in the console even through they most likely can be piped through my editor (honestly the thing could easily run its own X server if allowed, I am sure of it).

Currently I find myself working in golang which, in large enough projects, has many files with similar names. Similar names in go files are not a bad thing, the path that makes it to the package ends up being very descriptive such as github.com/myproject/web/api.go and github.com/myproject/ssh/api.go that make a nice descriptive name in context (and in code might end up having things like web.API and web.API.Endpoint and ssh.API) but in my editor, when I need to know what file this is to do some fun stuff with it in the console (or whatever other reason) I found no practical way to figure the name, other than opening the buffer selection, which I dont use that much since I use tabbar

So I created my first useful (for me) snippet and I intend to use this blog as the pride parent fridge to post my work.

;; display the filename of the current buffer in the minibuffer
(defun show-current-buffer-filename() (interactive)
  (let (
	(buffer-on-display
	 (buffer-file-name (current-buffer))))
    (message "Current buffer: %s" buffer-on-display)))
comments powered by Disqus