Unicode characters in emacs term-mode

后端 未结 3 1386
遇见更好的自我
遇见更好的自我 2020-12-14 04:33

I use ansi-term for my normal terminal sessions. I tend to use unicode characters in my prompt to do things like set the trailing character based on the type of source cont

相关标签:
3条回答
  • 2020-12-14 04:51

    Try

    (set-terminal-coding-system 'utf-8-unix)
    

    That's C-x RET t not C-x RET p.


    So C-x RET p helps? Unless C-h v default-process-coding-system is (utf-8-unix . utf-8-unix) try

    (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
    
    0 讨论(0)
  • 2020-12-14 04:52

    After getting a better understanding of term.el, the following works:

    (defadvice ansi-term (after advise-ansi-term-coding-system)
        (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
    (ad-activate 'ansi-term)
    

    Trying this with term-mode-hook is broken because in term.el, term-mode-hook is called before switching to the terminal buffer, so set-buffer-process-coding-system breaks due to the lack of a process associated with the buffer.

    0 讨论(0)
  • 2020-12-14 05:00

    The following worked for me:

    (add-hook 'term-exec-hook
              (function
               (lambda ()
                 (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))))
    

    ansi-term seems to ignore the default-process-coding-system variable, so I had to set it buffer-locally after it executes my shell.

    0 讨论(0)
提交回复
热议问题