I've defined my own major mode using define-generic-mode
, and in the setup function I have (set (make-local-variable 'indent-line-function) 'my-indent-function)
.
This works fine in general code, however it is not called at all when I'm inside a comment, as defined by the syntax table with:
;; // Comments (style a)
(modify-syntax-entry ?\/ ". 124" (syntax-table))
(modify-syntax-entry ?\n "> " (syntax-table))
;; /* Comments (style b) */
(modify-syntax-entry ?* ". 23b" (syntax-table))
Either // line comments
or /* Java comments */
are allowed.
I've tried setting comment-line-break-function
as I saw that it is set in Java mode, but this doesn't have any effect. I also tried setting comment-indent-function
to nil
, but again I couldn't see any effect.
EDIT: Added example minimal repro.
To test, just run emacs -Q
, paste the following into a buffer and run eval-buffer
, then open test.tmp
. Every time you hit return not inside a comment you will see "Called indent-line!" in the mini-buffer. Inside a comment you will not. This is my question.
(define-generic-mode
tmp-mode ; mode name
;; comments
nil
;; keywords
'("if" "then" "else")
;; other things to highlight
nil
;; auto mode alist
'("\\.tmp?$")
;; other function to run
(list 'tmp-mode--setup-function)
"A mode for tmp files")
(defun tmp-mode--setup-function ()
(modify-syntax-entry ?_ "w" (syntax-table))
;; // Comments (style a)
(modify-syntax-entry ?\/ ". 124" (syntax-table))
(modify-syntax-entry ?\n "> " (syntax-table))
;; /* Comments (style b) */
(modify-syntax-entry ?* ". 23b" (syntax-table))
(modify-syntax-entry ?@ "_" (syntax-table))
(set (make-local-variable 'indent-line-function) 'tmp-mode/indent-line))
(defun tmp-mode/indent-line ()
(message "Called indent-line!"))
(provide 'tmp)