~/.emacs
中使用这个来自定义asm-mode,使它对NASM语法非常可用,对GAS语法也还可以。 (语法高亮等使用;
作为注释字符,因此带有#
的GAS会很混乱。 我还没有研究过如何更改这个)。;
而不让asm-mode认为它知道我想要的注释位置。%nasm_macro
指令、global
、section
和以:
结尾的标签。(defun my-asm-mode-hook ()
;; you can use `comment-dwim' (M-;) for this kind of behaviour anyway
(local-unset-key (vector asm-comment-char))
;; (local-unset-key "<return>") ; doesn't work. "RET" in a terminal. http://emacs.stackexchange.com/questions/13286/how-can-i-stop-the-enter-key-from-triggering-a-completion-in-company-mode
(electric-indent-local-mode) ; toggle off
; (setq tab-width 4)
(setq indent-tabs-mode nil)
;; asm-mode sets it locally to nil, to "stay closer to the old TAB behaviour".
;; (setq tab-always-indent (default-value 'tab-always-indent))
(defun asm-calculate-indentation ()
(or
;; Flush labels to the left margin.
; (and (looking-at "\\(\\.\\|\\sw\\|\\s_\\)+:") 0)
(and (looking-at "[.@_[:word:]]+:") 0)
;; Same thing for `;;;' comments.
(and (looking-at "\\s<\\s<\\s<") 0)
;; %if nasm macro stuff goes to the left margin
(and (looking-at "%") 0)
(and (looking-at "c?global\\|section\\|default\\|align\\|INIT_..X") 0)
;; Simple `;' comments go to the comment-column
;(and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column)
;; The rest goes at column 4
(or 4)))
)
(add-hook 'asm-mode-hook #'my-asm-mode-hook)
.my_loop:
这样的东西,直到你按下回车键它才会被正确缩进,所以需要花一点时间适应快速输入并且不期望需要在按下回车键后回去修正行缩进。;
放置它们的列上。
~/.emacs
文件来自定义Emacs模式。上次我尝试默认禁用electric-semicolon时,它没有起作用(使用(add-hook 'asm-mode-hook #'my-asm-mode-hook)
运行之前定义的一个函数,该函数运行(local-unset-key (vector asm-comment-char))
)。如果我手动运行M-x eval-expression
,那么local-unset-key
会起作用。如果我想一直使用它,我应该花些时间学习Emacs自定义设置。 - Peter Cordes