【问题标题】:Emacs indentation in Asm modeAsm 模式下的 Emacs 缩进
【发布时间】:2010-04-19 15:17:22
【问题描述】:

我正在寻找c-indent-levelruby-indent-level 的等价物,用于asm-mode。也就是说,我想强制缩进为 4 个空格,并且我希望将它们替换为空格。

我所看到的告诉我它不存在 asm 模式。有人可以告诉我这是错的吗?

我也试过这个:Set 4 Space Indent in Emacs in Text Mode,没有 av。

我试过了:

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

但是这可行:

(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))))

但我想知道是否有办法只为asm-mode 定义它。如果我想为其他模式保留默认选项卡行为怎么办?

【问题讨论】:

    标签: emacs indentation


    【解决方案1】:

    asm-mode 使用indentation 的 tab-to-tab-stop 功能,这就是 tab-stop-list 起作用的原因。据我所知,您无能为力。您可以考虑使用一些“更高级”的 asm 模式,例如 - gas-modeasm86-mode

    【讨论】:

      【解决方案2】:

      Emacs 为每个 (?) 主要模式定义了钩子。如果您在汇编文件中执行 H-m,您可以在文本部分的末尾看到汇编程序模式挂钩称为“asm-mode-hook”。因此,当为这样的缓冲区选择汇编模式时,您可以添加代码以运行:

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

      注意,tab-width 和 indent-line-function 已经是缓冲区局部变量,所以设置它们只会改变当前缓冲区的值。这可能就是你想要的。如果你设置了一些其他变量,你可能希望使用 (make-variable-buffer-local VARIABLE) 函数使它们成为本地缓冲区。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-08-05
        • 1970-01-01
        • 1970-01-01
        • 2011-05-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多