Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the trivial-renamer Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 15:20:52 2020 GMT+0.
• Introduction | What trivial-renamer is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
TRIVIAL-RENAMER (RENAME) is a configurable Lisp tool for renaming objects using regular expressions, and maintaining mappings between old and new names. It may be useful as a component in projects such as file managers, MP3 renamers, and FFI generators.
TRIVIAL-RENAMER operates on 'categorized' names. Some examples of categories (which may be arbitrary lisp objects) are: file types/extensions, music album or songs, or FFI types.
Prior to renaming, TRIVIAL-RENAMER requires that you provide it with rules for categories. Each category can have one or more rules; each rule is a pair containing a regex and the substitution string. These are usually bulk-loaded as a list or rules, although you can add them dynamically.
The renaming process consists of rule-based renaming followed by a call to a 'normal' function you provide. If no rules can be found, the 'default' renaming function is called. The result will be checked to assure one-to-one correspondece between old and new names.
Both the format of the rules and the transformation function are configurable; the default is to perform regex text substitution based on rules that contain (regex . newstring)
.
After renaming, the hashtables built are made available to your application.
Any number of different renamers can be active at the same time.
cl-ppcre
The defaults create a renamer that expects string objects. A simple downcase renaming function is provided to test the functionality.
CL-USER> (ql:quickload :trivial-renamer)
...
CL-USER> (make-instance 'rename:renamer)
#<TRIVIAL-RENAMER:RENAMER {...}>
CL-USER> (rename:please "HELLO WORLD") ;; default is downcasing
"hello world"
CL-USER> (rename:rule 'cat1 '(("e" . "3"))) ;; add a regex substitution rule
(renamer:please "monkey" 'cat1)
"monk3y"
The example above shows a number of defaults in use. For instance, both normal and default renaming routines start out as lowercasing the string, unless set. If the renamer itself is not specified, rename:*default-renamer*
is used which is useful for testing. If the category is not specified, T is used for category. See the documentation below for more information.
The raison d'etre of this library is a cffi binding generator. Translating C identifier names to Lisp required keeping custom name translation rules based on type of C object, its namespace, and even the object's actual name, for total control of renaming.
After renaming, there is still the daunting task of maintaining a relationship between old and new names, uniqueness of mapping, etc.
The required functionality appeared to be well suited for a library.
KEY | DEFAULT | DESCRIPTION
--- | ------- | -----------
:TEST | #'equal | equality test for category hashtable.
:OVERWRITE | T | if T, overwrite rules if category is introduced more than once. Otherwise, add new rules in front.
:VALIDATE | NIL |(lambda (key value r))
optional function to validate a rule. If it returns, rule is valid.
:DEFAULT | lowercase | :default (lambda (oldname renamer)...)
called if no rule is found, return string.
:NORMAL | obj copy | :default (lambda (newname renamer)...)
called after rule is processed, return string.
:TRANSFORM | * | renaming function; see below
Parameter | Description --------- | ----------- rule | a list of (regex . newstring) pairs. Each matched regex is substituted with newstring. category | any object that works as a key in the rule hashtable (with :TEST)
Parameter | Description --------- | ----------- list | '(category ((regex . newstring) (regex .newstring)) category ((...)) ...)
Returns the new name.
Raises errors if the old name is already transformed and new transform mismatches, or if newly generated name is already in use.
Clear the renamer data and rules.
(lambda name category rules renamer)
It is possible to completely change the behavior of TRIVIAL-RENAMER by installing a different version of this function: the format of the rules, the actual transformations, etc.
The default transform expects each rule to be in the form of (regex . replacement)
, and repeatedly attempts to perform the replacements on the name.
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The trivial-renamer system |
StackSmith <fpgasm@apple2.x10.mx>
BSD 3-clause license
rename and manage categorized named objects
cl-ppcre
trivial-renamer.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The trivial-renamer.asd file | ||
• The trivial-renamer/package.lisp file | ||
• The trivial-renamer/trivial-renamer.lisp file |
Next: The trivial-renamer/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
trivial-renamer.asd
trivial-renamer (system)
Next: The trivial-renamer/trivial-renamer․lisp file, Previous: The trivial-renamer․asd file, Up: Lisp files [Contents][Index]
trivial-renamer (system)
package.lisp
Previous: The trivial-renamer/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
trivial-renamer (system)
trivial-renamer.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The trivial-renamer package |
package.lisp (file)
rename
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
trivial-renamer.lisp (file)
Next: Exported generic functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
clear the caches, leaving rules intact
trivial-renamer.lisp (file)
rename obj and return new name
trivial-renamer.lisp (file)
trivial-renamer.lisp (file)
add a rule for key appending or replacing
trivial-renamer.lisp (file)
Add a bunch of rules
trivial-renamer.lisp (file)
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
trivial-renamer.lisp (file)
ruler (class)
:default
(function trivial-renamer::default-rename-function)
default (generic function)
(setf default) (generic function)
:normal
(function trivial-renamer::default-rename-function)
normal (generic function)
(setf normal) (generic function)
:transform
(function trivial-renamer::default-transform)
transform (generic function)
(setf transform) (generic function)
old->new (generic function)
(setf old->new) (generic function)
new->old (generic function)
(setf new->old) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal functions | ||
• Internal generic functions | ||
• Internal classes |
Next: Internal generic functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
trivial-renamer.lisp (file)
trivial-renamer.lisp (file)
trivial-renamer.lisp (file)
trivial-renamer.lisp (file)
Next: Internal classes, Previous: Internal functions, Up: Internal definitions [Contents][Index]
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
automatically generated reader method
trivial-renamer.lisp (file)
automatically generated writer method
trivial-renamer.lisp (file)
Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
trivial-renamer.lisp (file)
standard-object (class)
renamer (class)
:test
(function equal)
test (generic function)
(setf test) (generic function)
:overwrite
t
overwrite (generic function)
(setf overwrite) (generic function)
:validate
(lambda (trivial-renamer::key trivial-renamer::val trivial-renamer::r) (declare (ignore trivial-renamer::key trivial-renamer::val trivial-renamer::r)))
validate (generic function)
(setf validate) (generic function)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L T |
---|
Jump to: | F L T |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
C D F G M N O P R T V |
---|
Jump to: | (
C D F G M N O P R T V |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
D N O S T V |
---|
Jump to: | *
D N O S T V |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P R S T |
---|
Jump to: | C P R S T |
---|