[英]EMACS and TAB key (indent vs \t insert)
Let's say I have a <weird language>
file and I'm editing it. 假设我有一个
<weird language>
文件,我正在编辑它。
If the cursor is at the beginning of a sentence (let's say an if
, which is already indented 2 levels) and I hit TAB
, I'd expect EMACS to increase +1 the indent level of that line (using a TAB
or N SPACEs
, depending on the indent style used in the file). 如果光标位于句子的开头(假设一个
if
,已经缩进了2个级别),并且我按了TAB
,那么我希望EMACS可以增加该行的缩进级别+1(使用TAB
或N SPACEs
,具体取决于文件中使用的缩进样式)。
Anyways, if I hit TAB
and the cursor is after the if
, I'd expect EMACS to insert a plain \\t
. 无论如何,如果我按下
TAB
并且光标位于if
之后, if
我希望EMACS插入一个普通\\t
。
How can I make EMACS behave like this? 如何使EMACS表现得像这样?
Regards 问候
Took current indentation as at-beginning. 将当前缩进作为开始。 That condition might need a modification.
该条件可能需要修改。 See also third clause.
另请参阅第三条款。
(defun my-indent-or-insert-tab ()
"Insert a TAB or indent depending on context. "
(interactive "*")
(cond((eq (current-column) (current-indentation))
(indent-for-tab-command))
((member (char-after) (list ?\t ? ?\n))
(insert "\t"))
(t (message "%s" "Don't know what to do if inside word"))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.