I tried to use text-property to decorate specific texts as well as automatically color tab characters in a text-mode buffer, but didn't find a way to realize them at the same time.
This is my try:
Start Emacs with the option -Q:
foo@bar:~$ emacs -Q
Open a new text file and an existing C file:
Copy a colored text from the c-mode buffer (M-w : kill-ring-save) to the text-mode buffer (C-y : yank).
The pasted text at this time is colored the same.
Then, make a font-lock rule to set backgound color of tab characters in the text mode buffer to make tab visible.
(font-lock-add-keywords nil ; current buffer `(("\\(\t+\\)" ; Tab 1 '((t (:background "gray"))) prepend)))
While all tab characters get colored as expected, the pasted decorated texts become back to default uncolored look.
I want only the tab background to be colored, while keeping existing texts decorated. And, I want to make it by 2 strokes, copy and paste (M-w and C-y).
Newly copied texts to the text buffer also no longer keep the original colors.
How can I make use of font-lock feature, as well as keeping existing static text-property faces in a buffer?
Emacs 27.1, Ubuntu 22.04.3 LTS
emacs -Q
(no init file). At each step show exactly what you do, say what you expect to see as the effect, and what you see instead.