ada-mode-users
[Top][All Lists]
Advanced

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

Re: [Ada-mode-users] Gnu Emacs Ada mode 6.0.1 released.


From: Stephen Leake
Subject: Re: [Ada-mode-users] Gnu Emacs Ada mode 6.0.1 released.
Date: Thu, 28 Mar 2019 02:13:46 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (windows-nt)

Stephen Leake <address@hidden> writes:

> Simon Wright <address@hidden> writes:
>
>> When inserting a comment, the marker appears after the leading '-' &
>> doesn't go away as the rest of the comment is typed (until DEL or
>> RET).
>
> Ah. There's a bug in the elisp code that triggers a reparse; after the
> second '-', you are editing a comment, so it thinks no reparse is needed
> :(.

The original error mark is not a bug; a lone '-' that will eventually
start a comment is a syntax error.

The bug that caused the error mark to not disappear when the second '-'
is typed is still there (it never made it to my todo list :(). I'll work
on that for the next release.

By default, font-lock triggers a reparse on every character. That's
required when a character (ie '.') changes a name from a variable to a
package or type name, for example.

One workaround is to set:

(setq jit-lock-defer-time 0.2)

That delays the font-lock long enough to type the second '-', avoiding
the syntax error. jit-lock-defer-time is a global variable, and may have
undesirable effects in other situations.

Another is to use partial parse:

(setq wisi-partial-parse-threshold 0)

wisi-partial-parse-threshold is buffer-local, so this needs to be in
your ada-mode-hook.

Partial parse is intended for use only in very large files, but it has
some interesting features. I have it enabled in all files, for testing.

Partial parse means the parse triggered by font-lock and indent only
parses the requested part of the file (often just the line being
edited). ada-mode expands that to a reasonable start point; before
'procedure', or after 'end;', etc. The end point is after any terminal
semicolon. This pretty much guarrantees there will be parse errors, so
the fringe marks are suppressed.

One downside of this is that indentation is often wrong, due to the
error correction doing something other than what the full code does.

When partial parse is active, any navigation command still triggers a
full parse; navigation info cannot be reasonably generated with anything
less. So that will then show the fringe marks.

One command that triggers navigation is "ada-indent-statement", bound to
C-c TAB by default. That navigates to the start and end of the statement
point is in, which triggers a full parse. It then reindents that
statement; the partial parse for indent then has a complete statement to
parse, so the indentation is accurate (relative to the statement start).

To indent a larger region with C-c TAB, put point on a keyword, or just
after the terminating semicolon, of an
enclosing block.

So in partial parse mode, I often type C-c TAB to correct the indent
when I think the statement is correct. That then shows fringe marks for
any remaining syntax errors, which is useful. A second C-c TAB is
required to remove the fringe marks after the error is fixed.

A third option to avoid fringe error marks for '-' is to set:

(setq wisi-disable-face t)

This turns off all fontification except keywords; the parser is no
longer triggered by font-lock. Eurocontrol does this, apparently because
they did not like the fontification produced by some earlier ada-mode
(or just don't like it in general).

-- 
-- Stephe



reply via email to

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