After installing the patch into wisent-csharp.el, you would need to
rebuild semantic, and then restart Emacs.
If you wrap a region of code that contains a #region macro in a Region
(using mark and point) then do:
M-x semantic-lex-test RET
you can find out if it successfully removed it from the token stream.
If it did not, you would need to fiddle the regexp till it worked.
Looking at the patch, I see I put in one too many ">". I had also
forgotten about the regionname that also (presumably) needs to be
removed.
Find a new patch below.
Eric
*** wisent-csharp.el 30 Sep 2005 15:50:54 -0400 1.4
--- wisent-csharp.el 19 Mar 2006 15:04:35 -0500
***************
*** 1,6 ****
--- 1,8 ----
;;; wisent-csharp.el --- LALR grammar for C#
;;
;; Copyright (C) 2003 David Shilvock
+ ;; Some Changes Copyright (C) 2006 Eric M. Ludlam
+
;; Time-stamp: <2003-12-08 19:11:48 dave>
;;
;; Author: David Shilvock <davels@...>
***************
*** 244,249 ****
--- 246,265 ----
;;; * Lexer
;;;----------------------------------------------------------------------
+ (define-lex-regex-analyzer wisent-csharp-lex-ignore-region
+ "Ignore # type macros for C sharp."
+ "^\\s-*#region\\>"
+ (goto-char (match-end 0))
+ (forward-word 1)
+ (setq semantic-lex-end-point (point))
+ nil)
+
+ (define-lex-regex-analyzer wisent-csharp-lex-ignore-endregion
+ "Ignore # type macros for C sharp."
+ "^\\s-*#endregion\\>"
+ (setq semantic-lex-end-point (match-end 0))
+ nil)
+
(define-lex-analyzer wisent-csharp-lex-string
"Detect and create a string token for csharp strings."
(looking-at wisent-csharp-string-re)
***************
*** 284,289 ****
--- 300,307 ----
semantic-lex-ignore-whitespace
semantic-lex-ignore-newline
semantic-lex-ignore-comments
+ wisent-csharp-lex-ignore-region
+ wisent-csharp-lex-ignore-endregion
wisent-csharp-lex-number
wisent-csharp-lex-string
wisent-csharp-lex-symbol
>>> Amit Lath <amit_lath@...> seems to think that:
>Hi,
>
>i tried to run the patch but it doesnt work. let me
>once more show how these tags look:
>
>#region regionName
>....some code here
>#endregion
>
>so VS.Net will fold the code within these two with the
>label "regionName".
>
>i dont know any emacs-lisp but i feel that maybe the
>regex provided by you isnt compatible with the above
>(i could be wrong in this though).
>
>i tried to write a regex of my own:
>
>^\\s*#(end)?region
>
>but that didnt work either (maybe i am missing some
>required escape chars according to emacs-lisp syntax).
>
>thanks
>amit
>
>--- "Eric M. Ludlam" <eric@...> wrote:
>
>> Hi,
>>
>> The macro things I had checked into CVS would not
>> work with C sharp
>> as they exist only in the C/C++ parser. I've made
>> the below patch
>> which I would guess will solve the #region problem.
>> It would be great
>> if someone could try it out and let me know if this
>> patch works.
>>
>> I have since written a generic lexical
>> pre-processor, but I don't
>> like the first implementation. Also, I do need to
>> focus more on
>> making a real release of cedet before delving into
>> such interesting
>> things much more.
>>
>> Thanks
>> Eric
>>
>> ----------------
>> *** wisent-csharp.el 30 Sep 2005 15:50:54 -0400 1.4
>> --- wisent-csharp.el 19 Mar 2006 11:05:53 -0500
>> ***************
>> *** 1,6 ****
>> --- 1,8 ----
>> ;;; wisent-csharp.el --- LALR grammar for C#
>> ;;
>> ;; Copyright (C) 2003 David Shilvock
>> + ;; Some Changes Copyright (C) 2006 Eric M. Ludlam
>> +
>> ;; Time-stamp: <2003-12-08 19:11:48 dave>
>> ;;
>> ;; Author: David Shilvock <davels@...>
>> ***************
>> *** 244,249 ****
>> --- 246,257 ----
>> ;;; * Lexer
>>
>>
>;;;----------------------------------------------------------------------
>>
>> + (define-lex-regex-analyzer
>> wisent-csharp-lex-ignore-macro
>> + "Ignore # type macros for C sharp."
>> + "^\\s-*#\\(end\\)>region\\>"
>> + (setq semantic-lex-end-point (match-end 0))
>> + nil)
>> +
>> (define-lex-analyzer wisent-csharp-lex-string
>> "Detect and create a string token for csharp
>> strings."
>> (looking-at wisent-csharp-string-re)
>> ***************
>> *** 284,289 ****
>> --- 292,298 ----
>> semantic-lex-ignore-whitespace
>> semantic-lex-ignore-newline
>> semantic-lex-ignore-comments
>> + wisent-csharp-lex-ignore-macro
>> wisent-csharp-lex-number
>> wisent-csharp-lex-string
>> wisent-csharp-lex-symbol
>>
>>
>>
>>
>> >>> <klaus.berndl@...> seems to think that:
>> >>" But i think this problem could be solved via
>> an appropriate setting =
>> >of the option
>> `semantic-lex-c-preprocessor-symbol-map' - see the =
>> >documentation or search the=20
>> >>semantic mailing-list - there was a thread which
>> addresses a similar =
>> >topic in c..."
>> >=20
>> >See above, i didn't mention a Thread about c# but
>> about c! And what is =
>> >wrong with the option
>> `semantic-lex-c-preprocessor-symbol-map'? The =
>> >tread i mean has an example how to add stuff to
>> this option which is =
>> >then ignored by the parser... Just search the cedet
>> archive for this =
>> >option!!
>> >=20
>> >Klaus
>> >
>> >________________________________
>> >
>> >From: Amit Lath [mailto:amit_lath@...
>> >Sent: Sunday, March 19, 2006 2:20 PM
>> >To: Berndl, Klaus
>> >Cc: ecb-list@...
>> >Subject: RE: [ECB-list] c# #region and #endregion
>> >
>> >
>> >Hi,
>> >=20
>> >i tried to find out what i can do in reference to
>> the message with C# =
>> >but couldnt get very far. i tried to search the
>> mailing list too, but =
>> >didnt find any topics related to C#.
>> >=20
>> >i have put up a query in the semantic mailing list
>> now and we are trying =
>> >there to see what can be done. will update here if
>> i find a solution.
>> >=20
>> >thanks
>> >amit
>> >
>> >klaus.berndl@... wrote:
>> >
>> > Hi all,
>> > =20
>> > please see the message below i sent to you at
>> 10.3.2006 ... does this =
>> >not help???
>> > =20
>> > Ciao,
>> > Klaus
>> >
>> >________________________________
>> >
>> > From: Berndl, Klaus=20
>> > Sent: Friday, March 10, 2006 2:38 PM
>> > To: 'Amit Lath'; ecb-list@...
>> > Cc: cedet-semantic@...
>> > Subject: RE: [ECB-list] c# #region and #endregion
>> >=09
>> >=09
>> > Hi,
>> > =20
>> > I was not aware that there is a parser for C#?!
>> > =20
>> > But i think this problem could be solved via an
>> appropriate setting of =
>> >the option `semantic-lex-c-preprocessor-symbol-map'
>> - see the =
>> >documentation or search the semantic mailing-list -
>> there was a thread =
>> >which addresses a similar topic in c.
>> > =20
>> > Ciao,
>> > Klaus
>> >
>> >________________________________
>> >
>> > From: ecb-list-admin@... =
>> >[mailto:ecb-list-admin@...] On
>> Behalf Of Amit Lath
>> > Sent: Monday, March 06, 2006 8:41 PM
>> > To: ecb-list@...
>> > Subject: [ECB-list] c# #region and #endregion
>> >=09
>> >=09
>> > Hi,
>> > =20
>> > i am using the latest ecb release with emacs
>> 21.3.1 for programming in =
>> >C#.
>> > =20
>> > my problem is, when i have methods inside the c#
>> #region and #endregion =
>> >directives, the methods buffer doesnt see them. as
>> soon as i delete the =
>> >above directives the methods buffer populates with
>> the methods =
>> >correctly.
>> > =20
>> > is this behavior expected. what can i do to
>> support the #region and =
>> >#endregion directives?
>> > =20
>> > thanks
>> > Amit Lath
>> > =20
>> > =20
>> >________________________________
>> >
>> > Yahoo! Mail
>> > Bring photos to life! New PhotoMail =
>>
>><http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=3D39174/*http://photomai=
>> >l.mail.yahoo.com> makes sharing a breeze.=20
>> >
>> >
>> >________________________________
>> >
>> >Yahoo! Mail
>> >Use Photomail =
>>
>><http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=3D38867/*http://photomai=
>> >l.mail.yahoo.com> to share photos without annoying
>> attachments.
>> >
>>
>>
>>
>-------------------------------------------------------
>>
>=== message truncated ===
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam? Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
|