1

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?

Flux
  • 583
  • 2
  • 16
  • 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. https://emacs.stackexchange.com/a/9627/2287 – lawlist Aug 06 '19 at 02:27

1 Answers1

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.

Tobias
  • 32,569
  • 1
  • 34
  • 75