When I type M-;, this invokes comment-dwim which, on a line containing text and with no active region, I believe ultimately invokes comment-indent to add an in-line or end-of-line comment.
In this custom major-mode, comment-start is set to "# " (and comment-style is 'plain) but this should only apply at the very start of a line. How do I get an in-line comment to start with ";; "?
Example of current behaviour:
# Whole line comment
SOME CODE HERE # in-line comment
Example of required behaviour:
# Whole line comment
SOME CODE HERE ;; in-line comment
Additionally, comment-region works perfectly when region starts at the beginning of a line and comment-start is always left-aligned for this. However, halfway through a line, it will begin the comment with comment-start (#).
You may need to make custom syntax table as described at Emacs Wiki and ErgoEmacs:
For example, for my cql-mode I use following to distinguish between
/* .. */for block comments, and--or//for single-line/end-of line comments.and in declaration of derived mode I specify:
And meaning is described in documentation for function
modify-syntax-entry: for/-1means that character can start comment,2means that it could be also 2nd character in sequence,4- that it finishes comment,bis that it could be comment typeb. for*it says that it could be second or second to last character of comment typea(default type).Similarly, for
-it declares that it could be first & second characters in comment typeb.In your case it could look following way (not tested):