aboutsummaryrefslogtreecommitdiff
path: root/pkg/system/references.cl
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/system/references.cl
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/system/references.cl')
-rw-r--r--pkg/system/references.cl50
1 files changed, 50 insertions, 0 deletions
diff --git a/pkg/system/references.cl b/pkg/system/references.cl
new file mode 100644
index 00000000..ca93e6a6
--- /dev/null
+++ b/pkg/system/references.cl
@@ -0,0 +1,50 @@
+# REFERENCES -- Search the help database for help on a given subject.
+# By default a runtime search is performed of all the package menus in the
+# help database, but the user may prepare a "quick-reference" file to speed
+# further searches if desired. This cannot easily be done automatically
+# since any set of packages may form the help database.
+#
+# NOTE -- Uses LISTS.
+
+procedure references (topic)
+
+string topic { prompt = "topic to find help for" }
+file quickref = "uparm$quick.ref" { prompt = "quick-reference file" }
+bool updquick = no { prompt = "update quick-reference file" }
+bool usequick = no { prompt = "use quick-reference file" }
+
+begin
+ string pattern
+ file fname
+
+ # Make a quick-search file if so requested.
+ if (updquick) {
+ fname = quickref
+ print ("generating new quick-reference file " // fname // "...")
+ if (access (fname))
+ delete (fname, verify-)
+ help ("[a-z]*.", option="ref", curpack="AsckCL", device="terminal",
+ helpdb="helpdb") |& match ("-", metacharacters=yes) |
+ sort(ignore+) | unique ( > fname)
+ references.quickref = fname
+ references.usequick = yes
+
+ } else {
+ # Ignore case.
+ pattern = ("{" // topic // "}")
+
+ # If the user has prepared a quick-search file (e.g., by running
+ # this task with topic=* and saving the output to make the quick
+ # file), search that if it exists, otherwise perform a runtime
+ # search of the package menu files for the entire help database.
+
+ if (usequick && access (quickref))
+ match (pattern, quickref, metacharacters=yes)
+ else {
+ print ("searching the help database...")
+ help ("[a-z]*.", section="all", option="ref", curpack="AsckCL",
+ device="terminal", helpdb="helpdb") |& sort(ignore+) |
+ unique | match (pattern, metacharacters=yes)
+ }
+ }
+end