Piotr Trojanek <[email protected]> writes:
> Hi,
>
> with the latest ada-mode 5.1.9 I get a runtime error when indenting
> package aspects.
>
> Test and patch attached.
Thanks!
+ (package_specification
+ ;; package P
The first line of this comment should be a shortcut to the file
containing the test code: test/p.ads. That way, you can use a binding to
`find-file-at-point' (C-F12 for me) to navigate to directly to the test.
I'd prefer a longer name for the test file, or include this test in an
existing package. "SPARK_Mode" is recognized by GNAT GPL 2014 (which is
what I'm testing with), so this can go in an existing package;
ada_mode-nominal.ads. That changes the test of ada-*-statement-keyword.
+ ;; with SPARK_Mode => On
+ ;; indenting 'with'
+ (save-excursion
+ (wisi-backward-token)
+ (+ (current-column) ada-indent-broken)))
There's a bug in the grammar here. At this point in the code, point is
on the token containing the aspect, which is P. But it should be
"package", so the indentation is dependent on the keyword, not the name.
Then you would not need "wisi-backward-token". And it changes
"package_specification" to "package_declaration".
> Note that I do not know if my decision about
> how to indent the package aspect is in line with the style promoted by
> the ada-mode.
As Simon pointed out, aspects with types are aligned with "type", so
these should be aligned with "package". This looks better when there is
a list of aspects:
package Ada_Mode.Nominal
with
SPARK_Mode => On,
foo => bar
is
Full patch attached.
--
-- Stephe
#
# old_revision [0aa94df084fcddb44b8a3ac33716394705545bff]
#
# patch "ada-grammar-wy.el"
# from [132ccd14b913979df6ade3ef693c61f4e1543455]
# to [c756bd783e5efe9ba6705923522d1c9e4838e71d]
#
# patch "ada-grammar.wy"
# from [7e7c7b31aa02a70d9dd6515f96978e5b7d0fe3ec]
# to [063b3cd3c19102111229bf49253fc0ef4a182ff4]
#
# patch "ada-wisi.el"
# from [194d02ac19d86ae94f2a53fcc89e53115ddda8fa]
# to [24958de03eddabad1b2845ede8ef67ce158df84c]
#
# patch "test/ada_mode-nominal.ads"
# from [386f97b6cf4f800b91e293fc244780fc8f8c0308]
# to [af48707e8fd8426bbd048ac4ad2fcbc1519f4780]
#
============================================================
# ada-grammar-wy.el is binary
============================================================
--- ada-grammar.wy 7e7c7b31aa02a70d9dd6515f96978e5b7d0fe3ec
+++ ada-grammar.wy 063b3cd3c19102111229bf49253fc0ef4a182ff4
@@ -1697,7 +1697,7 @@ package_specification
(progn
(wisi-statement-action [1 statement-start 2 name 4 block-start 6 block-middle 8 block-end])
(wisi-containing-action 1 2)
- (wisi-containing-action 2 3)
+ (wisi-containing-action 1 3)
(wisi-containing-action 4 5)
(wisi-containing-action 6 7)
(wisi-motion-action [1 4 6 8])
@@ -1706,7 +1706,7 @@ package_specification
(progn
(wisi-statement-action [1 statement-start 2 name 4 block-start 6 block-end])
(wisi-containing-action 1 2)
- (wisi-containing-action 2 3)
+ (wisi-containing-action 1 3)
(wisi-containing-action 4 5)
(wisi-motion-action [1 4 6])
(wisi-face-action [2 font-lock-function-name-face 7 font-lock-function-name-face]))
============================================================
--- ada-wisi.el 194d02ac19d86ae94f2a53fcc89e53115ddda8fa
+++ ada-wisi.el 24958de03eddabad1b2845ede8ef67ce158df84c
@@ -552,6 +552,9 @@ point must be on CACHE. PREV-TOKEN is th
(t
(cl-ecase (wisi-cache-nonterm containing)
+
+ ;; abstract_subprogram_declaration with subprogram_body
+
(aggregate
;; test/ada_mode-nominal-child.adb
;; return (Parent_Type_1
@@ -571,6 +574,8 @@ point must be on CACHE. PREV-TOKEN is th
;; indenting 'when'; containing is 'entry'
(+ (current-column) ada-indent-broken))
+ ;; expression_function_declaration with subprogram_body
+
(formal_package_declaration
;; test/ada_mode-generic_package.ads
;; with package A_Package_7 is
@@ -579,6 +584,8 @@ point must be on CACHE. PREV-TOKEN is th
(+ (current-column) ada-indent-broken))
((full_type_declaration
+
+ ;; shared code, but out of alphabetical order:
protected_type_declaration
single_protected_declaration
single_task_declaration
@@ -660,6 +667,8 @@ point must be on CACHE. PREV-TOKEN is th
;; indenting keyword following 'generic'
(current-column))
+ ;; null_procedure_declaration with subprogram_body
+
(object_declaration
(cl-ecase (wisi-cache-token containing)
(COLON
@@ -684,6 +693,16 @@ point must be on CACHE. PREV-TOKEN is th
(+ (current-indentation) ada-indent-broken))
))
+ (package_declaration
+ ;; test/ada_mode-nominal.ads
+ ;; package Ada_Mode.Nominal
+ ;; with
+ ;; SPARK_Mode => On
+ ;; is
+ ;; indenting 'with'
+ (save-excursion
+ (current-column)))
+
(private_extension_declaration
(cl-ecase (wisi-cache-token cache)
(WITH
@@ -708,6 +727,8 @@ point must be on CACHE. PREV-TOKEN is th
;; indenting 'with'
(current-indentation))
+ ;; protected_type_declaration with full_type_declaration
+
(qualified_expression
;; test/ada_mode-nominal-child.ads
;; Child_Obj_5 : constant Child_Type_1 :=
@@ -715,6 +736,9 @@ point must be on CACHE. PREV-TOKEN is th
;; (Parent_Element_1 => 1,
(ada-wisi-indent-cache ada-indent-broken containing))
+ ;; single_protected_declaration with full_type_declaration
+ ;; single_task_declaration with full_type_declaration
+
(statement
(cl-case (wisi-cache-token containing)
(label_opt
@@ -730,11 +754,13 @@ point must be on CACHE. PREV-TOKEN is th
(ada-wisi-indent-cache ada-indent-broken cache))
))
- ((abstract_subprogram_declaration
- expression_function_declaration
- subprogram_body
+ ((subprogram_body
subprogram_declaration
subprogram_specification
+
+ ;; shared code, but out of alphabetical order:
+ abstract_subprogram_declaration
+ expression_function_declaration
null_procedure_declaration)
(cl-ecase (wisi-cache-token cache)
(IS
@@ -765,6 +791,8 @@ point must be on CACHE. PREV-TOKEN is th
(current-column))
))
+ ;; subtype_declaration, task_type_declaration with full_type_declaration
+
))))
)))) ;; end statement-other
============================================================
--- test/ada_mode-nominal.ads 386f97b6cf4f800b91e293fc244780fc8f8c0308
+++ test/ada_mode-nominal.ads af48707e8fd8426bbd048ac4ad2fcbc1519f4780
@@ -61,9 +61,14 @@ with Ada_Mode.Function_2;
with Ada_Mode.Function_2;
--EMACSCMD:(progn (ada-goto-end)(looking-back "end Ada_Mode.Nominal"))
--EMACSRESULT:t
---EMACSCMD:(progn (end-of-line 3)(forward-word -3) (ada-next-statement-keyword)(looking-at "private -- Ada_Mode.Nominal"))
+--EMACSCMD:(progn (beginning-of-line 3) (ada-next-statement-keyword)(looking-at "is -- target 0"))
--EMACSRESULT:t
-package Ada_Mode.Nominal is -- target 0
+package Ada_Mode.Nominal
+with
+ Spark_Mode => On
+is -- target 0
+ --EMACSCMD:(progn (beginning-of-line -0) (ada-next-statement-keyword)(looking-at "private -- Ada_Mode.Nominal"))
+ --EMACSRESULT:t
--EMACSCMD:(test-face "pragma" font-lock-keyword-face)
--EMACSCMD:(test-face "Elaborate_Body" font-lock-function-name-face)
_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org