i know i can change what info to display in modeline in mode-line-format variable. But how to display mode-line-position for one mode, but not display it for another?

1 Answer 1


Use (setq-local mode-line-position nil) in the mode-hook.


(define-derived-mode my-mode nil "my") ;; Our playground.

(defun remove-mode-line-position () ;; That's the thing you actually need.
  "Set `mode-line-position' buffer-locally to nil."
  (setq-local mode-line-position nil))

(add-hook 'my-mode-hook #'remove-mode-line-position) ;; Usage example.

If you create a new buffer with C-x b *mybuf* RET and call M-x my-mode RET the position info in the modeline disappears for buffer *mybuf* but for no other buffer.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.