Re: make_ctags: use -I option to ignore pg_node_attr macro - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: make_ctags: use -I option to ignore pg_node_attr macro
Date
Msg-id 20221015.104029.452778853846743298.t-ishii@sranhm.sra.co.jp
Whole thread Raw
In response to Re: make_ctags: use -I option to ignore pg_node_attr macro  (Yugo NAGATA <nagata@sraoss.co.jp>)
Responses Re: make_ctags: use -I option to ignore pg_node_attr macro  (Yugo NAGATA <nagata@sraoss.co.jp>)
List pgsql-hackers
> On Thu, 13 Oct 2022 15:35:09 +0900 (JST)
> Tatsuo Ishii <ishii@sraoss.co.jp> wrote:
> 
>> > OK, that sounds good then.  I would make a feature request to have a
>> > switch that supresses creation of these links, then.
>> 
>> Ok, I have added "-n" option to make_ctags so that it skips to create
>> the links.
>> 
>> Also I have changed make_etags so that it exec make_ctags, which seems
>> to be the consensus.
> 
> Thank you for following up my patch.
> I fixed the patch to allow use both -e and -n options together.

Thanks. I have made mostly cosmetic changes so that it is more
consistent with existing scripts.

I would like to push v6 patch if there's no objection.

Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
diff --git a/src/tools/make_ctags b/src/tools/make_ctags
index 912b6fafac..102881667b 100755
--- a/src/tools/make_ctags
+++ b/src/tools/make_ctags
@@ -1,12 +1,37 @@
 #!/bin/sh
 
-# src/tools/make_ctags
+# src/tools/make_ctags [-e] [-n]
+# If -e is specified, generate tags files for emacs.
+# If -n is specified, don't create symbolic links of tags file.
+usage="Usage:  $0 [-e][-n]"
+if [ $# -gt 2 ]
+then    echo $usage
+    exit 1
+fi
+
+MODE=
+NO_SYMLINK=
+TAGS_FILE="tags"
+
+while [ $# -gt 0 ]
+do
+    if [ $1 = "-e" ]
+    then    MODE="-e"
+        TAGS_FILE="TAGS"
+    elif [ $1 = "-n" ]
+    then    NO_SYMLINK="Y"
+    else
+        echo $usage
+        exit 1
+    fi
+    shift
+done
 
 command -v ctags >/dev/null || \
     { echo "'ctags' program not found" 1>&2; exit 1; }
 
 trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
-rm -f ./tags
+rm -f ./$TAGS_FILE
 
 IS_EXUBERANT=""
 ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
@@ -34,9 +59,17 @@ then    FLAGS="--c-kinds=+dfmstuv"
 else    FLAGS="-dt"
 fi
 
+# Use -I option to ignore a macro
+if [ "$IS_EXUBERANT" ]
+then    IGNORE_IDENTIFIES="-I pg_node_attr+"
+else    IGNORE_IDENTIFIES=
+fi
+
 # this is outputting the tags into the file 'tags', and appending
-find `pwd`/ -type f -name '*.[chyl]' -print |
-    xargs ctags -a -f tags "$FLAGS"
+find `pwd`/ \( -name tmp_install -prune -o -name tmp_check -prune \) \
+    -o \( -name "*.[chly]" -o -iname "*makefile*" -o -name "*.mk" -o -name "*.in" \
+    -o -name "*.sql" -o -name "*.p[lm]" \) -type f -print |
+    xargs ctags $MODE -a -f $TAGS_FILE "$FLAGS" "$IGNORE_IDENTIFIES"
 
 # Exuberant tags has a header that we cannot sort in with the other entries
 # so we skip the sort step
@@ -45,10 +78,13 @@ find `pwd`/ -type f -name '*.[chyl]' -print |
 if [ ! "$IS_EXUBERANT" ]
 then    LC_ALL=C
     export LC_ALL
-    sort tags >/tmp/$$ && mv /tmp/$$ tags
+    sort $TAGS_FILE >/tmp/$$ && mv /tmp/$$ $TAGS_FILE
 fi
 
-find . \( -name 'CVS' -prune \) -o \( -name .git -prune \) -o -type d -print |
-while read DIR
-do    [ "$DIR" != "." ] && ln -f -s `echo "$DIR" | sed 's;/[^/]*;/..;g'`/tags "$DIR"/tags
-done
+# create symbolic links
+if [ ! "$NO_SYMLINK" ]
+then    find . \( -name 'CVS' -prune \) -o \( -name .git -prune \) -o -type d -print |
+    while read DIR
+    do    [ "$DIR" != "." ] && ln -f -s `echo "$DIR" | sed 's;/[^/]*;/..;g'`/$TAGS_FILE "$DIR"/$TAGS_FILE
+    done
+fi
diff --git a/src/tools/make_etags b/src/tools/make_etags
index 9288ef7b14..afc57e3e89 100755
--- a/src/tools/make_etags
+++ b/src/tools/make_etags
@@ -1,16 +1,6 @@
 #!/bin/sh
-
 # src/tools/make_etags
 
-command -v etags >/dev/null || \
-    { echo "'etags' program not found" 1>&2; exit 1; }
-
-rm -f ./TAGS
-
-find `pwd`/ -type f -name '*.[chyl]' -print |
-    xargs etags --append -o TAGS
-
-find . \( -name CVS -prune \) -o \( -name .git -prune \) -o -type d -print |
-while read DIR
-do    [ "$DIR" != "." ] && ln -f -s `pwd`/TAGS "$DIR"
-done
+cdir=`dirname $0`
+dir=`(cd $cdir && pwd)`
+exec $dir/make_ctags -e $*

pgsql-hackers by date:

Previous
From: Corey Huinker
Date:
Subject: Re: predefined role(s) for VACUUM and ANALYZE
Next
From: Michael Paquier
Date:
Subject: Re: New "single-call SRF" APIs are very confusingly named