[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: yet more term.el fixes #2

From: Stefan Monnier
Subject: Re: yet more term.el fixes #2
Date: Wed, 22 Sep 2004 16:23:52 -0400
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux)

> (insert (string-as-unibyte (substring str i funny)))

I think string-as-unibyte is also an extremely poor choice here and will
likely lead to unexpected errors in some cases (it's a function that should
have big warning signs all around it, like string-as-multibyte).

Also calling set-buffer-multibyte is to be avoided if possible.

Can you try with

  (insert (decode-coding-string (substring str i funny) locale-coding-system))

Also based on your above code, it seems that `str' is a multibyte string,
which sounds wrong.  I think that the coding-system used for the process's
output should be `binary'.  Can you see what coding-system is used for
the process?

I suggest a patch like the one below,


--- orig/lisp/term.el
+++ mod/lisp/term.el
@@ -1290,7 +1290,8 @@
     (let ((proc (get-buffer-process buffer)))  ; Blast any old process.
       (if proc (delete-process proc)))
     ;; Crank up a new process
-    (let ((proc (term-exec-1 name buffer command switches)))
+    (let ((proc (term-exec-1 name buffer command switches))
+         (coding-system-for-read 'binary))
       (make-local-variable 'term-ptyp)
       (setq term-ptyp process-connection-type) ; t if pty, nil if pipe.
       ;; Jump to the end, and set the process mark.
@@ -2722,7 +2724,7 @@
                          ;; following point if not eob nor insert-mode.
                          (let ((old-column (current-column))
                                columns pos)
-                           (insert (substring str i funny))
+                           (insert (decode-coding-string (substring str i 
funny) locale-coding-system))
                            (setq term-current-column (current-column)
                                  columns (- term-current-column old-column))
                            (when (not (or (eobp) term-insert-mode))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]