1

Hi I'm working on some assembly language files.

Here is a relevant snippet

            // Wait for line $ff and prepare next frame 
loop2:      lda #$ff                            // <- Inside the scope labels can collide so we use 'loop2' 
            cmp $d012
            bne loop2

What I'd like is for the comments to wrap where they are. i.e. a comment should wrap and be indented where the original comment began.

This should in theory be possible with visual-fill-column-mode and adaptive-wrap-prefix-mode - it should just be a matter of setting adaptive-fill-regexp to .*// and according to the documentation:

the candidate must match this regular expression, or match comment-start-skip. If it doesn’t, fill-context-prefix replaces the candidate with a string of spaces of the same width as it.

So I should get a string of spaces to give me an indent to match the original comment start.

Instead however I get this:

            // Wait for line $ff and prepare next frame 
loop2:      lda #$ff                            // <- Inside the scope labels can
loop2:      lda #$ff                              //collide so we use 'loop2'   
            cmp $d012
            bne loop2

Which is what you'd expect if the space-filling logic described in the doc wasn't working.

I've even tracked down the code in emacs (fill.el.gz), and it seems like it should do what I expect, but I don't have the knowhow at this point in time to actually debug it myself.

;; If first-line-prefix comes from the first line,
;; see if it seems reasonable to use for all lines.
;; If not, replace it with whitespace.
(if (or (and first-line-regexp
             (string-match first-line-regexp
                           first-line-prefix))
        (and comment-start-skip
             (string-match comment-start-skip
                           first-line-prefix)))
    first-line-prefix
  (make-string (string-width first-line-prefix) ?\s))

anyone any idea what I could be doing wrong?

1
  • I don't know what's wrong, but if you M-x edebug-defun with your cursor on that function in fill.el, and then reproduce the bug, you'll land in that function and be able to step through it (in spacemacs, keep hitting s, in vanilla emacs I think it's SPC) Feb 26, 2021 at 19:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.