comp.lang.ada
 help / color / mirror / Atom feed
* ada-mode failing at formatting still
@ 2018-05-20 18:51 Lucretia
  2018-05-20 18:59 ` Dan'l Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Lucretia @ 2018-05-20 18:51 UTC (permalink / raw)


Hi,

I thought I'd reinstall emacs and try ada-mode again, but it's failing to format properly.

https://bpaste.net/show/5cb547ca16cc was formatted using ada-mode, for some reason it won't indent the Label properly.

Thanks,
Luke.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* ada-mode failing at formatting still
  2018-05-20 18:51 ada-mode failing at formatting still Lucretia
@ 2018-05-20 18:59 ` Dan'l Miller
  2018-05-20 19:03   ` Lucretia
                     ` (2 more replies)
  2018-05-20 20:19 ` Simon Wright
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 22+ messages in thread
From: Dan'l Miller @ 2018-05-20 18:59 UTC (permalink / raw)


All the language modes in emacs rely on regular expressions instead of a grammar.  Hence, mistaken false-positives & false-negatives are par for the course in Emacs’s language modes. 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 18:59 ` Dan'l Miller
@ 2018-05-20 19:03   ` Lucretia
  2018-05-20 19:18     ` Dan'l Miller
  2018-05-20 23:55   ` Shark8
  2018-05-21  0:19   ` Paul Rubin
  2 siblings, 1 reply; 22+ messages in thread
From: Lucretia @ 2018-05-20 19:03 UTC (permalink / raw)


On Sunday, 20 May 2018 19:59:44 UTC+1, Dan'l Miller  wrote:
> All the language modes in emacs rely on regular expressions instead of a grammar.  Hence, mistaken false-positives & false-negatives are par for the course in Emacs’s language modes.

Not for ada-mode, it uses WISI, which I've just found out is LALR.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 19:03   ` Lucretia
@ 2018-05-20 19:18     ` Dan'l Miller
  0 siblings, 0 replies; 22+ messages in thread
From: Dan'l Miller @ 2018-05-20 19:18 UTC (permalink / raw)


LALR in GNU Emacs language modes is awesome welcome news (to me).  For decades, Emacs’s regular-expression-based highlighting & formatting has been an eyesore embarrassment.  Finally, Emacs has a hope of being as good as Visual Studio in this regard.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 18:51 ada-mode failing at formatting still Lucretia
  2018-05-20 18:59 ` Dan'l Miller
@ 2018-05-20 20:19 ` Simon Wright
  2018-05-20 20:42   ` Lucretia
  2018-05-20 20:19 ` Lucretia
  2018-05-21 16:35 ` Lucretia
  3 siblings, 1 reply; 22+ messages in thread
From: Simon Wright @ 2018-05-20 20:19 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

> I thought I'd reinstall emacs and try ada-mode again, but it's failing
> to format properly.
>
> https://bpaste.net/show/5cb547ca16cc was formatted using ada-mode, for
> some reason it won't indent the Label properly.

Because ada-indent-label is defaulted to -3. If you customise it to 0,
-gnaty won't complain any more.

begin
   Ada.Text_IO.Put_Line ("hello");

   Label :
   declare
   begin
      <<Another_Label>>
      null;
   end Label;
end Test;

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 18:51 ada-mode failing at formatting still Lucretia
  2018-05-20 18:59 ` Dan'l Miller
  2018-05-20 20:19 ` Simon Wright
@ 2018-05-20 20:19 ` Lucretia
  2018-05-21 16:35 ` Lucretia
  3 siblings, 0 replies; 22+ messages in thread
From: Lucretia @ 2018-05-20 20:19 UTC (permalink / raw)


Oh it's me, sticking this in my hook fixed it.

  (setq ada-label-indent 0)

But, if I want:

   Some_Label : declare

It'll dump begin in the first colum:

   Some_Label : declare
begin

