如何为PIC汇编代码设置Emacs

3
我想使用emacs来起草和编辑汇编代码,以便将其插入到Microchip MPLAB IDE for PIC项目中。如果我将文件扩展名设置为“.asm”,并在第一列使用分号作为注释行的开头,会产生一个有趣的效果 - 下一行总是有缩进。如何避免这种情况?我已经将“.asm”文件的主要模式设置为“gas”来尝试解决此问题,但没有效果。
也许真正的问题是我不理解这些模式如何工作的描述。

不确定,但我认为您需要编辑asm-mode.el文件或制作自己的规则以编辑非.asm结尾的文件。它应该用emacs-lisp语言编写。查看这个汇编NASM语法规则的实现(以便您了解如何操作)http://matthieuhauglustaine.blogspot.com.br/2011/08/nasm-mode-for-emacs.html 通过阅读nasm-mode.el和/或asm-mode.el,我相信足以实现您正在使用的汇编版本。很抱歉没有确切的答案(这就是我发布评论的原因),但我正在努力帮助您。 - Jack
1个回答

0

您可以通过在init.el中添加以下函数来重新定义asm-calculate-indentation。为了“试用”该函数,您可以将其粘贴到scratch缓冲区中,对其进行评估,并在asm文件中执行一些编辑操作,以查看是否符合您的要求。

(defun asm-calculate-indentation ()
  (or
   ;; Flush labels to the left margin.
   (and (looking-at "\\(\\sw\\|\\s_\\)+:") 0)
   ;; Same thing for `;;;' comments.
   (and (looking-at "\\s<\\s<\\s<") 0)
   ;; Simple `;' comments go to the comment-column.
   (and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column)
   ;; Do not indent after ';;;' comments.
   (and (progn
          (previous-line)
          (beginning-of-line)
          (looking-at "\\s<\\s<\\s<")) 0)
   ;;The rest goes at the first tab stop.
   (or (car tab-stop-list) tab-width))

这样做将使分号直接下面的行不自动缩进。 我不知道你是否注意到,但如果你将定义保留原样,如果下一个注释下面放置的是标签,当你输入:时,标签将自动向左缩进,而标签下面的所有内容也会自动缩进。我可以理解这会对指令或标题注释造成困扰。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接