Today I got tired of always looking up, where all these little files named “_show.rhtml”, “_list.rhtml” and their ilk are living, and patched the emacs mode line to include the last element of the current buffer’s directory. http://www.emacswiki.org/cgi-bin/wiki/ModeLineDirtrack describes something very similar, but it repeats the whole mode line definition of mode-line-format, which might break with the next version of Emacs. It’s much cleaner to add to a variable that is used in the mode line:
(setq-default mode-line-buffer-identification (cons '(:eval (replace-regexp-in-string "^.*/\\(.*\\)/" "\\1/" default-directory)) mode-line-buffer-identification))
But I am using vim. Please provide this patch for vim. :)
You can always use viper-mode. 8-)
My combined solution to keep propertization and restrict directory name to file buffers:
(defun find-file-mode-line ()
(concat (replace-regexp-in-string “^.*/\\(.*\\)/” “\\1/” default-directory) “%12b”)))))
(add-hook ‘find-file-hook ‘find-file-mode-line)
In the mean time I found an even better solution using the uniquify library.
Thanks for your ‘uniquify’ suggestion. This is the best improvement since I learned about ido-mode.
Comments are closed.