[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible to hook into Emacs's buffer name generation?
From: |
Óscar Fuentes |
Subject: |
Re: Possible to hook into Emacs's buffer name generation? |
Date: |
Fri, 18 Feb 2011 02:37:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Sean McAfee <eefacm@gmail.com> writes:
[snip]
> I thought it might be cool to have Emacs automatically name buffers that
> are visiting files in my repository with a trailing "<component-x.y.z>"
> when I open them, where component-x.y.z is simply the closest directory
> name above the file that matches that pattern.
See if this helps:
C-h v uniquify-buffer-name-style
> I could do this by
> adding a hook to find-file-hooks and renaming the buffer according to my
> scheme, but it seems cleaner to tell Emacs how to generate the desired
> buffer name in the first place. I've traced the code from find-file all
> the way down to generate-new-buffer-name, but I can't find anywhere I
> can interpose my buffer-naming logic.
The mechanism proposed above advises `create-file-buffer':
(defadvice create-file-buffer (after create-file-buffer-uniquify activate)
"Uniquify buffer names with parts of directory name."
...
That is in the last lines of lisp/uniquify.el