unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
@ 2009-01-15  7:59 Erik
  2009-01-15  9:12 ` Juanma Barranquero
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Erik @ 2009-01-15  7:59 UTC (permalink / raw)
  To: bug-gnu-emacs

In Ada-mode, type the reserved word "raise" (and some whitespace after).
Then type the name of an identifier. It may or may not get highlighted
in light blue colour. It seems to depend on which characters that are
part of the identifier. when typing "H", the highlighting works. But if
the letter 'Ö' is added, the word is no longer highlighted. This may be
a character set issue. It seems like the highlighter thinks that the
file is in Ada83. I never used Ada83 but I think it was ASCII-only. But
my files are in Ada95, which is Latin1, or Ada2005, which supports even
more characters. So how should I tell the highlighter that the file is
Ada95 or Ada2005 (and not Ada83)? I think that emacs should assume that
the file is not Ada83 if a non-ASCII character is used in an identifier.







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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-15  7:59 bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode Erik
@ 2009-01-15  9:12 ` Juanma Barranquero
  2009-01-15 13:40   ` Erik
  2020-04-16 18:42 ` Stephen Leake
  2020-07-02 18:11 ` bug#1913: closed by ada-mode version 7.1 Stephen Leake
  2 siblings, 1 reply; 10+ messages in thread
From: Juanma Barranquero @ 2009-01-15  9:12 UTC (permalink / raw)
  To: Erik; +Cc: 1913

On Thu, Jan 15, 2009 at 08:59, Erik <esigra@gmail.com> wrote:

> So how should I tell the highlighter that the file is
> Ada95 or Ada2005 (and not Ada83)? I think that emacs should assume that
> the file is not Ada83 if a non-ASCII character is used in an identifier.

It's not that the Ada mode is assuming any specific version. There's a
variable `ada-language-version', but it just affects which keywords
are recognized as such. The problem is simply that some of the regexps
were written in the ASCII-only era and have not been updated.

Try the following patch, which should fix this particular case. I'll
bring the issue to the Ada mode maintainer for a more permanent fix.

    Juanma


Index: lisp/progmodes/ada-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/ada-mode.el,v
retrieving revision 1.101
diff -u -2 -r1.101 ada-mode.el
--- lisp/progmodes/ada-mode.el	9 Jan 2009 04:15:56 -0000	1.101
+++ lisp/progmodes/ada-mode.el	15 Jan 2009 09:05:02 -0000
@@ -5224,5 +5224,5 @@
      ;; correctly highlight a with_clause that spans multiple lines.
      (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)"
-		   "[ \t]+\\([a-zA-Z0-9_., \t]+\\)\\W")
+		   "[ \t]+\\([[:alnum:]_., \t]+\\)\\W")
 	   '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))






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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-15  9:12 ` Juanma Barranquero
@ 2009-01-15 13:40   ` Erik
  2009-01-15 14:42     ` Juanma Barranquero
  0 siblings, 1 reply; 10+ messages in thread
From: Erik @ 2009-01-15 13:40 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 1913

Juanma Barranquero skrev:
> On Thu, Jan 15, 2009 at 08:59, Erik <esigra@gmail.com> wrote:
>   
>> So how should I tell the highlighter that the file is
>> Ada95 or Ada2005 (and not Ada83)? I think that emacs should assume that
>> the file is not Ada83 if a non-ASCII character is used in an identifier.
>>     
>
> It's not that the Ada mode is assuming any specific version. There's a
> variable `ada-language-version', but it just affects which keywords
> are recognized as such. The problem is simply that some of the regexps
> were written in the ASCII-only era and have not been updated.
>
> Try the following patch, which should fix this particular case. I'll
> bring the issue to the Ada mode maintainer for a more permanent fix.
>
>     Juanma
>
>
> Index: lisp/progmodes/ada-mode.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/progmodes/ada-mode.el,v
> retrieving revision 1.101
> diff -u -2 -r1.101 ada-mode.el
> --- lisp/progmodes/ada-mode.el	9 Jan 2009 04:15:56 -0000	1.101
> +++ lisp/progmodes/ada-mode.el	15 Jan 2009 09:05:02 -0000
> @@ -5224,5 +5224,5 @@
>       ;; correctly highlight a with_clause that spans multiple lines.
>       (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)"
> -		   "[ \t]+\\([a-zA-Z0-9_., \t]+\\)\\W")
> +		   "[ \t]+\\([[:alnum:]_., \t]+\\)\\W")
>  	   '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))
>   

