[PATCH] Add Pascal/Delphi (.pas file) funcname pattern.

Subsystems: the rest

DORMANTno replies

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] Add Pascal/Delphi (.pas file) funcname pattern.

From: Avery Pennarun <hidden>
Date: 2016-06-15 22:45:05

Finds classes, records, functions, procedures, and sections.  Most lines
need to start at the first column, or else there's no way to differentiate
a procedure's definition from its declaration.

Signed-off-by: Avery Pennarun <redacted>
---

The Ruby funcname pattern patch inspired me.  Although unlike him, I didn't
check with anyone else for confirmation.  How many Pascal programmers can
there possibly be? :)

 diff.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index cbf2547..c73ba69 100644
--- a/diff.c
+++ b/diff.c
@@ -1380,6 +1380,10 @@ static struct builtin_funcname_pattern {
 			"^[ 	]*\\(\\([ 	]*"
 			"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
 			"[ 	]*([^;]*\\)$" },
+	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
+			"destructor\\|interface\\|implementation\\|"
+			"type|initialization|finalization\\).*$\\)"
+			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },
 	{ "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
 };
 
-- 
1.6.0.rc1.34.g23b24.dirty

Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.

From: Petr Baudis <hidden>
Date: 2016-06-15 22:45:05

On Fri, Aug 01, 2008 at 03:45:15PM -0400, Avery Pennarun wrote:
quoted hunk
diff --git a/diff.c b/diff.c
index cbf2547..c73ba69 100644
--- a/diff.c
+++ b/diff.c
@@ -1380,6 +1380,10 @@ static struct builtin_funcname_pattern {
 			"^[ 	]*\\(\\([ 	]*"
 			"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
 			"[ 	]*([^;]*\\)$" },
+	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
+			"destructor\\|interface\\|implementation\\|"
+			"type|initialization|finalization\\).*$\\)"
+			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },
 	{ "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
 };
 
Wouldn't it be better to make the second pattern start on new line
instead of the outer \(\|\)?

Why "type"?

-- 
		Petr "Pasky, but not writing in Pascal anymore!" Baudis
As in certain cults it is possible to kill a process if you know
its true name.  -- Ken Thompson and Dennis M. Ritchie

Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.

From: Avery Pennarun <hidden>
Date: 2016-06-15 22:45:05

On 8/1/08, Petr Baudis [off-list ref] wrote:
On Fri, Aug 01, 2008 at 03:45:15PM -0400, Avery Pennarun wrote:
 > +     { "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
 > +                     "destructor\\|interface\\|implementation\\|"
 > +                     "type|initialization|finalization\\).*$\\)"
 > +                     "\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },

Wouldn't it be better to make the second pattern start on new line
 instead of the outer \(\|\)?
I didn't even know that was possible, but suddenly I understand the
"java" pattern a lot better.  Thanks!
 Why "type"?
Well, it's a subsection, but it's always followed by a class or record
definition anyway, so I guess it makes more sense to omit it, now that
you bring it up.

Have fun,

Avery
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help