Truncation in Emacs Powerline (mode line)
Is there a way to get some elements truncated in (excellent) Emacs Powerline? I think in particular in the section which-func-mode
in the default mode line. It would be nice to see only the first N characters of the function name or section name (in Org mode), N for the definition.
Question: is it possible to just disable components (i.e. not display) if the frame is too narrow (e.g. 80 characters)?
source to share
Typically you can tweak which-func-format
accordingly, for example:
(setq which-func-format `("[" (:propertize (:eval (my-which-func-current)) local-map ,which-func-keymap face which-func mouse-face mode-line-highlight help-echo "mouse-1: go to beginning\n\ mouse-2: toggle rest visibility\n\ mouse-3: go to end") "]") )
Where my-which-func-current
is the function that truncates the current function name accordingly:
(defun my-which-func-current () (let ((current (gethash (selected-window) which-func-table))) (if current (truncate-string-to-width current 20 nil nil "…") which-func-unknown)))
This approach works with a standard mode string and any line expansion pack that supports standard mode data. I know what Smart Mode Line does, but I'm not sure about Powerline. I am not using any of these packages.
source to share