3

I want to use emacs for drafting and editing assembler code that I can insert into Microchip MPLAB IDE for PIC projects. If I use .asm as the file extension I get a funny effect when I use a semi-colon in column one to start off a comment line -- the next line is always indented. How can I avoid this? I have "gas" as the major mode for .asm files to try to do this, but it has no effect.

Perhaps the real problem is that I do not understand the descriptions of how these modes work.

Harry Weston
  • 696
  • 8
  • 22
  • Not sure,but I think that you will need to edit asm-mode.el file or make your onw rules for editing a non-.asm terminatted file. It should be written in emacs-lisp language. Check out this implemtantion for assembly NASM's syntax rules(to you get the idea how to do) http://matthieuhauglustaine.blogspot.com.br/2011/08/nasm-mode-for-emacs.html by reading `nasm-mode.el` and/or `asm-mode.el` I believe that is enough to implement the version for assembly that you are using. Sorry for not exact answer(that's why I'm posting as comment) but I'm trying to help you. – Jack Feb 07 '13 at 03:14

1 Answers1

0

You can redefine asm-calculate-indentation by placing the function below in your init.el. To "test drive" the function you can paste it in your scratch buffer, eval it, and perform some editing in an asm file to see if this is what you want.

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

This will make it so that line directly below the ;;; will not auto indent. I do not know if you noticed, but if you leave the definition as is if the next think you put under the comment is a label when you enter the : the label will auto indent to the left, and everything below the label auto indents. I can see where this would be annoying for commenting directives or header comments though.

Cory Koch
  • 470
  • 4
  • 8