[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SMIE: Indentation after comments
From: |
Andreas Matthias |
Subject: |
SMIE: Indentation after comments |
Date: |
Tue, 6 Oct 2020 17:34:06 +0200 |
The last line of the following example is not indented correctly
whereas the second line is correct. The difference is just a space
before the semi-colon. How can I fix this?
============================================================
int a /**/ ;
int b;
int a /**/;
int b;
============================================================
Here is the code:
(require 'smie)
(setq foobar-grammar
(smie-prec2->grammar
(smie-bnf->prec2
`((insts (insts ";" insts) (inst))
(inst ("int" id))
(id))
'((assoc ";")))))
(defun foobar-rules (kind token)
(message "rule: (%s . %s) at point %d" kind token (point))
(pcase (cons kind token)
;; ???
))
(define-derived-mode foobar-mode prog-mode "foobar"
:syntax-table nil
(modify-syntax-entry ?/ ". 124")
(modify-syntax-entry ?* ". 23b")
(modify-syntax-entry ?\n ">")
(setq comment-start "//")
(smie-setup foobar-grammar #'foobar-rules)
(font-lock-add-keywords nil '(("int" . font-lock-keyword-face)))
(font-lock-mode)
(font-lock-ensure (point-min) (point-max)))
- SMIE: Indentation after comments,
Andreas Matthias <=