I currently have the hook below for displaying tabs when in text mode:

(add-hook 'text-mode-hook
          (lambda () (standard-display-ascii ?\t "!---")))

I only want that setting to apply in text mode.

The problem: Once I open a text file, the above setting will be set for all subsequent buffers that I open. That is not the desired outcome. How can I apply a setting to only one mode?

  • If you want to add some color to the glyphs using the buffer-display-table, here is a link to an example that plays with smiley faces, em-dash and en-dash. emacs.stackexchange.com/a/9627/2287
    – lawlist
    Aug 6, 2019 at 2:27

1 Answer 1


Use buffer-display-table instead of standard-display-table:

(defun my-text-mode-hook-fun ()
   (unless buffer-display-table
      (setq buffer-display-table (make-display-table)))
   (aset buffer-display-table ?\t (vconcat "!---")))

(add-hook 'text-mode-hook #'my-text-mode-hook-fun)

Also note that there is the highly configurable whitespace-mode for your special purpose of displaying tab-characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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