I believe I've seen a type of abbreviation with some(?) modeline packages that I'd like to implement in spaceline (I'd be willing to switch modelines for a good reason). I want to abbreviate the buffer-file-name to shorten directories to single characters (ideally, only if it is overflowing some other text). For example, instead of ~/.emacs.d/layers/display.org, I'd like to see ~/.e/l/display.org or ~/./l/display.org for the buffer-file-name. Significant flexibility (e.g., min buffer-file-name length before truncating, length of truncation, etc.) would be appreciated, but I'll settle for any improvement over (abbreviate-file-name (buffer-file-name).

My full spaceline config is as follows:

(use-package spaceline-config
  :ensure spaceline

  (spaceline-helm-mode 1)

  (setq spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)

  (spaceline-define-segment buffer-id
    (if (buffer-file-name)
        (abbreviate-file-name (buffer-file-name))

     ((remote-host buffer-id) :face highlight-face)
     (process :when active)

   '((selection-info :face 'region :when mark-active)
     ((flycheck-error flycheck-warning flycheck-info) :when active)
     (python-pyvenv :fallback python-pyenv)
     (global :when active)
     (version-control :when active)

There's typically not a lot of text in my modeline, unless I'm several directories deep, and this becomes a problem when I split the window vertically (all the segments on the right-hand-side are gone).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.