开发者

Emacs indentation in Asm mode

I am looking for the equivalent of c-indent-level and ruby-indent-level, for asm-mode. That is, I want to force the indentation to 4 spaces, and I want them to be replaced with blanks.

What I've seen tells me it does not exist for asm-mode. Cou开发者_StackOverflow中文版ld someone please tell me this is wrong?

I tried this also: Set 4 Space Indent in Emacs in Text Mode , to no av.

I have tried:

(setq tab-width 4)
(setq indent-line-function 'insert-tab)
(setq asm-indent-level 4)

This works however:

(custom-set-variables
 '(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))))

But I wonder if there is a way to define that for asm-mode only. What if I wanted to keep the default tab behaviour for other modes?


asm-mode uses the function tab-to-tab-stop for indentation, that's why tab-stop-list is working. As far I know there is nothing more that you can do. You might consider using some of the "more advanced" asm modes such as - gas-mode or asm86-mode.


Emacs defines hooks for every (?) major mode. If you do H-m in assembly file, you can see at the end of text section that Assembler mode hook is called `asm-mode-hook'. So you can add your code to run when assembler mode is selected for a buffer like this:

(add-hook 'asm-mode-hook (lambda()
                           (setq tab-width 4)
                           (setq indent-line-function 'insert-tab)
                           (setq asm-indent-level 4)))

Note, tab-width and indent-line-function are already buffer local variables, so setting them changes their value only for the current buffer. This is probably what you want. If you setq some other variables, you may want to make them buffer local using (make-variable-buffer-local VARIABLE) function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