【问题标题】:How do I set up emacs for PIC assembler code如何为 PIC 汇编代码设置 emacs
【发布时间】:2013-02-06 19:18:01
【问题描述】:

我想使用 emacs 来起草和编辑我可以插入 Microchip MPLAB IDE for PIC 项目的汇编代码。如果我使用 .asm 作为文件扩展名,当我在第一列中使用分号开始注释行时,我会得到一个有趣的效果——下一行总是缩进。我怎样才能避免这种情况?我将“gas”作为 .asm 文件的主要模式来尝试执行此操作,但它没有效果。

也许真正的问题是我不理解这些模式如何工作的描述。

【问题讨论】:

  • 不确定,但我认为您需要编辑 asm-mode.el 文件或制定 onw 规则来编辑非 .asm 终止文件。它应该用 emacs-lisp 语言编写。通过阅读nasm-mode.el 和/或asm-mode.el 来查看汇编NASM 语法规则的这个实现(让您知道怎么做)matthieuhauglustaine.blogspot.com.br/2011/08/… 我相信这足以实现您正在使用的汇编版本。抱歉,答案不准确(这就是我发表评论的原因),但我想帮助你。

标签: assembly emacs pic


【解决方案1】:

您可以通过将下面的函数放在 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))

这将使该行直接位于 ;;; 下方不会自动缩进。 我不知道你是否注意到了,但是如果你保持原样,如果下一个 当您输入时,认为您在评论下放置的是一个标签:标签将自动 向左缩进,标签下方的所有内容都自动缩进。不过,我可以看到这对于评论指令或标头 cmets 来说会很烦人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 2021-02-27
    • 2013-01-22
    • 2020-11-04
    • 2011-09-13
    • 1970-01-01
    相关资源
    最近更新 更多