From 3589c966b743850c29b89b83710783d4ea026770 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 19 May 2018 18:17:38 +0300 Subject: Use Enriched mode in etc/HELLO to keep charset information This allows to encode HELLO in UTF-8, thus supporting the entire repertory of Unicode, while still keeping the charset info where that is important. Suggested by Michael Welsh Duggan . * lisp/textmodes/enriched.el (enriched-translations): Add translations for 'charset'. (enriched-decode-charset, enriched-handle-charset-prop): New functions. * lisp/facemenu.el (facemenu-special-menu): Add sub-menu for 'charset' property. (facemenu-set-charset): New function. (facemenu-remove-special): Remove the 'charset' property as well. * etc/NEWS: Announce the new feature of Enriched mode. * etc/HELLO: Recode in UTF-8 and place under Enriched mode. * doc/emacs/text.texi (Enriched Properties): Mention the support for 'charset'. --- lisp/textmodes/enriched.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lisp/textmodes') diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el index b9d247132dc..6b4c44a39e7 100644 --- a/lisp/textmodes/enriched.el +++ b/lisp/textmodes/enriched.el @@ -120,9 +120,11 @@ expression, which is evaluated to get the string to insert.") ;; The following are not part of the standard: (FUNCTION (enriched-decode-foreground "x-color") (enriched-decode-background "x-bg-color") - (enriched-decode-display-prop "x-display")) + (enriched-decode-display-prop "x-display") + (enriched-decode-charset "x-charset")) (read-only (t "x-read-only")) (display (nil enriched-handle-display-prop)) + (charset (nil enriched-handle-charset-prop)) (unknown (nil format-annotate-value)) ; (font-size (2 "bigger") ; unimplemented ; (-2 "smaller")) @@ -492,6 +494,21 @@ Return value is \(begin end name positive-p), or nil if none was found." (list from to 'face (list ':background color)) (message "Warning: no color specified for ") nil)) + +(defun enriched-decode-charset (from to &optional cset) + (let ((cs (when (stringp cset) + (condition-case () + (car (read-from-string cset)) + (error nil))))) + (unless cs + (message "Warning: invalid parameter %s" cset)) + (list from to 'charset cs))) + +(defun enriched-handle-charset-prop (old new) + "Return a list of annotations for a change in the `charset' property." + (cons (and old (list (list "x-charset" (symbol-name old)))) + (and new (list (list "x-charset" (symbol-name new)))))) + ;;; Handling the `display' property. -- cgit v1.2.3