which is annoying.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 20:19 ` Simon Wright
@ 2018-05-20 20:42   ` Lucretia
  2018-05-20 21:07     ` Dan'l Miller
                       ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Lucretia @ 2018-05-20 20:42 UTC (permalink / raw)


On Sunday, 20 May 2018 21:19:21 UTC+1, Simon Wright  wrote:
> Lucretia <> writes:
> 
> > I thought I'd reinstall emacs and try ada-mode again, but it's failing
> > to format properly.
> >
> > https://bpaste.net/show/5cb547ca16cc was formatted using ada-mode, for
> > some reason it won't indent the Label properly.
> 
> Because ada-indent-label is defaulted to -3. If you customise it to 0,
> -gnaty won't complain any more.


Yeah, just found it thanks.

Do you know how to stop it auto casing keywords?

I have this in my .emacs file:

(defun my-ada-mode-hook ()
  (setq ada-case-keyword lower-case)
  (setq ada-label-indent 0))

But neither are working.

I don't know lisp, I will learn, but I just want this working.

Thanks,
Luke

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 20:42   ` Lucretia
@ 2018-05-20 21:07     ` Dan'l Miller
  2018-05-21  6:49       ` Simon Wright
  2018-05-21  7:11     ` Simon Wright
  2018-05-21  7:18     ` Simon Wright
  2 siblings, 1 reply; 22+ messages in thread
From: Dan'l Miller @ 2018-05-20 21:07 UTC (permalink / raw)


In addition to here on c.l.a, this whole thread’s various questions could be at least one question on StackOverflow to attract people to this new breakthrough feature of ada-mode in Emacs.  

(Finally for the first time in quite a long time, Ada has something truly new & awesome first for all the other languages to be quite envious of.)


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 18:59 ` Dan'l Miller
  2018-05-20 19:03   ` Lucretia
@ 2018-05-20 23:55   ` Shark8
  2018-05-21  0:19   ` Paul Rubin
  2 siblings, 0 replies; 22+ messages in thread
From: Shark8 @ 2018-05-20 23:55 UTC (permalink / raw)


On Sunday, May 20, 2018 at 12:59:44 PM UTC-6, Dan'l Miller wrote:
> All the language modes in emacs rely on regular expressions

Ouch!
Always a negative in my book. (I honestly would recommend *against* RegEx at any portion of your compiler, unless the language is completely regular; none of this "I use it to recognize [integer/string/whatever] tokens" crap.)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 18:59 ` Dan'l Miller
  2018-05-20 19:03   ` Lucretia
  2018-05-20 23:55   ` Shark8
@ 2018-05-21  0:19   ` Paul Rubin
  2018-05-21  3:28     ` Dan'l Miller
  2 siblings, 1 reply; 22+ messages in thread
From: Paul Rubin @ 2018-05-21  0:19 UTC (permalink / raw)


"Dan'l Miller" <optikos@verizon.net> writes:
> All the language modes in emacs rely on regular expressions instead of
> a grammar.

Not since many years ago.  Language modes these days tend to use
Semantic.  See:

https://www.gnu.org/software/emacs/manual/html_node/semantic/Introduction.html

which says:

   Semantic provides a new infrastructure to analyze source code using
   parsers instead of regular expressions. It contains two built-in
   parser generators (an LL generator named Bovine and an LALR generator
   named Wisent, both written in Emacs Lisp), and parsers for several
   common programming languages. It can also make use of external
   parsers—programs such as GNU Global and GNU IDUtils.

   Semantic provides a uniform, language-independent API for accessing
   the parser output. This output can be used by other Emacs Lisp
   programs to implement “syntax-aware” behavior. Semantic itself
   includes several such utilities, including user-level Emacs commands
   for navigating, searching, and completing source code.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21  0:19   ` Paul Rubin
@ 2018-05-21  3:28     ` Dan'l Miller
  2018-05-21  3:37       ` Paul Rubin
  0 siblings, 1 reply; 22+ messages in thread
From: Dan'l Miller @ 2018-05-21  3:28 UTC (permalink / raw)


On Sunday, May 20, 2018 at 7:19:22 PM UTC-5, Paul Rubin wrote:
> "Dan'l Miller" writes:
> > All the language modes in emacs rely on regular expressions instead of
> > a grammar.

