(define -ayalog '())

括弧に魅せられて道を外した名前のないプログラマ

Emacs の上の方にファイルのパスを表示したかった

f:id:ayato0211:20150521193130p:plain

ずっと前からしたいなーって思ってたけど、思いの外簡単に出来たので満足している。

(setq-default
 header-line-format
 '(""
   (:propertize (:eval (shorten-directory default-directory 30))
                face mode-line-folder-face)
   (:propertize "%b"
                face mode-line-filename-face)))

(defun shorten-directory (dir max-length)
  "Show up to `max-length' characters of a directory name `dir'."
  (let ((path (reverse (split-string (abbreviate-file-name dir) "/")))
        (output ""))
    (when (and path (equal "" (car path)))
      (setq path (cdr path)))
    (while (and path (< (length output) (- max-length 4)))
      (setq output (concat (car path) "/" output))
      (setq path (cdr path)))
    (when path
      (setq output (concat ".../" output)))
    output))

ついでなのでモードラインの表示も少し弄ってスッキリさせてある。