I am using
(which-function-mode t) to show current function name / org-heading on the mode line. I would like to limit the number of characters it shows on the mode line, but I couldn't find any option like
I can limit the string by redefining
(which-function) replaced by
(truncate-string-to-width (which-function) 30):
(defun which-func-update-1 (window) "Update the Which Function mode display for window WINDOW." (with-selected-window window (when which-func-mode (condition-case info (let ((current (truncate-string-to-width (which-function) 30))) (unless (equal current (gethash window which-func-table)) (puthash window current which-func-table) (force-mode-line-update))) (error (setq which-func-mode nil) (error "Error in which-func-update: %S" info))))))
But it is too hacky..
I tried to use
advice as follow:
(defadvice which-func-update-1 (around testing activate) (cl-letf (((symbol-function 'which-function) (lambda () (truncate-string-to-width (which-function) 30)))) ad-do-it))
But it generates infinite loop.
Anyone know how to limit the string length without modifying