I must admit that I am not subscribed to every nook & cranny of every Emacs mailing-list on the planet, but I thought the state of the art was:

> Not since many years ago.

2013? was when this started getting any serious traction, correct?

>  Language modes these days tend to

be able to optionally

> use Semantic

instead of their default regular expressions for syntax highlighting, dating back to Lucid's XEmacs fork.

from the Semantic manual, you omitted the best part:
“This chapter gives an overview of Semantic and its ••goals••.

[••emphasis•• added, implying that batteries aren't always included, and that your mileage might vary]

“Ordinarily,

[i.e., in a fresh-from-FSF GNU Emacs download]

“Emacs uses ••regular expressions•• (and syntax tables) to analyze source code for purposes such as syntax highlighting. This approach, though simple and efficient, has its limitations: roughly speaking, it only “guesses” the meaning of each piece of source code in the context of the programming language, instead of rigorously “understanding” it.”

[which, btw, sure seems to concur with what I commented above]

>    Semantic provides a new infrastructure

that is available to developers of language modes

>    to analyze source code using
>    parsers instead of regular expressions. It contains two built-in
>    parser generators (an LL generator named Bovine and an LALR generator
>    named Wisent, both written in Emacs Lisp), and parsers for several
>    common programming languages. It can also make use of external
>    parsers—programs such as GNU Global and GNU IDUtils.
> 
>    Semantic provides a uniform, language-independent API for accessing
>    the parser output. This output can be used by other Emacs Lisp
>    programs to implement “syntax-aware” behavior. Semantic itself
>    includes several such utilities, including user-level Emacs commands
>    for navigating, searching, and completing source code.

that you as an Emacs user must at least turn on overtly AIUI, if not install, compile, and configure so that various stars align in Emacs's sky:

https://emacs.StackExchange.com/questions/20409/turn-on-semantic-mode-for-c-c

Perhaps it changed in the recent year or so since perhaps 2016, but I thought the CEDET add-on was required to turn on Semantic for various language modes (or at least CEDET was the most-expedient, least-roll-your-own way to do it).

http://cedet.SourceForge.net/semantic.shtml

Just when I am practicing my not-wall-of-text/short-juicy-factoid skills for Luke's satisfaction, someone else demands a wall of text.  Sheesh.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21  3:28     ` Dan'l Miller
@ 2018-05-21  3:37       ` Paul Rubin
  0 siblings, 0 replies; 22+ messages in thread
From: Paul Rubin @ 2018-05-21  3:37 UTC (permalink / raw)


"Dan'l Miller" <optikos@verizon.net> writes:
> Just when I am practicing my not-wall-of-text/short-juicy-factoid
> skills for Luke's satisfaction, someone else demands a wall of text.

It seems to me that C++ and Haskell modes (the main modes I use) use
Semantic or some other fancy parser in recent Emacs versions.  I noticed
the parsing get smarter several years back (maybe I shouldn't have said
"many").  I'm not sure how to test for this though.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 21:07     ` Dan'l Miller
@ 2018-05-21  6:49       ` Simon Wright
  0 siblings, 0 replies; 22+ messages in thread
From: Simon Wright @ 2018-05-21  6:49 UTC (permalink / raw)


"Dan'l Miller" <optikos@verizon.net> writes:

> In addition to here on c.l.a, this whole thread’s various questions
> could be at least one question on StackOverflow to attract people to
> this new breakthrough feature of ada-mode in Emacs.
>
> (Finally for the first time in quite a long time, Ada has something
> truly new & awesome first for all the other languages to be quite
> envious of.)

Not that new! Stephe Leake started looking for a better wy of indenting
Ada in 2012, using smie, and started thinking about wisi in early 2013.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 20:42   ` Lucretia
  2018-05-20 21:07     ` Dan'l Miller
@ 2018-05-21  7:11     ` Simon Wright
  2018-05-21  8:57       ` Lucretia
  2018-05-21  7:18     ` Simon Wright
  2 siblings, 1 reply; 22+ messages in thread
From: Simon Wright @ 2018-05-21  7:11 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

> Do you know how to stop it auto casing keywords?
>
> I have this in my .emacs file:
>
> (defun my-ada-mode-hook ()
>   (setq ada-case-keyword lower-case)
>   (setq ada-label-indent 0))
>
> But neither are working.

Which Emacs & ada-mode versions are you using? I have Emacs 25.3.1,
ada-mode 5.3.1 (via elpa).

Best to use customize.

With point in an Ada buffer, (menu) Ada>Customize.

The casing defaults are, from ada-mode.el,

ada-auto-case t (automatically change case of preceding word while
typing)

ada-case-keyword 'lower-case

ada-case-identifier 'mixed-case (actually Title_Case)

ada-case-strict t (allow CamelCase; if nil, -> Camelcase)

------------------------------------------------------------------------

Down at the bottom of the Ada group customization page, there are
links to the Build and Indentation customization groups.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 20:42   ` Lucretia
  2018-05-20 21:07     ` Dan'l Miller
  2018-05-21  7:11     ` Simon Wright
@ 2018-05-21  7:18     ` Simon Wright
  2018-05-21  8:59       ` Lucretia
  2 siblings, 1 reply; 22+ messages in thread
From: Simon Wright @ 2018-05-21  7:18 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

> I have this in my .emacs file:
>
> (defun my-ada-mode-hook ()
>   (setq ada-case-keyword lower-case)
>   (setq ada-label-indent 0))

Better to set up via Customize.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21  7:11     ` Simon Wright
@ 2018-05-21  8:57       ` Lucretia
  2018-05-21 12:31         ` Simon Wright
  0 siblings, 1 reply; 22+ messages in thread
From: Lucretia @ 2018-05-21  8:57 UTC (permalink / raw)


On Monday, 21 May 2018 08:11:45 UTC+1, Simon Wright  wrote:
> Lucretia <> writes:
> 
> > Do you know how to stop it auto casing keywords?
> >
> > I have this in my .emacs file:
> >
> > (defun my-ada-mode-hook ()
> >   (setq ada-case-keyword lower-case)
> >   (setq ada-label-indent 0))
> >
> > But neither are working.
> 
> Which Emacs & ada-mode versions are you using? I have Emacs 25.3.1,
> ada-mode 5.3.1 (via elpa).
> 
> Best to use customize.

I did, neither are working. I have emacs 26.1 and ada-mode 5.3.1

> 
> With point in an Ada buffer, (menu) Ada>Customize.

Also, that doesn't show the lisp when I select it in ada-mode.
 
> The casing defaults are, from ada-mode.el,
> 
> ada-auto-case t (automatically change case of preceding word while
> typing)
> 
> ada-case-keyword 'lower-case

Not working.
 
> ada-case-identifier 'mixed-case (actually Title_Case)
> 
> ada-case-strict t (allow CamelCase; if nil, -> Camelcase)
> 
> ------------------------------------------------------------------------
> 
> Down at the bottom of the Ada group customization page, there are
> links to the Build and Indentation customization groups.

I know.

I'm beginning to think this might be a 26.1 and 5.3.1 problem.

Luke.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21  7:18     ` Simon Wright
@ 2018-05-21  8:59       ` Lucretia
  0 siblings, 0 replies; 22+ messages in thread
From: Lucretia @ 2018-05-21  8:59 UTC (permalink / raw)


On Monday, 21 May 2018 08:18:24 UTC+1, Simon Wright  wrote:
> Lucretia <> writes:
> 
> > I have this in my .emacs file:
> >
> > (defun my-ada-mode-hook ()
> >   (setq ada-case-keyword lower-case)
> >   (setq ada-label-indent 0))
> 
> Better to set up via Customize.

The full .emacs:

https://bpaste.net/show/572a0c7c8241

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21  8:57       ` Lucretia
@ 2018-05-21 12:31         ` Simon Wright
  2018-05-21 12:51           ` Lucretia
  2018-05-21 13:35           ` Simon Wright
  0 siblings, 2 replies; 22+ messages in thread
From: Simon Wright @ 2018-05-21 12:31 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

> I'm beginning to think this might be a 26.1 and 5.3.1 problem.

I suppose it might be.

I just tried to build emacs from git & got compilation errors, so I
won't be pursuing that any further. Sorry.

Of course the latest official release is 25.3 ...


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21 12:31         ` Simon Wright
@ 2018-05-21 12:51           ` Lucretia
  2018-05-21 13:35           ` Simon Wright
  1 sibling, 0 replies; 22+ messages in thread
From: Lucretia @ 2018-05-21 12:51 UTC (permalink / raw)


On Monday, 21 May 2018 13:31:32 UTC+1, Simon Wright  wrote:
> Lucretia <> writes:
> 
> > I'm beginning to think this might be a 26.1 and 5.3.1 problem.
> 
> I suppose it might be.
> 
> I just tried to build emacs from git & got compilation errors, so I
> won't be pursuing that any further. Sorry.
> 
> Of course the latest official release is 25.3 ...

I eselected 25.3 and then rebuilt my .emacs file and it seems to be working.

All I need to do now is get auto-complete to allow me to see the menu for packages, but I think that might be a ctags issue.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21 12:31         ` Simon Wright
  2018-05-21 12:51           ` Lucretia
@ 2018-05-21 13:35           ` Simon Wright
  1 sibling, 0 replies; 22+ messages in thread
From: Simon Wright @ 2018-05-21 13:35 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> Lucretia <laguest9000@googlemail.com> writes:
>
>> I'm beginning to think this might be a 26.1 and 5.3.1 problem.
>
> I suppose it might be.
>
> I just tried to build emacs from git & got compilation errors, so I
> won't be pursuing that any further. Sorry.

My mistake was building using Apple clang.

With gcc (and --without-makeinfo --without-ns --with-jpeg=no
--with-gif=no --with-tiff=no --with-gnutls=no !!!) I see what you
saw. This will need looking into.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-20 18:51 ada-mode failing at formatting still Lucretia
                   ` (2 preceding siblings ...)
  2018-05-20 20:19 ` Lucretia
@ 2018-05-21 16:35 ` Lucretia
  2018-05-21 16:37   ` Dan'l Miller
  3 siblings, 1 reply; 22+ messages in thread
From: Lucretia @ 2018-05-21 16:35 UTC (permalink / raw)


I thought I'd dump my .emacs into a github repo so that anyone can grab it.

https://github.com/Lucretia/emacs

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ada-mode failing at formatting still
  2018-05-21 16:35 ` Lucretia
@ 2018-05-21 16:37   ` Dan'l Miller
  0 siblings, 0 replies; 22+ messages in thread
From: Dan'l Miller @ 2018-05-21 16:37 UTC (permalink / raw)


On Monday, May 21, 2018 at 11:35:02 AM UTC-5, Lucretia wrote:
> I thought I'd dump my .emacs into a github repo so that anyone can grab it.
> 
> https://github.com/Lucretia/emacs

Thank you!


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-05-21 16:37 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-20 18:51 ada-mode failing at formatting still Lucretia
2018-05-20 18:59 ` Dan'l Miller
2018-05-20 19:03   ` Lucretia
2018-05-20 19:18     ` Dan'l Miller
2018-05-20 23:55   ` Shark8
2018-05-21  0:19   ` Paul Rubin
2018-05-21  3:28     ` Dan'l Miller
2018-05-21  3:37       ` Paul Rubin
2018-05-20 20:19 ` Simon Wright
2018-05-20 20:42   ` Lucretia
2018-05-20 21:07     ` Dan'l Miller
2018-05-21  6:49       ` Simon Wright
2018-05-21  7:11     ` Simon Wright
2018-05-21  8:57       ` Lucretia
2018-05-21 12:31         ` Simon Wright
2018-05-21 12:51           ` Lucretia
2018-05-21 13:35           ` Simon Wright
2018-05-21  7:18     ` Simon Wright
2018-05-21  8:59       ` Lucretia
2018-05-20 20:19 ` Lucretia
2018-05-21 16:35 ` Lucretia
2018-05-21 16:37   ` Dan'l Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox