summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorManuel Giraud <manuel@ledu-giraud.fr>2026-05-04 10:14:36 +0200
committerEli Zaretskii <eliz@gnu.org>2026-05-23 14:12:19 +0300
commit7a17f97baa7d483cba5cde3cd22c34e0597e60b5 (patch)
treef385d3186385b06512f6faa1d95113a9f891a37f /lisp
parentf13287fde0d0900fe834cda9df77a072dd35d685 (diff)
Prettify special glyphs
* lisp/disp-table.el (prettify-special-glyphs-mode): New mode to display nicer special glyphs. (special-glyphs): New face for displaying special glyphs when the minor mode is active. (prettify-special-glyphs-saved-truncation) (prettify-special-glyphs-saved-continuation): Internal variables to save previous special glyphs. * etc/NEWS: Announce the change. (Bug#80628)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/disp-table.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/lisp/disp-table.el b/lisp/disp-table.el
index 9f2971a6fc3..467430f30ef 100644
--- a/lisp/disp-table.el
+++ b/lisp/disp-table.el
@@ -458,6 +458,50 @@ which characters can be displayed and which cannot."
(insert ")\n"))
(pop-to-buffer buf)))
+(defface special-glyphs
+ '((t :inherit (shadow default)))
+ "Face for displaying special glyphs."
+ :group 'basic-faces
+ :version "31.1")
+
+(defvar prettify-special-glyphs-saved-truncation)
+(defvar prettify-special-glyphs-saved-continuation)
+
+;;;###autoload
+(define-minor-mode prettify-special-glyphs-mode
+ "Mode to display pretty special character glyphs.
+If you have already customized your special character glyphs, only the
+`special-glyphs' face is applied to them. This mode only applies to the
+`standard-display-table'. Window or buffer display table, if defined,
+still take precedence."
+ :global t
+ :group 'display
+ (if prettify-special-glyphs-mode
+ (let ((tbl standard-display-table)
+ truncation wrap)
+ ;; Save current glyphs.
+ (setq prettify-special-glyphs-saved-truncation
+ (display-table-slot tbl 'truncation)
+ prettify-special-glyphs-saved-continuation
+ (display-table-slot tbl 'wrap))
+ ;; Prepare new ones with face.
+ (setq truncation
+ (if prettify-special-glyphs-saved-truncation
+ (make-glyph-code prettify-special-glyphs-saved-truncation
+ 'special-glyphs)
+ (make-glyph-code ?→ 'special-glyphs))
+ wrap
+ (if prettify-special-glyphs-saved-continuation
+ (make-glyph-code prettify-special-glyphs-saved-continuation
+ 'special-glyphs)
+ (make-glyph-code ?↩ 'special-glyphs)))
+ ;; Alter display-table.
+ (set-display-table-slot tbl 'truncation truncation)
+ (set-display-table-slot tbl 'wrap wrap))
+ (let ((tbl standard-display-table))
+ ;; Reset saved glyphs.
+ (set-display-table-slot tbl 'truncation prettify-special-glyphs-saved-truncation)
+ (set-display-table-slot tbl 'wrap prettify-special-glyphs-saved-continuation))))
(provide 'disp-table)