summaryrefslogtreecommitdiffstats
path: root/tags.tl
Commit message (Collapse)AuthorAgeFilesLines
* lib: sort becomes non-destructive; nsort introduced.Kaz Kylheku2020-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm fixing a historic mistake copied from ANSI Lisp, which trips up language newcomers and sometimes even experienced users. The function innocently named sort will now return newly allocated structure. The function previously called sort will be available as nsort (non-consing/allocating sort). The shuffle function also becomes pure, and is accompanied by nshuffle. * eval (me_op): Continue to use destructive sort in this legacy code that is only triggered in very old compat mode. (eval_init): Registered nsort and nshuffle. * lib.c (nsort, nshuffle): New functions introduced, closely based on sort and shuffle. (sort, shuffle): Rewritten to avoid destructive behavior: work by copying the input and calling destructive counterparts. (sort_group): Continue to use destructive sort, which is safe; the structure is locally allocated. The sort_group function has pure semantics. (grade): Likewise. * lib.h (nsort, nshuffle): Declared. * share/txr/stdlib/getopts.tl (opthelp): Replace an instance of the (sort (copy-list ...)) pattern with just (sort ...). * tags.tl (toplevel): Continue to use destructive sort to sort tags before writing the tag file; the lifetime of the tags list ends when the file is written. * tests/010/seq.txr: Switch some sort calls to nsort to keep test case working. * txr.1: Documented.
* tags: bugfix: file-opening logic in simulated load.Kaz Kylheku2020-04-221-1/+2
| | | | | | | | * tags.tl (fake-load): When the file doesn't end in .tl, we are only trying it with the .tl suffix, without falling back on the original name. And we are doing that in an ignerr, so the nil object will be used as a stream. This cause stdin to be read when the function encounters a dangling symlink.
* tags: @(bind) should generate variable tags.Kaz Kylheku2020-04-071-1/+1
| | | | | * tags.tl (process-clause): Symbols from @(bind) should be recorded as variable tags, not function tags.
* tags: handle macro-timeKaz Kylheku2020-04-051-1/+1
| | | | * tags.tl (process-form): Handle top-level macro-time form.
* tags: bugfix: process progn correctly.Kaz Kylheku2020-04-051-1/+1
| | | | | | * tags.tl (process-form): Use mappend for the recursive processing, not mapdo, and invoke pend on the result to add it to the accumulated list.
* tags: process only pkg clauses of load-for.Kaz Kylheku2020-04-051-1/+4
| | | | | | * tags.tl (process-package-influencing-form): When a load-for is encountered, only descend into fake-load if the clause kind is pkg, and the package doesn't exist.
* tags: use sys:make-anon-packageKaz Kylheku2020-04-051-1/+1
| | | | | | | * tags.tl (in-anon-package): Take advantage of the system function sys:make-anon-package which is used in the file compiler, instead of creating a package named "anon" which could plausibly clash with an existing package.
* tags: completely restore package list for each file.Kaz Kylheku2020-04-051-6/+4
| | | | | | | | * tags.tl (in-anon-package): Instead of the unwind-protect which deletes the anonymous package, let us save and restore the *package-alist* by dynamically binding it to its current value. This will roll back packages that were created by fake-load.
* tags: follow loads and define needed packages.Kaz Kylheku2020-04-051-1/+24
| | | | | | | | | | | | * tags.tl (*fake-load-path*): New special variable. (process-package-influencing-form, fake-load): New functions. (process-form): Pass each compound form to process-package-influencing-form in case it might be a defpackage or load. (collect-tags-tl): Bind *fake-load-path* to the file's path so fake-load will resolve relative paths relative to the file's own directory, similarly to how load works with *load-path*.
* tags: process files in anon package.Kaz Kylheku2020-04-041-4/+15
| | | | | | | | | | Let's process each file in an anonymous package, saving and restoring the *package* special. TXR files can mess with that variable. * tags.tl (in-anon-package): New macro. (collect-tags-tl, collect-tags-txr): Wrap parsing with in-anon-package macro.
* tags: wrong flattening function in @(bind) handling.Kaz Kylheku2020-04-041-1/+1
| | | | | * tags.tl (process-clause): Bugfix: flatcar must be used, not flatten, because the bindings can contain dotted notation.
* tags: grok Lisp definitions inside @(do ...).Kaz Kylheku2020-04-031-1/+9
| | | | | | | | | | | * tags.tl (unexpand): New function. (process-clause): Walk the forms enclosed in a @(do ...) directive that appears at the top level. Because all Lisp is macro-expanded right inside the TXR parser, we need to "unexpand" the forms by chasing their macro-ancestor chain, gaining access to the original forms like defun and defstruct. We can then turn these forms into tags using the process-form function.
* tags: first cut at handling .txr files.Kaz Kylheku2020-04-031-65/+114
| | | | | | | | | | | | | | | | | | | Handles only top-level define and bind. * tags.tl (with-tag-shorthand-macro): New macro: a robot for writing the the shorthand macrolet in collect-tags, so we can reuse it. (process-form): New function, made from the bulk of collect-tags. (collect-tags): Renamed to collect-tags-tl. The macrolet is replaced by invocation of with-tag-shorthand macro and the form case processing logic by a call to process-form. (process-clause, collect-tags-txr, collect-tags-guess): New functions. (toplevel): Help text updated. Process .txr files through collect-tags-txr. Also process unsuffixed files, if they are explicity mentioned on the command line, through collect-tags-guess, which looks for hash-bang lines containing the --lisp option.
* tags: backslashes require escape.Kaz Kylheku2020-04-031-1/+1
| | | | | | | * tags.tl (escape): Vim is failing to find tag entries when the search patterns are lines containing backslashes. Backslash must be added to the list of characters needing escaping in tag patterns.
* tags: useless use of quasiliteral.Kaz Kylheku2020-03-141-2/+2
| | | | | * txr.tl (toplevel): In the usage output, a few quasiliterals should just be literals since nothing is interpolated.
* tags: fix reversed test for ftw-actionretval.Kaz Kylheku2020-03-141-1/+1
| | | | | | | | * tags.tl (toplevel): We need to push directories into the skiplist when we don't have FTW_ACTIONRETVAL, indicated by ftw-actionretval being zero. If ftw-actionretval is nonzero, so is ftw-skip-subtree, which completely takes care of the skipping of subdirectories.
* tags: missing eval in macro.Kaz Kylheku2020-03-111-1/+1
| | | | | * tags.tl (static-when): Macro must explicitly reduce expression to its value.
* tags: support compilation.Kaz Kylheku2020-03-101-41/+42
| | | | | * tags.tl (toplevel): Wrap in compile-only so compiler doesn't execute it.
* tags: don't scan files twice.Kaz Kylheku2020-03-091-67/+65
| | | | | | | | | | * tags.tl (collect-tags): Snarf the file as a string from which we can make a string byte input stream suitable for parsing. Having that string, we can handle hash bang by detecting it and commenting it out with a semicolon. We obtain the lines by splitting the string. When calling read, we pass the path as the name argument, so error messages still use the correct file name.
* tags: add --exclude option.Kaz Kylheku2020-03-071-9/+33
| | | | | | | | | | | | | * tags.tl (tags-opts): Cumulative exlude option added. (ftw-actionretval, ftw-continue, ftw-skip-subtree): These variables are missing if we are not on Glibc, so we define them as zero. These definitions help us take advantage of FTW_ACTIONRETVAL to skip recursing into exluded subtrees. (static-when): New macro. (toplevel): Implement exclude option. Skipping directories on platforms whose nftw function doesn't have FTW_ACTIONRETVAL is simulated by keeping a dynamic skip list, which is intelligently purged to keep it short.
* tags: handle option struct slots with more careKaz Kylheku2020-03-051-2/+4
| | | | | | | | * tags.tl (collect-tags): In proccessing a define-option-struct, don't record a tag for a long or short option that is nil. Each option definition defines only one slot. If both a long and short option are present (non-nil), then the long option names the slot.
* tags: implement merge with merge function.Kaz Kylheku2020-03-051-2/+2
| | | | | | | * tags.tl (write-tagfile): Since we can assume that the tags file is sorted, and the tags coming into this function are likewise sorted, we can just merge the sorted lists. Then, we don't have to sort the tags list a second time.
* tags: fix off-by-one line numbers for hash bang.Kaz Kylheku2020-03-051-1/+2
| | | | | | | | | * tags.tl (collect-tags): For hash-bang files, pop the dummy blank line that we inserted at the head of the line list to obtain 1-based numbering. If the parser starts working ater the #! line, it means the second line is 1, which is the same as zero-based numbering, so we can lose the dummy entry and all is well.
* tags: handle define-option-struct.Kaz Kylheku2020-03-051-0/+6
| | | | | | * tags.tl (collect-tags): Generate tags for the define-option-struct macro, indexing both the long and short forms.
* tags: add option processing.Kaz Kylheku2020-03-051-11/+46
| | | | | | | | | | | | * tags.tl (tag-opts): New option struct. (orig-tag): New struct. (write-tagfile): Take option struct as argument. Implement merge and append options. (toplevel): Parse arguments and provide usage text. Default to processing the current directory when no non-option arguments are given. Allow files that don't end in .tl, if they are explicititly specified; but directories are searched only for .tl files.
* tags: reduce repetition of tag construction with macrolet.Kaz Kylheku2020-03-041-76/+50
| | | | | * tags.tl (collect-tags): Use macrolet to sugar over the numerous new operator calls.
* tags: eliminate duplicated text methods.Kaz Kylheku2020-03-041-10/+13
| | | | | | | | | * tags.tl (tag): New slot, type; new method, text. (fun-tag, var-tag, struct-tag, type-tag): Override type slot with appropriate value ("f", "v", "s", "t"), and remove text method. (slot-tag): Override type; keep text method, and interpolate typee instead of hard-coded "m".
* TXR Lisp tag generation utility.Kaz Kylheku2020-03-041-0/+150
* tags.tl: New file.