From 8dd18bbb6f3c09a4988cf2e06378aa24b098fb85 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 19 Oct 2019 12:12:31 +0300 Subject: [PATCH] Fix display of Info files on TTY frames * lisp/info.el (info-symbols-and-replacements): New variable. (Info-mode): Use 'info-symbols-and-replacements' to set up a buffer-display-table for non-ASCII symbols used by Info files that cannot be displayed on TTY frames. --- lisp/info.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lisp/info.el b/lisp/info.el index fc0d58068a7..951bdad4c2b 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4297,6 +4297,33 @@ With a zero prefix arg, put the name inside a function call to `info'." (defvar Info-mode-font-lock-keywords '(("‘\\([‘’]\\|[^‘’]*\\)’" (1 'Info-quoted)))) +;; See info-utils.c:degrade_utf8 in Texinfo for the source of the list +;; below. +(defvar info-symbols-and-replacements + '((?\‘ . "`") + (?\’ . "'") + (?\“ . "\"") + (?\” . "\"") + (?© . "(C)") + (?\》 . ">>") + (?→ . "->") + (?⇒ . "=>") + (?⊣ . "-|") + (?★ . "-!-") + (?↦ . "==>") + (?‐ . "-") + (?‑ . "-") + (?‒ . "-") + (?– . "-") + (?— . "--") + (?− . "-") + (?… . "...") + (?• . "*") + ) + "A list of Unicode symbols used in Info files and their ASCII translations. +Each element should be a cons cell with its car a character and its cdr +a string of ASCII characters.") + ;; Autoload cookie needed by desktop.el ;;;###autoload (define-derived-mode Info-mode nil "Info" ;FIXME: Derive from special-mode? @@ -4368,6 +4395,20 @@ Advanced commands: (setq case-fold-search t) (setq buffer-read-only t) (setq Info-tag-table-marker (make-marker)) + (unless (or (display-multi-font-p) + (coding-system-equal + (coding-system-base (terminal-coding-system)) + 'utf-8)) + (dolist (elt info-symbols-and-replacements) + (let ((ch (car elt)) + (repl (cdr elt))) + (or (char-displayable-p ch) + (aset (or buffer-display-table + (setq buffer-display-table (make-display-table))) + ch (vconcat (mapcar (lambda (c) + (make-glyph-code c 'homoglyph)) + repl))))))) + (if Info-use-header-line ; do not override global header lines (setq header-line-format '(:eval (get-text-property (point-min) 'header-line)))) -- 2.39.2