emacs-devel
[Top][All Lists]
Advanced

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

smie-next-sexp make last seen keyword available


From: Stephen Leake
Subject: smie-next-sexp make last seen keyword available
Date: Sun, 30 Sep 2012 07:57:58 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (windows-nt)

I'm rewriting the Emacs Ada mode indentation engine. The trigger was the
new Ada 2012 syntax; it was just too daunting a task to try to squeeze
that into the Ada mode 4.01 indentation code, which is totally ad hoc.

Someone pointed me to SMIE; thank you Stefan! It is a very useful tool.
I was worried that Ada would prove too complex for operator precedence
parsing, but so far it is going well.

My current code is at
http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html#ada-mode-5.0
It is still a work in progress.

I'm currently using Emacs 24.2; I could move to trunk if necessary.

I have a request for an additional feature for smie-next-sexp; make the
last seen keyword available.

Consider the following Ada code:

   type Private_Type_2 is abstract tagged limited
      record
         Component_1 : Integer;
         Component_2 : Integer;
         Component_3 : Integer;
      end record;

In order to have "end record" align with "with record", I've arranged
the precedence for "record" to be higher than "is". "abstract" "tagged"
"limited" are all identifiers in the smie grammar; they are optional
keywords in Ada.

Starting from "end", smie-backward-sexp leaves point on "abstract",
and returns "is" as the found token. But I need point on "record", which
is the last smie keyword seen. I can easily navigate back to "record"
using "smie-default-forward-token", but since "smie-backward-sexp" has
already seen "record", it would be cleaner to have it cache the info,
and either return it in its return value, or store it in a smie global
variable.

Any suggestions on whether this is a good idea, or the best way to
implement it?

--
-- Stephe



reply via email to

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