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.
This commit is contained in:
Eli Zaretskii 2019-10-19 12:12:31 +03:00
parent a3726f057b
commit 8dd18bbb6f

View file

@ -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))))