* Fixing a bug in pascal-mode
@ 2014-04-06 7:19 Feng Li
2014-04-06 10:40 ` Feng Li
0 siblings, 1 reply; 7+ messages in thread
From: Feng Li @ 2014-04-06 7:19 UTC (permalink / raw)
To: emacs-devel
Hi Emacs devs,
I just fixed a small bug in pascal-mode. Here's the diff
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index a693295..4058826 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -168,7 +168,7 @@
;; "record" "array" "file")
(,(concat "\\<\\(array\\|boolean\\|c\\(har\\|onst\\)\\|file\\|"
"integer\\|re\\(al\\|cord\\)\\|type\\|var\\)\\>")
- font-lock-type-face)
+ . font-lock-type-face)
("\\<\\(label\\|external\\|forward\\)\\>" . font-lock-constant-face)
("\\<\\([0-9]+\\)[ \t]*:" 1 font-lock-function-name-face)
;; ("of" "to" "for" "if" "then" "else" "case" "while"
--
Feng Li
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Fixing a bug in pascal-mode
2014-04-06 7:19 Fixing a bug in pascal-mode Feng Li
@ 2014-04-06 10:40 ` Feng Li
2014-04-06 17:36 ` Daniel Colascione
0 siblings, 1 reply; 7+ messages in thread
From: Feng Li @ 2014-04-06 10:40 UTC (permalink / raw)
To: emacs-devel
Feng Li <fengli@gmail.com> writes:
> Hi Emacs devs,
>
> I just fixed a small bug in pascal-mode. Here's the diff
>
> diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
> index a693295..4058826 100644
> --- a/lisp/progmodes/pascal.el
> +++ b/lisp/progmodes/pascal.el
> @@ -168,7 +168,7 @@
> ;; "record" "array" "file")
> (,(concat "\\<\\(array\\|boolean\\|c\\(har\\|onst\\)\\|file\\|"
> "integer\\|re\\(al\\|cord\\)\\|type\\|var\\)\\>")
> - font-lock-type-face)
> + . font-lock-type-face)
> ("\\<\\(label\\|external\\|forward\\)\\>" . font-lock-constant-face)
> ("\\<\\([0-9]+\\)[ \t]*:" 1 font-lock-function-name-face)
> ;; ("of" "to" "for" "if" "then" "else" "case" "while"
Another one, this fixes pascal variables that contain keywords
surrounded by '_' chars (eg. do_this):
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index 4058826..10b7619 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -166,20 +166,20 @@
(3 font-lock-function-name-face))
;; ("type" "const" "real" "integer" "char" "boolean" "var"
;; "record" "array" "file")
- (,(concat "\\<\\(array\\|boolean\\|c\\(har\\|onst\\)\\|file\\|"
- "integer\\|re\\(al\\|cord\\)\\|type\\|var\\)\\>")
+ (,(concat "\\_<\\(array\\|boolean\\|c\\(har\\|onst\\)\\|file\\|"
+ "integer\\|re\\(al\\|cord\\)\\|type\\|var\\)\\_>")
. font-lock-type-face)
- ("\\<\\(label\\|external\\|forward\\)\\>" . font-lock-constant-face)
- ("\\<\\([0-9]+\\)[ \t]*:" 1 font-lock-function-name-face)
+ ("\\_<\\(label\\|external\\|forward\\)\\_>" . font-lock-constant-face)
+ ("\\_<\\([0-9]+\\)[ \t]*:" 1 font-lock-function-name-face)
;; ("of" "to" "for" "if" "then" "else" "case" "while"
;; "do" "until" "and" "or" "not" "in" "with" "repeat" "begin" "end")
- ,(concat "\\<\\("
+ ,(concat "\\_<\\("
"and\\|begin\\|case\\|do\\|e\\(lse\\|nd\\)\\|for\\|i[fn]\\|"
"not\\|o[fr]\\|repeat\\|t\\(hen\\|o\\)\\|until\\|w\\(hile\\|ith\\)"
- "\\)\\>")
- ("\\<\\(goto\\)\\>[ \t]*\\([0-9]+\\)?"
+ "\\)\\_>")
+ ("\\_<\\(goto\\)\\_>[ \t]*\\([0-9]+\\)?"
1 font-lock-keyword-face)
- ("\\<\\(goto\\)\\>[ \t]*\\([0-9]+\\)?"
+ ("\\_<\\(goto\\)\\_>[ \t]*\\([0-9]+\\)?"
2 font-lock-keyword-face t))
"Additional expressions to highlight in Pascal mode.")
--
Feng Li
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Fixing a bug in pascal-mode
2014-04-06 10:40 ` Feng Li
@ 2014-04-06 17:36 ` Daniel Colascione
2014-04-06 23:25 ` Feng Li
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Colascione @ 2014-04-06 17:36 UTC (permalink / raw)
To: Feng Li, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 201 bytes --]
On 04/06/2014 03:40 AM, Feng Li wrote:
> Feng Li <fengli@gmail.com> writes:
>
>> Hi Emacs devs,
>>
>> I just fixed a small bug in pascal-mode. Here's the diff
>>
Can you write a testcase?
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fixing a bug in pascal-mode
2014-04-06 17:36 ` Daniel Colascione
@ 2014-04-06 23:25 ` Feng Li
2014-04-07 14:03 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Feng Li @ 2014-04-06 23:25 UTC (permalink / raw)
To: emacs-devel
Daniel Colascione <dancol <at> dancol.org> writes:
>
> On 04/06/2014 03:40 AM, Feng Li wrote:
> > Feng Li <fengli <at> gmail.com> writes:
> >
> >> Hi Emacs devs,
> >>
> >> I just fixed a small bug in pascal-mode. Here's the diff
> >>
>
> Can you write a testcase?
>
>
Hi Daniel,
I'm not sure what kind of testcase do you want. I had a brief look in the
source tree and didn't see any Pascal (or other languages) syntax
highlighting testcases under the 'test' directory, which I could use as
examples to write my testcases for these bugs.
I could describe the nature of the 2 bugs though as they are really quite
straightforward. So if you know how to write testcases probably you could help?
The first bug actually prevents any syntax highlighting rules after it to
run because that slot, if it's a list, then it should be a function rather
than a font lock class. Emacs prints out errors like "function is void:
font-lock-type-face" to the messages buffer. If there is any existing
Pascal mode syntax highlighting testcases then most of them should already fail.
The second bug is that in the syntax table the '_' character is considered a
symbol delimiter but not a word delimiter. Therefore the regexps would match
sub-strings inside a symbol. For example, the variable 'value_to_rgb' would
have the 'to' matched as a keyword and the 'to' gets highlighted.
Hopefully this helps.
--
Feng Li
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fixing a bug in pascal-mode
2014-04-06 23:25 ` Feng Li
@ 2014-04-07 14:03 ` Stefan Monnier
2014-04-07 14:24 ` Feng Li
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2014-04-07 14:03 UTC (permalink / raw)
To: Feng Li; +Cc: emacs-devel
> I'm not sure what kind of testcase do you want. I had a brief look in the
> source tree and didn't see any Pascal (or other languages) syntax
> highlighting testcases under the 'test' directory, which I could use as
> examples to write my testcases for these bugs.
Just add to test/indent/pascal.pas a sample piece of Pascal code
where the bug shows up.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fixing a bug in pascal-mode
2014-04-07 14:03 ` Stefan Monnier
@ 2014-04-07 14:24 ` Feng Li
2014-04-10 13:57 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Feng Li @ 2014-04-07 14:24 UTC (permalink / raw)
To: emacs-devel
Here you go.
Note that there are 2 bugs and this is just a test case for the second
one.
This is because the first bug actually stops font lock from completing
so you'll only see very little syntax highlighting in the test
file. There is no need to add a test case for this as the entire file is
a test case.
Once the first bug is fixed then the syntax highlighting becomes much
richer and then you'll be able to see the second bug.
--->8------>8------>8------>8------>8------>8------>8------>8---
diff --git a/test/indent/pascal.pas b/test/indent/pascal.pas
index 4b3be7c..0005b95 100644
--- a/test/indent/pascal.pas
+++ b/test/indent/pascal.pas
@@ -29,6 +29,7 @@ by the GNU General Public License. }
// Free-pascal style comment.
var x:Char = 12 /* 45; // This /* does not start a comment.
var x:Char = (/ 4); // This (/ does not start a comment.
+var a_to_b : integer; // 'to' should not be highlighted
program CRTDemo;
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> I'm not sure what kind of testcase do you want. I had a brief look in the
>> source tree and didn't see any Pascal (or other languages) syntax
>> highlighting testcases under the 'test' directory, which I could use as
>> examples to write my testcases for these bugs.
>
> Just add to test/indent/pascal.pas a sample piece of Pascal code
> where the bug shows up.
>
>
> Stefan
>
>
--
Feng Li
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-04-10 13:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-06 7:19 Fixing a bug in pascal-mode Feng Li
2014-04-06 10:40 ` Feng Li
2014-04-06 17:36 ` Daniel Colascione
2014-04-06 23:25 ` Feng Li
2014-04-07 14:03 ` Stefan Monnier
2014-04-07 14:24 ` Feng Li
2014-04-10 13:57 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.