commit 47191e5200a01ded9420f13f2835867413ec6b13 Spenser Truex <truex@equwal.com> 2020-09-20 19:29:02 -0700 Initial commit. This generates tags for source code cross-referencing programs (xref programs). It currently lacks a build system and has a pretty unfriendly interface. It is also written using Roswell, which makes it more of a chore to install.
README | 46 ++++++++++++++++++++++++++++++ config-examples/local.conf | 9 ++++++ config-examples/root.conf | 1 + tag-gen.ros | 70 ++++++++++++++++++++++++++++++++++++++++++++++ wrapper/tgen | 7 +++++ 5 files changed, 133 insertions(+)
diff --git a/README b/README new file mode 100644 index 0000000..06defb0 --- /dev/null +++ b/README @@ -0,0 +1,46 @@ +Generate etags for a list of files and extensions. + +=== +Requirements +=== +- A cron program like cronie or scron +- The Roswell Common Lisp script bootstrapper +- a tagging program like etags + +=== +Install +=== + +Add a command to cron like: +*/29 * * * * su username -c 'tag-gen.ros /home/username/.config/tag-gen/local.conf /usr/bin/etags 1' + +Signature: + +tag-gen.ros <conf> <tag program> [verbosity] + +tags.conf needs to contain this kind of format: +(("<directory>" ("<ext>"...)) + ...) +See examples in config-examples. Configuration is **mandatory** for the program to work. + +For example: +(("/home/jose/.emacs.d" ("el")) + ("/home/jose/src/sf/sbcl/sbcl" ("lisp" "c"))) + +Keep in mind that the home shorthand ~ might not git expanded +properly! Always use absolute paths like in the examples. + +For output control, call with a debug argument 0, 1, 2 where: +- 0 is silent +- 1 is for serious errors +- 2 is for everything + +Edit tgen and put it in the path. + +=== +TODO +=== +Use GNU Make to put things in the PATH and to form absolute paths. + + + diff --git a/config-examples/local.conf b/config-examples/local.conf new file mode 100644 index 0000000..7b4e313 --- /dev/null +++ b/config-examples/local.conf @@ -0,0 +1,9 @@ +(("/home/username/.emacs.d" ("el")) + ("/home/username/src/sf/sbcl/sbcl" ("lisp" "c")) + ("/home/username/src/savannah/emacs" ("el" "c")) + ("/home/username/src/xscreensaver" ("c" "h" "sh")) + ("/home/username/src/sh" ("sh")) + ("/home/username/lang/tex/" ("tex" "bib")) + ("/home/username/lang/roff/" ("ms" "ref")) + ("/home/username/src/m4/" ("m4")) + ("/home/username/common-lisp" ("lisp"))) diff --git a/config-examples/root.conf b/config-examples/root.conf new file mode 100644 index 0000000..604f796 --- /dev/null +++ b/config-examples/root.conf @@ -0,0 +1 @@ +(("/usr/include" ("c" "h"))) diff --git a/tag-gen.ros b/tag-gen.ros new file mode 100755 index 0000000..2741c69 --- /dev/null +++ b/tag-gen.ros @@ -0,0 +1,70 @@ +#!/bin/sh +#|-*- mode:lisp -*-|# +#| +exec ros -Q -- $0 "$@" +|# +(progn ;;init forms + (ros:ensure-asdf) + #+quicklisp(ql:quickload '() :silent t) + ) + +;;;; Generate etags for a list of files. +;;;; Add a command to cron like: +;;;; 0 0 * * * tag-gen ~/.config/tag-gen/tags.conf +;;;; +;;;; tags.conf needs to contain this kind of format: +;;;; (("<directory>" ("<ext>"...)) +;;;; ...) +;;;; +;;;; For example: +;;;; (("/home/jose/.emacs.d" ("el")) +;;;; ("/home/jose/src/sf/sbcl/sbcl" ("lisp" "c"))) +;;;; +;;;; Keep in mind that the home shorthand ~ might not git expanded properly! +;;;; +;;;; For debugging, call with a debug argument 0, 1, 2 where: +;;;; - 0 is silent +;;;; - 1 is for serious errors +;;;; - 2 is for everything + +(defpackage :ros.script.tag-gen.3809526563 + (:use :cl)) +(in-package :ros.script.tag-gen.3809526563) + +(defvar *log-level* 0) + +(defun add-to-log (str-log level) + (when (and (/= 0 *log-level*) + (>= *log-level* level)) + (format t "~A~%" str-log))) + +(defun tag-gen (tags tag-program) + (labels ((extensions (dir exts) + (when exts + (add-to-log tags 2) + (add-to-log + (or (and (not (uiop:directory-exists-p dir)) + (cons (format nil "The directory ~A doesn't exist" dir) 1)) + (uiop:run-program (format nil + "find ~A -type f -iname \"*.~A\" | ~A -" + dir + (car exts) + tag-program) + :ignore-error-status t + :output '(string :stripped t))) + 2) + (extensions dir (cdr exts))))) + (when tags + (extensions (caar tags) (cadar tags)) + (tag-gen (cdr tags) tag-program)))) + +(defun main (conf tag-program &optional (log-level *log-level*) &rest argv) + (declare (ignorable argv)) + (let ((log-level (if (stringp log-level) + (parse-integer log-level) + log-level))) + (setf *log-level* log-level) + (with-open-file (s conf :direction :input) + (tag-gen (read s) (uiop:unix-namestring tag-program))))) + +;;; vim: set ft=lisp lisp: diff --git a/wrapper/tgen b/wrapper/tgen new file mode 100755 index 0000000..d1f826e --- /dev/null +++ b/wrapper/tgen @@ -0,0 +1,7 @@ +#!/bin/sh + +# tag-gen.ros isn't really meant to be used interactively, but it can +# be useful to call it directly when making big changes to a project, +# adding a new one, etc. + +tag-gen.ros /home/username/.config/tag-gen/local.conf /usr/bin/etags 2