GNU Emacs 24.1:强制TAB键插入< tab>字符在ESS模式 [英] GNU Emacs 24.1: forcing the TAB key to insert a <tab> character in ESS mode

查看:374
本文介绍了GNU Emacs 24.1:强制TAB键插入< tab>字符在ESS模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了插入< tab> \t )字符。继续键入 C-q TAB 来执行此操作是不能接受的,因为我主要使用选项卡进行注释。我的大部分代码缩进是由Emacs自动匹配我的第一行手动缩进,并通过绑定 indent-region C-TAB 完成的。我主要使用Tab键缩进我的评论。我更喜欢将我的标签宽度设置为8个字符,并通过两个制表符字符缩进每个我的注释,共16个字符的空格。如果ESS不容易出现故障,我将可以使用现有的系统来管理缩进,如这里。我目前正在处理的文件已经出现虚线,导致了所描述的问题。目前,在该文件中,按选项卡键将生成NO结果。



如何强制Tab键在ESS [S]和ESS [SAS]模式下插入制表符?



我尝试添加

 (全局设置键\Ci'self-insert-command) 

 (setq-default tab-always-indent nil)

到我的 .emacs 文件,但这并没有改变ESS中的行为。我不知道Emacs在内部称为ESS [S]模式,即

 (define-key ess-mode-map \Ci'self-insert-command)

产生错误


变量ess-mode-map无效


尝试 ess-S模式 ess-s-mode ESS-S模式和其他几个结果相同。



我还确认了 ess-mode-hook ess-mode-map 是预期的钩子和地图变量。然后我尝试

 (add-hook'ess-mode-hook(lambda()(define-key\t ess-mode-map'self-insert-command))

哪些不起作用。 p>

我尝试编辑ess-mode.el文件,并将\t的键盘图更改为'self-insert-command 没有效果。

解决方案

实用的解决方案很简单,只需添加:

 (add-hook'ess-mode-hook(lambda()(local-set-key\t'self-insert-command))

.emacs 文件。


I almost never use the TAB key for anything except inserting a <tab> (\t) character. It is unacceptable to continue typing C-q TAB to do this, because I mostly use tabs for comments. Most of my code indentation is accomplished by Emacs automatically matching my first line of manual indentation, and by binding indent-region to C-TAB. I mostly use the tab key to indent my comments. I prefer to set my tab width to 8 characters and indent each of my comments by two tab characters for a total of 16 characters of white space. I would be OK living with the existing system for managing indentation if ESS were not prone to failure as described here. The file that I am currently working on has broken lines which cause exactly the problem described. At present, in that file, pressing the tab key produces NO result.

How does one force the tab key to insert a tab character in ESS[S] and ESS[SAS] modes?

I have tried adding

(global-set-key "\C-i" 'self-insert-command)

and

(setq-default tab-always-indent nil)

to my .emacs file, but this has not changed behavior in ESS. I cannot figure out what Emacs calls ESS[S] mode internally, i.e.,

(define-key ess-mode-map "\C-i" 'self-insert-command)

produces the error

"Variable ess-mode-map is void."

I tried ess-S-mode, ess-s-mode, ESS-S-mode, and a few others with the same result.

I have also confirmed that ess-mode-hook and ess-mode-map are the expected hook and map variables. I then tried

(add-hook 'ess-mode-hook (lambda () (define-key "\t" ess-mode-map 'self-insert-command)))

which did not work.

I tried editing the ess-mode.el file and changing the keymap for "\t" to 'self-insert-command which produced no effect.

解决方案

The practical solution was simple, just add:

(add-hook 'ess-mode-hook (lambda () (local-set-key "\t" 'self-insert-command)))

to the .emacs file.

这篇关于GNU Emacs 24.1:强制TAB键插入&lt; tab&gt;字符在ESS模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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