unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Andreas Matthias <andreas.matthias@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: SMIE: Indentation after comments
Date: Tue, 6 Oct 2020 17:34:06 +0200	[thread overview]
Message-ID: <CAHp59H2QpAofVuczdUyx3cKPpHdk9xuX-e0wn9ChnzPtPgG3Gg@mail.gmail.com> (raw)

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)))



             reply	other threads:[~2020-10-06 15:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06 15:34 Andreas Matthias [this message]
2020-10-06 15:59 ` SMIE: Indentation after comments Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp59H2QpAofVuczdUyx3cKPpHdk9xuX-e0wn9ChnzPtPgG3Gg@mail.gmail.com \
    --to=andreas.matthias@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).