The patch is an improvement, but it highlights some illegal identifiers.
The correct regexp for an Ada identifier is "[[:alpha:]](_?[^\W_])*".
See this example (in bash):
for i in hög _hög h_ög h__ög h_ö_g hög_ _ hau_og do
    echo $i | egrep "^[[:alpha:]](_?[^\W_])*$"
done


It only matches the allowed identifiers:
hög
h_ög
h_ö_g
hau_og

(no leading, consecutive or trailing '_')

There seems to be a lot of places with a-z in ada-mode.el.






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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-15 13:40   ` Erik
@ 2009-01-15 14:42     ` Juanma Barranquero
  2009-01-15 23:03       ` Erik
  0 siblings, 1 reply; 10+ messages in thread
From: Juanma Barranquero @ 2009-01-15 14:42 UTC (permalink / raw)
  To: Erik; +Cc: 1913

On Thu, Jan 15, 2009 at 14:40, Erik <esigra@gmail.com> wrote:

> The patch is an improvement, but it highlights some illegal identifiers.

That shouldn't be a problem. You don't use font-locking to determine
whether the identifier follows Ada rules, do you? :-)

> (no leading, consecutive or trailing '_')

Yes, I know the spec. But I don't think the problem of false positives
is worth making the regexp slower.

> There seems to be a lot of places with a-z in ada-mode.el.

Yes. I suppose Stephen will welcome patches, assuming they are correct.

Are you aware of the Emacs ada-mode hompage

  http://www.stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html

and list

  http://stephe-leake.org/mailman/listinfo/emacs-ada-mode_stephe-leake.org

?

    Juanma






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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-15 14:42     ` Juanma Barranquero
@ 2009-01-15 23:03       ` Erik
  2009-01-15 23:10         ` Juanma Barranquero
  2009-01-16  2:16         ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Erik @ 2009-01-15 23:03 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 1913

Juanma Barranquero skrev:
> On Thu, Jan 15, 2009 at 14:40, Erik <esigra@gmail.com> wrote:
>
>   
>> The patch is an improvement, but it highlights some illegal identifiers.
>>     
>
> That shouldn't be a problem. You don't use font-locking to determine
> whether the identifier follows Ada rules, do you? :-)
>   

Actually I do notice the highlighting and take advantage of it as an
early error detector. If it makes me notice an error immediately, before
I move on to another part of the code or try to compile things, it is
useful. If a word is not highlighted as expected when I have typed it, I
automatically stop to see what I did wrong.


>> (no leading, consecutive or trailing '_')
>>     
>
> Yes, I know the spec. But I don't think the problem of false positives
> is worth making the regexp slower.
>   

Did you have a performance problem with that regexp? I do not really
believe that there is a reason to worry about it without some
measurements. I have a 1.6 GHz CPU and want to take advantage of it. I
think it should be able to recognize Ada identifiers as a type them.

The regexp guru that I once talked with suggested this:
[[:alpha:]](?:_?[^\W_])*

The (?:) is equivalent to () but faster since it is a so-called
non-capturing group, which should always be used when capturing is not
needed. Maybe that helps?


>> There seems to be a lot of places with a-z in ada-mode.el.
>>     
>
> Yes. I suppose Stephen will welcome patches, assuming they are correct.
>
> Are you aware of the Emacs ada-mode hompage
>
>   http://www.stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html
>
> and list
>
>   http://stephe-leake.org/mailman/listinfo/emacs-ada-mode_stephe-leake.org
>
> ?
>   

No, I just subscribed now, thanks. If I make any changes I will send it
there.






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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-15 23:03       ` Erik
@ 2009-01-15 23:10         ` Juanma Barranquero
  2009-01-16  2:16         ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Juanma Barranquero @ 2009-01-15 23:10 UTC (permalink / raw)
  To: Erik; +Cc: 1913

