How to set up emacs for PIC assembly code

I want to use emacs to create and edit assembly language code that I can paste into Microchip MPLAB IDE for PIC projects. If I use .asm as the file extension, I get a funny effect when I use a half-line in column one to start a comment line - the next line is always indented. How can I avoid this? I have "gas" as the primary mode for .asm files to try and do this, but it has no effect.

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

+3


source to share


1 answer


You can override asm-calculate-indentation by placing the function below in init.el. To "test the disk" you can insert it into your scratch buffer, evaluate it, and do some editing in the asm file to make sure this is exactly 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 the line directly below the ;;; will not automatically retreat. I don't know if you noticed, but if you leave the definition as if the following I think you put a shortcut under the comment as you type: the shortcut will auto-indent to the left and whatever is specified under the auto-indent of the tag. I can see where it gets annoying for directive comments or header comments though.

0


source







All Articles