[英]Emacs: Turn off indentation when doing a paragraph fill in LaTeX mode
When I am using emacs to edit a latex document the paragraph fill (Esc-q) does not do what I want. 当我使用emacs编辑乳胶文档时,段落填充(Esc-q)不能满足我的要求。 For example, something like: 例如,类似:
The component \vn{%vec} is not similar to
When I use fill I get: 当我使用填充时,我得到:
The component \vn{%vec} is not
% similar to
That is, emacs is taking "%" to be a comment character and filling the paragraph accordingly. 也就是说,emacs将“%”作为注释字符并相应地填充该段落。 However, "\\vn" is a macro of mine that sets text in texttt mode and here "%" is simply a regular printable character so the paragraph fill has done things incorrectly. 但是,“ \\ vn”是我的宏,它以texttt模式设置文本,这里的“%”只是一个常规的可打印字符,因此段落填充操作不正确。
So what I want is for paragraph fill to be the same it is as in text-mode. 所以我想要的是段落填充与在文本模式下相同。 That is, no indentation and no adding extra characters. 也就是说,没有缩进,也没有添加额外的字符。 But I don't want to have to toggle between text-mode and latex-mode every time I want to paragraph fill. 但是我不想每次想填充段落时都必须在文本模式和乳胶模式之间切换。 Is there any way to do this? 有什么办法吗?
Thanks for the help. 谢谢您的帮助。 -- David - 大卫
PS: Yes, I do know that if there are real comments at the end of lines then the test-mode fill will not do things correctly. PS:是的,我确实知道,如果在行尾有真正的注释,则测试模式填充将无法正确执行操作。 But I never put comments at the end of lines so this will never bother me. 但是我从来没有在行末添加评论,所以这永远不会打扰我。
I found the solution. 我找到了解决方案。 I put this in my init.el file: 我把它放在我的init.el文件中:
(add-hook 'latex-mode-hook '(lambda() (setq comment-start nil)))
(add-hook 'tex-mode-hook '(lambda() (setq comment-start nil)))
(add-hook 'latex-mode-hook '(lambda() (setq fill-indent-according-to-mode nil)))
(add-hook 'tex-mode-hook '(lambda() (setq fill-indent-according-to-mode nil)))
I love emacs but the documentation (or lack thereof) can sometimes drive me crazy... :). 我喜欢emacs,但是文档(或缺少文档)有时会让我发疯... :)。
You can try: 你可以试试:
(setq comment-start nil)
to handle this specific case. 处理这个特殊情况。
What you're trying to fix is a symptom of the real problem -- latex-mode
is naively marking code after "%" as comment. 您要解决的是真正问题的征兆- latex-mode
天真地将“%”后的代码标记为注释。
Does installing auctex-mode fix your problem? 安装auctex模式是否可以解决您的问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.