Emacs在进程缓冲区中显示^ M [英] Emacs showing ^M in a process buffer

查看:324
本文介绍了Emacs在进程缓冲区中显示^ M的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有一个进程缓冲区 utf-8-auto (emacs modeline将缓冲区报告为 utf-8- auto-dos )与 CRLF 样式换行符。当我通过 process-send-region process-send-string 将多行文本写入缓冲区时行后面加上 ^ M



这个问题奇怪的是,文本直接写入进程缓冲区从过程中,不包含 ^ M



源文本来自实际上甚至已经出现在进程缓冲区中的标记和发送的多行区域(不包含 ^ M )将具有它们

注意,流程发送区域的源文本将始终来自Emacs缓冲区,process-send-string ,当多行将从Windows剪贴板界面到killring,或再次从一个Emacs缓冲区killring。)



我还应该添加,传入的文本缓冲区由一个 after-change-functions 钩子(根据输入做一些着色)解析,所以最后一个办法我会做一个额外的 regexp-replace-in-string 作为该hook函数的一部分,我想避免,因为它看起来错误,但我会添加它



附录



我更新了缓冲区的编码设置,过程使用 utf-8-dos 而不是 utf-8-auto ^ M 已消失。



所以在我的应用程序的缓冲区设置部分,我做了...

 (switch-to-buffersock-buffer)
(set-process-coding-system(get-process sock-process)'utf-8-dos'utf-8-dos)
(set-buffer-file-coding-system'utf-8-dos nil)
(set-buffer-process-coding-system'utf-8-dos'utf-8-dos)

然后将其缩小为...

 (切换到缓冲区sock-buffer)
(set-buffer-process-coding-system'utf-8-dos'utf-8-dos)

一切正常。

解决方案

这是因为这些文件是在DOS / Windows行尾。您可以使用Cx [Enter] f unix [Enter]将它们转换为Unix编码。



^ L 是分页符。我已经看过他们有时分离源代码的不同部分(对于在文本打印机中的老式列表),或在文本文档中插入实际的新页面命令。



自更新以来,此处 a>您可以看到您必须选择 set-process-coding-system 到正确的编码系统。


At the moment, I have a process-buffer which is utf-8-auto (emacs modeline reports the buffer as utf-8-auto-dos) with CRLF style newlines. When I write multi-line text into the buffer via a process-send-region or process-send-string each line is suffixed with ^M.

What makes this problem odd is that text written to the process-buffer directly from the process, does not contain ^M's.

It doesn't seem to make any difference where the source text comes from, in fact, even a multi-line region marked and sent that already appears in the process buffer (that doesn't contain ^M) will have them when sent.

(Note the source text for the process-send-region will always come from a Emacs buffer, process-send-string, when multi-line will be from the Windows clipboard interface to the killring, or again from an Emacs buffer to killring.)

I should also add that the incoming text to the buffer is parsed by a after-change-functions hook (to do some colorisation based on input) so a last resort I'd do an additional regexp-replace-in-string on this incoming text as part of that hook function, I'd like to avoid that because it seems wrong, but I'll add it as a hacky solution if nothing else works.

Addendum

I updated the encoding settings for the buffer and the process to use utf-8-dos instead of utf-8-auto and the ^M's vanished.

So in the buffer setup part of my app, I did...

(switch-to-buffer "sock-buffer")
(set-process-coding-system (get-process sock-process) 'utf-8-dos 'utf-8-dos)
(set-buffer-file-coding-system 'utf-8-dos nil)
(set-buffer-process-coding-system 'utf-8-dos 'utf-8-dos)

Then reduced this to just...

(switch-to-buffer "sock-buffer")
(set-buffer-process-coding-system 'utf-8-dos 'utf-8-dos)

And everything worked fine.

解决方案

This is because those files are in DOS/Windows line endings. You can use C-x [Enter] f unix [Enter] to convert them to the Unix encoding.

^L is a page break. I've seen them some times to separate different parts of source code (for old-fashioned listings in a text printer), or in text documentation to insert an actual "new page" command.

As of the update, here you can see that you have to select set-process-coding-system to the correct coding system.

这篇关于Emacs在进程缓冲区中显示^ M的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