help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get forward-comment work for major mode that can't use syntax for


From: Pierre Rouleau
Subject: How to get forward-comment work for major mode that can't use syntax for all comments?
Date: Tue, 15 Apr 2025 14:45:06 -0400

Hi all,

I am currently writing a major mode for the Seed7 programming language
(at https://github.com/pierre-rouleau/seed7-mode).

Seed7 has 2 types of comments:
- The nestable block comments that use "(*" as  comment start and  "*)" to
end it.
- Line ending comments that start with a '#'

Unfortunately it also uses the '#' as a integer radix/base separator inside
integer literals (
https://seed7.sourceforge.net/manual/tokens.htm#Integer_literals):
- 2#0101010101
- 16#a0

I can use the syntax table to identify nestable (* *) comments.

But I can't use the syntax table for the line ned comments that start with
'#'
because it would interpret 16#a0 as a comment starting after the '6'.

So I deal with line-end comments using regular expressions.

That seems to cause a problem with `forward-comment':
`(forward-comment 1)' works as expected for Seed7 block comments.
It also works properly when the line-end comments are identified via the
syntax table.
But it does not work properly when the line-end comment is not identified
by the syntax table (and identified by regular expressions) despite the
following code:

  ;; Seed7 Comments Control

  ;; - Currently cannot rely on syntax table to identify line-end comments

  ;;   because Seed7 uses the '#' as integer base separator.

  (with-no-warnings
    (when (< emacs-major-version 24)
      (setq-local comment-use-global-state nil))
    (when (> emacs-major-version 26)
      (setq-local comment-use-syntax-ppss  nil)))
  (setq-local comment-use-syntax nil)

My questions:
- Is there a way to express line-end comments with the Seed7 use of '#'
integer-base format to allow the syntax to work in all cases?
- If the answer to the above question is 'no', is there a way to make
`(forward-comment 1)` move over the line-end comment as expected?

Thanks!

-- 
/Pierre


reply via email to

[Prev in Thread] Current Thread [Next in Thread]