summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/facemenu.el26
-rw-r--r--lisp/textmodes/enriched.el19
2 files changed, 43 insertions, 2 deletions
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index be5a18c8cc7..a4f675b8c11 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -188,6 +188,8 @@ it will remove any faces not explicitly in the list."
(let ((map (make-sparse-keymap "Special")))
(define-key map [?s] (cons (purecopy "Remove Special")
'facemenu-remove-special))
+ (define-key map [?c] (cons (purecopy "Charset")
+ 'facemenu-set-charset))
(define-key map [?t] (cons (purecopy "Intangible")
'facemenu-set-intangible))
(define-key map [?v] (cons (purecopy "Invisible")
@@ -433,6 +435,28 @@ This sets the `read-only' text property; it can be undone with
(interactive "r")
(add-text-properties start end '(read-only t)))
+(defun facemenu-set-charset (cset &optional start end)
+ "Apply CHARSET text property to the region or next character typed.
+
+If the region is active (normally true except in Transient
+Mark mode) and nonempty, and there is no prefix argument,
+this command adds CHARSET property to the region. Otherwise, it
+sets the CHARSET property of the character at point."
+ (interactive (list (progn
+ (barf-if-buffer-read-only)
+ (read-charset
+ (format "Use charset (default %s): " (charset-after))
+ (charset-after)))
+ (if (and mark-active (not current-prefix-arg))
+ (region-beginning))
+ (if (and mark-active (not current-prefix-arg))
+ (region-end))))
+ (or start
+ (setq start (min (point) (1- (point-max)))
+ end (1+ start)))
+ (remove-text-properties start end '(charset nil))
+ (put-text-property start end 'charset cset))
+
(defun facemenu-remove-face-props (start end)
"Remove `face' and `mouse-face' text properties."
(interactive "*r") ; error if buffer is read-only despite the next line.
@@ -452,7 +476,7 @@ These special properties include `invisible', `intangible' and `read-only'."
(interactive "*r") ; error if buffer is read-only despite the next line.
(let ((inhibit-read-only t))
(remove-text-properties
- start end '(invisible nil intangible nil read-only nil))))
+ start end '(invisible nil intangible nil read-only nil charset nil))))
(defalias 'facemenu-read-color 'read-color)
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 <x-bg-color>")
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 <x-charset> 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.