[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Displaying a string as another one
From: |
Stefan Monnier |
Subject: |
Re: Displaying a string as another one |
Date: |
Mon, 16 Mar 2020 11:58:16 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Does anyone have a ready-made solution?
You could start with something like
(defun my-decode-\n-\t ()
(font-lock-add-keywords nil
'(("\\\\[nt]"
(0 (my-apply-decode (match-beginning 0) (match-end 0)))))))
(defun my-apply-decode (beg end)
(when (= 0 (mod (save-excursion (goto-char beg)
(skip-chars-backward "\\\\"))
2))
`(face nil
display ,(string (if (eq (char-before end) ?n) ?\n ?\t)))))
(add-hook 'foo-mode-hook #'my-decode-\n-\t)
-- Stefan