Stefan Monnier writes: >>>> This inspired me to do something not exactly this but which also gets >>>> rid of the new argument to create-file-buffer. How about this: >>> >>> Now you're talking! :-) >>> LGTM! Thank you very much, >> >> Great! Here's that as a complete patch again. > > Eli, OK to install on `master`? > > > Stefan > > > PS: Nitpicks: > >> + (let* ((lastname (if (directory-name-p filename) >> + (file-name-nondirectory (directory-file-name filename)) >> + (file-name-nondirectory filename))) > > Aka > > (let* ((lastname (file-name-nondirectory > (if (directory-name-p filename) > (directory-file-name filename) > filename))) > > or even just > > (let* ((lastname (file-name-nondirectory > (directory-file-name filename))) Absolutely, makes sense. >> + (lastname (if (and (directory-name-p filename) uniquify-trailing-separator-p) >> + (cond ((eq uniquify-buffer-name-style 'forward) >> + (file-name-as-directory lastname)) >> + ((eq uniquify-buffer-name-style 'reverse) >> + (concat (or uniquify-separator "\\") lastname)) >> + (t lastname)) >> + lastname)) > > Here you can merge the `if` into the `cond` and I'd test > `uniquify-trailing-separator-p` first (cheaper and nil by default) Yes, makes sense. Revised patch for these two below. > and since we know (directory-name-p filename), I'd be tempted to replace > (file-name-as-directory lastname) with just `filename`. (file-name-as-directory lastname) and filename are different though: the former is only the last component of filename, but as a directory name. The latter is the full filename, which is not what the basename of the buffer should be. (since it gets no further processing) > Also I'd argue that when `uniquify-trailing-separator-p` and > (directory-name-p filename) are both true we never want to use just > `lastname` so the default should be to return `filename`: > > (lastname (cond > ((not (and uniquify-trailing-separator-p (directory-name-p filename))) > lastname) > ((eq uniquify-buffer-name-style 'reverse) > (concat (or uniquify-separator "\\") lastname)) > (t filename))) > > so for `post-forward` (my personal favorite) /foo/bar/mumble/name/ would > turn into name/|bar/mumble. > WDYT? I agree that would be good (modulo that it does need to be (file-name-as-directory lastname) rather than filename), but it would change the existing behavior and not comply with the docstring of `uniquify-trailing-separator-p'. (I think it would be a reasonable change though, but probably as a subsequent change)