On Fri, Jan 16, 2009 at 00:03, Erik <esigra@gmail.com> wrote:

> Actually I do notice the highlighting and take advantage of it as an
> early error detector. If it makes me notice an error immediately, before
> I move on to another part of the code or try to compile things, it is
> useful. If a word is not highlighted as expected when I have typed it, I
> automatically stop to see what I did wrong.

But we're not talking of something that is highlighted "when you move
to another part of the code"; more like "when you finish the next
token in the line".

> Did you have a performance problem with that regexp? I do not really
> believe that there is a reason to worry about it without some
> measurements. I have a 1.6 GHz CPU and want to take advantage of it. I
> think it should be able to recognize Ada identifiers as a type them.

I don't have a performance problem, but font-locking isn't the fastest
of Emacs features. You have a 1,6 GHz CPU; mine is fast, too. But
Emacs is used in all kinds of computers. That said, if you write a
patch to make the font-locking more correct without sacrificing
performance, I'm sure it'll be very welcome.

> The (?:) is equivalent to () but faster since it is a so-called
> non-capturing group, which should always be used when capturing is not
> needed. Maybe that helps?

Not really. Font-lock patterns have capturing groups for a reason
(that's what the 1, 2 in the next line refer to).

    Juanma






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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-15 23:03       ` Erik
  2009-01-15 23:10         ` Juanma Barranquero
@ 2009-01-16  2:16         ` Stefan Monnier
  2009-01-16  2:22           ` Juanma Barranquero
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2009-01-16  2:16 UTC (permalink / raw)
  To: Erik; +Cc: 1913, Juanma Barranquero

> Did you have a performance problem with that regexp? I do not really
> believe that there is a reason to worry about it without some
> measurements. I have a 1.6 GHz CPU and want to take advantage of it. I
> think it should be able to recognize Ada identifiers as a type them.

Agreed: the right regexp doesn't seem to be significantly more complex.


        Stefan






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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-16  2:16         ` Stefan Monnier
@ 2009-01-16  2:22           ` Juanma Barranquero
  0 siblings, 0 replies; 10+ messages in thread
From: Juanma Barranquero @ 2009-01-16  2:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Erik, 1913

On Fri, Jan 16, 2009 at 03:16, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Agreed: the right regexp doesn't seem to be significantly more complex.

Oh, I'm not opposing to it, just leaving the issue in the hands of the
Emacs ada-mode maintainer, Stephen Leake.

    Juanma






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

* bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode
  2009-01-15  7:59 bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode Erik
  2009-01-15  9:12 ` Juanma Barranquero
@ 2020-04-16 18:42 ` Stephen Leake
  2020-07-02 18:11 ` bug#1913: closed by ada-mode version 7.1 Stephen Leake
  2 siblings, 0 replies; 10+ messages in thread
From: Stephen Leake @ 2020-04-16 18:42 UTC (permalink / raw)
  To: 1913

Will be fixed in next ada-mode release; non-ASCII regular expressions
have been fixed.
-- 
-- Stephe





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

* bug#1913: closed by ada-mode version 7.1
  2009-01-15  7:59 bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode Erik
  2009-01-15  9:12 ` Juanma Barranquero
  2020-04-16 18:42 ` Stephen Leake
@ 2020-07-02 18:11 ` Stephen Leake
  2 siblings, 0 replies; 10+ messages in thread
From: Stephen Leake @ 2020-07-02 18:11 UTC (permalink / raw)
  To: 1913-close


-- 
-- Stephe





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

end of thread, other threads:[~2020-07-02 18:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-15  7:59 bug#1913: Identifier after reserved word "raise" is not always highlighted in Ada-mode Erik
2009-01-15  9:12 ` Juanma Barranquero
2009-01-15 13:40   ` Erik
2009-01-15 14:42     ` Juanma Barranquero
2009-01-15 23:03       ` Erik
2009-01-15 23:10         ` Juanma Barranquero
2009-01-16  2:16         ` Stefan Monnier
2009-01-16  2:22           ` Juanma Barranquero
2020-04-16 18:42 ` Stephen Leake
2020-07-02 18:11 ` bug#1913: closed by ada-mode version 7.1 Stephen Leake

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).