unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Casing of number literals in ada-mode
@ 2010-02-07 22:06 jemarch
  2010-02-08  1:32 ` Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: jemarch @ 2010-02-07 22:06 UTC (permalink / raw)
  To: emacs-devel


Hi.

Appended is a little patch that makes ada-mode to not case number
literals to avoid situations like:

      subtype U32 is range 16#0000_0000#..16#Ffff_Ffff#;

Note the Ffff_Ffff.



2010-02-06  Jose E. Marchesi  <jemarch@gnu.org>

	* progmodes/ada-mode.el (ada-in-numeric-literal-p): New function.
	(ada-adjust-case): Don't adjust case in hexadecimal number
	literals.

=== modified file 'lisp/progmodes/ada-mode.el'
--- lisp/progmodes/ada-mode.el	2010-01-23 12:34:52 +0000
+++ lisp/progmodes/ada-mode.el	2010-02-07 22:02:29 +0000
@@ -1009,6 +1009,10 @@
 	     (parse-partial-sexp
 	      (line-beginning-position) (point)))))
 
+(defsubst ada-in-numeric-literal-p ()
+  "Return t if point is after a prefix of a numeric literal."
+  (looking-back "\\([0-9]+#[0-9a-fA-F_]+\\)"))
+
 (defsubst ada-in-string-or-comment-p (&optional parse-result)
   "Return t if inside a comment or string.
 If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'."
@@ -1606,6 +1610,8 @@
 		 (eq (char-syntax (char-before)) ?w)
 		 ;;  if in a string or a comment
 		 (not (ada-in-string-or-comment-p))
+                 ;;  if in a numeric literal
+                 (not (ada-in-numeric-literal-p))
 		 )
 	    (if (save-excursion
 		  (forward-word -1)




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

* Re: Casing of number literals in ada-mode
  2010-02-07 22:06 Casing of number literals in ada-mode jemarch
@ 2010-02-08  1:32 ` Chong Yidong
  2010-02-08 16:37   ` Stephen Leake
  0 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2010-02-08  1:32 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel, jemarch

Hi Stephen, could you check this patch?  If it's OK, we can commit it.
Thanks.


jemarch@gnu.org writes:

> Appended is a little patch that makes ada-mode to not case number
> literals to avoid situations like:
>
>       subtype U32 is range 16#0000_0000#..16#Ffff_Ffff#;
>
> Note the Ffff_Ffff.
>
> 2010-02-06  Jose E. Marchesi  <jemarch@gnu.org>
>
> 	* progmodes/ada-mode.el (ada-in-numeric-literal-p): New function.
> 	(ada-adjust-case): Don't adjust case in hexadecimal number
> 	literals.
>
> === modified file 'lisp/progmodes/ada-mode.el'
> --- lisp/progmodes/ada-mode.el	2010-01-23 12:34:52 +0000
> +++ lisp/progmodes/ada-mode.el	2010-02-07 22:02:29 +0000
> @@ -1009,6 +1009,10 @@
>  	     (parse-partial-sexp
>  	      (line-beginning-position) (point)))))
>  
> +(defsubst ada-in-numeric-literal-p ()
> +  "Return t if point is after a prefix of a numeric literal."
> +  (looking-back "\\([0-9]+#[0-9a-fA-F_]+\\)"))
> +
>  (defsubst ada-in-string-or-comment-p (&optional parse-result)
>    "Return t if inside a comment or string.
>  If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'."
> @@ -1606,6 +1610,8 @@
>  		 (eq (char-syntax (char-before)) ?w)
>  		 ;;  if in a string or a comment
>  		 (not (ada-in-string-or-comment-p))
> +                 ;;  if in a numeric literal
> +                 (not (ada-in-numeric-literal-p))
>  		 )
>  	    (if (save-excursion
>  		  (forward-word -1)




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

* Re: Casing of number literals in ada-mode
  2010-02-08  1:32 ` Chong Yidong
@ 2010-02-08 16:37   ` Stephen Leake
  2010-02-08 18:30     ` jemarch
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2010-02-08 16:37 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel, jemarch

Chong Yidong <cyd@stupidchicken.com> writes:

> Hi Stephen, could you check this patch?  If it's OK, we can commit it.

I can't reproduce the problem, so I don't see the need for the fix.

Jose; can you file a bug report, with a reproducer?

