Let's say I have a <weird language>
file and I'm editing it.
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).
Anyways, if I hit TAB
and the cursor is after the if
, I'd expect EMACS to insert a plain \\t
.
How can I make EMACS behave like this?
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"))))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.