summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2002-02-26 16:27:47 +0000
committerEli Zaretskii <eliz@gnu.org>2002-02-26 16:27:47 +0000
commitee91a447ce7fd4b2dbeaa773d8efd54210d9dce8 (patch)
tree5593b5603dc8fa820227bf9fa26d64065262bfd2
parentb8c5f62b051f4ef779ab70f0aa5861b495aafb53 (diff)
downloademacs-ee91a447ce7fd4b2dbeaa773d8efd54210d9dce8.tar.gz
(ctext-pre-write-conversion): Handle the
case when FROM is a string, and when we are called from build_annotations_2.
-rw-r--r--lisp/international/mule.el24
1 files changed, 21 insertions, 3 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 9bb9c4bf5cc..8235ce58e65 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1392,9 +1392,23 @@ encode each character in this charset. NOCTETS can be 0 (meaning the number
of octets per character is variable), 1, 2, 3, or 4.")
(defun ctext-pre-write-conversion (from to)
- "Encode characters between FROM and TO as Compound Text w/Extended Segments."
- (buffer-disable-undo) ; minimize consing due to insertions and deletions
- (narrow-to-region from to)
+ "Encode characters between FROM and TO as Compound Text w/Extended Segments.
+
+If FROM is a string, or if the current buffer is not the one set up for us
+by run_pre_post_conversion_on_str, generate a new temp buffer, insert the
+text, and convert it in the temporary buffer. Otherwise, convert in-place."
+ (cond ((and (string= (buffer-name) " *code-converting-work*")
+ (not (stringp from)))
+ ; Minimize consing due to subsequent insertions and deletions.
+ (buffer-disable-undo)
+ (narrow-to-region from to))
+ (t
+ (let ((buf (current-buffer)))
+ (set-buffer (generate-new-buffer " *temp"))
+ (buffer-disable-undo)
+ (if (stringp from)
+ (insert from)
+ (insert-buffer-substring buf from to)))))
(encode-coding-region from to 'ctext-no-compositions)
;; Replace ISO-2022 charset designations with extended segments, for
;; those charsets that are not part of the official X registry.
@@ -1404,6 +1418,8 @@ of octets per character is variable), 1, 2, 3, or 4.")
(case-fold-search nil)
pt desig encode-info encoding chset noctets textlen)
(set-buffer-multibyte nil)
+ ;; The regexp below finds the leading sequences for big5 and
+ ;; iso8859-1[03-6] charsets.
(while (re-search-forward "\e\\(\$([01]\\|-[VY_bf]\\)" nil 'move)
(setq desig (match-string 1)
pt (point-marker)
@@ -1416,6 +1432,7 @@ of octets per character is variable), 1, 2, 3, or 4.")
(cond
((eq encoding t) ; only the leading sequence needs to be changed
(setq textlen (+ (- newpt pt) (length chset) 1))
+ ;; Generate the ICCCM control sequence for an extended segment.
(replace-match (format "\e%%/%d%c%c%s"
noctets
(+ (/ textlen 128) 128)
@@ -1437,6 +1454,7 @@ of octets per character is variable), 1, 2, 3, or 4.")
chset))))
(goto-char newpt))))
(set-buffer-multibyte t)
+ ;; Must return nil, as build_annotations_2 expects that.
nil)
;;; FILE I/O