> 
> Thanks.
>
>
> jemarch@gnu.org writes:
>
>> Appended is a little patch that makes ada-mode to not case number
>> literals to avoid situations like:
>>
>>       subtype U32 is range 16#0000_0000#..16#Ffff_Ffff#;
>>
>> Note the Ffff_Ffff.
>>
>> 2010-02-06  Jose E. Marchesi  <jemarch@gnu.org>
>>
>> 	* progmodes/ada-mode.el (ada-in-numeric-literal-p): New function.
>> 	(ada-adjust-case): Don't adjust case in hexadecimal number
>> 	literals.
>>
>> === modified file 'lisp/progmodes/ada-mode.el'
>> --- lisp/progmodes/ada-mode.el	2010-01-23 12:34:52 +0000
>> +++ lisp/progmodes/ada-mode.el	2010-02-07 22:02:29 +0000
>> @@ -1009,6 +1009,10 @@
>>  	     (parse-partial-sexp
>>  	      (line-beginning-position) (point)))))
>>  
>> +(defsubst ada-in-numeric-literal-p ()
>> +  "Return t if point is after a prefix of a numeric literal."
>> +  (looking-back "\\([0-9]+#[0-9a-fA-F_]+\\)"))
>> +
>>  (defsubst ada-in-string-or-comment-p (&optional parse-result)
>>    "Return t if inside a comment or string.
>>  If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'."
>> @@ -1606,6 +1610,8 @@
>>  		 (eq (char-syntax (char-before)) ?w)
>>  		 ;;  if in a string or a comment
>>  		 (not (ada-in-string-or-comment-p))
>> +                 ;;  if in a numeric literal
>> +                 (not (ada-in-numeric-literal-p))
>>  		 )
>>  	    (if (save-excursion
>>  		  (forward-word -1)

-- 
-- Stephe




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

* Re: Casing of number literals in ada-mode
  2010-02-08 16:37   ` Stephen Leake
@ 2010-02-08 18:30     ` jemarch
  2010-02-08 22:13       ` Stephen Leake
  0 siblings, 1 reply; 7+ messages in thread
From: jemarch @ 2010-02-08 18:30 UTC (permalink / raw)
  To: Stephen Leake; +Cc: Chong Yidong, emacs-devel


   > Hi Stephen, could you check this patch?  If it's OK, we can commit it.

   I can't reproduce the problem, so I don't see the need for the fix.

   Jose; can you file a bug report, with a reproducer?

You can reproduce the bug in this way:

1) emacs -Q
2) M-xada-mode
3) Type: 16#ffff_ffff#;

You will get the number literal cased to '16#Ffff_Ffff#;'.
ada-adjust-case-region and ada-adjust-case-buffer can also be used to
reproduce the problem.





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

* Re: Casing of number literals in ada-mode
  2010-02-08 18:30     ` jemarch
@ 2010-02-08 22:13       ` Stephen Leake
  2010-02-08 22:28         ` jemarch
  2010-02-08 23:27         ` Chong Yidong
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Leake @ 2010-02-08 22:13 UTC (permalink / raw)
  To: jemarch; +Cc: Chong Yidong, emacs-devel

jemarch@gnu.org writes:

>    > Hi Stephen, could you check this patch?  If it's OK, we can commit it.
>
>    I can't reproduce the problem, so I don't see the need for the fix.
>
>    Jose; can you file a bug report, with a reproducer?
>
> You can reproduce the bug in this way:
>
> 1) emacs -Q
> 2) M-xada-mode
> 3) Type: 16#ffff_ffff#;

Ok, now I see it. I never type hex with all lowercase, so I've never
encountered this.

Yes, this is a good fix. I've added this to my test suite.

Thanks for reporting and fixing this.

-- 
-- Stephe




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

* Re: Casing of number literals in ada-mode
  2010-02-08 22:13       ` Stephen Leake
@ 2010-02-08 22:28         ` jemarch
  2010-02-08 23:27         ` Chong Yidong
  1 sibling, 0 replies; 7+ messages in thread
From: jemarch @ 2010-02-08 22:28 UTC (permalink / raw)
  To: Stephen Leake; +Cc: Chong Yidong, emacs-devel


   Ok, now I see it. I never type hex with all lowercase, so I've never
   encountered this.

   Yes, this is a good fix. I've added this to my test suite.

   Thanks for reporting and fixing this.

Thanks to you for maintaining this fantastic mode!! :)

-- 
Jose E. Marchesi  <jemarch@gnu.org>
                  http://www.jemarch.net
GNU Project       http://www.gnu.org




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

* Re: Casing of number literals in ada-mode
  2010-02-08 22:13       ` Stephen Leake
  2010-02-08 22:28         ` jemarch
@ 2010-02-08 23:27         ` Chong Yidong
  1 sibling, 0 replies; 7+ messages in thread
From: Chong Yidong @ 2010-02-08 23:27 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel, jemarch

Stephen Leake <stephen_leake@member.fsf.org> writes:

> jemarch@gnu.org writes:
>
>>    > Hi Stephen, could you check this patch?  If it's OK, we can commit it.
>>
>>    I can't reproduce the problem, so I don't see the need for the fix.
>>
>>    Jose; can you file a bug report, with a reproducer?
>>
>> You can reproduce the bug in this way:
>>
>> 1) emacs -Q
>> 2) M-xada-mode
>> 3) Type: 16#ffff_ffff#;
>
> Ok, now I see it. I never type hex with all lowercase, so I've never
> encountered this.
>
> Yes, this is a good fix. I've added this to my test suite.
>
> Thanks for reporting and fixing this.

OK, I've checked it in.




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

end of thread, other threads:[~2010-02-08 23:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-07 22:06 Casing of number literals in ada-mode jemarch
2010-02-08  1:32 ` Chong Yidong
2010-02-08 16:37   ` Stephen Leake
2010-02-08 18:30     ` jemarch
2010-02-08 22:13       ` Stephen Leake
2010-02-08 22:28         ` jemarch
2010-02-08 23:27         ` Chong Yidong

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).