The cl-difflib Reference Manual

This is the cl-difflib Reference Manual, version 0.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 04:50:12 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-difflib

A Lisp library for computing differences between sequences.

Maintainer

John Wiseman <>

Author

John Wiseman <>

License

MIT

Long Description

A Lisp library for computing differences between sequences. Based on Python’s difflib module.

Version

0.2

Source

cl-difflib.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 cl-difflib/cl-difflib.asd

Source

cl-difflib.asd.

Parent Component

cl-difflib (system).

ASDF Systems

cl-difflib.


3.1.2 cl-difflib/package.lisp

Source

cl-difflib.asd.

Parent Component

cl-difflib (system).

Packages

difflib.


3.1.3 cl-difflib/difflib.lisp

Dependency

package.lisp (file).

Source

cl-difflib.asd.

Parent Component

cl-difflib (system).

Public Interface
Internals

3.2 Static


3.2.1 cl-difflib/LICENSE.txt

Source

cl-difflib.asd.

Parent Component

cl-difflib (system).


3.2.2 cl-difflib/NEWS.txt

Source

cl-difflib.asd.

Parent Component

cl-difflib (system).


4 Packages

Packages are listed by definition order.


4.1 difflib

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Ordinary functions

Function: context-diff (stream a b &key from-file to-file from-file-date to-file-date n test-function junk-function)
Package

difflib.

Source

difflib.lisp.

Function: get-close-matches (word possibilities &key max cutoff)
Package

difflib.

Source

difflib.lisp.

Function: group-opcodes (opcodes n)
Package

difflib.

Source

difflib.lisp.

Function: make-opcode (&key tag i1 i2 j1 j2)
Package

difflib.

Source

difflib.lisp.

Reader: opcode-i1 (instance)
Writer: (setf opcode-i1) (instance)
Package

difflib.

Source

difflib.lisp.

Target Slot

i1.

Reader: opcode-i2 (instance)
Writer: (setf opcode-i2) (instance)
Package

difflib.

Source

difflib.lisp.

Target Slot

i2.

Reader: opcode-j1 (instance)
Writer: (setf opcode-j1) (instance)
Package

difflib.

Source

difflib.lisp.

Target Slot

j1.

Reader: opcode-j2 (instance)
Writer: (setf opcode-j2) (instance)
Package

difflib.

Source

difflib.lisp.

Target Slot

j2.

Function: opcode-p (object)
Package

difflib.

Source

difflib.lisp.

Function: opcode-range (opcode)
Package

difflib.

Source

difflib.lisp.

Reader: opcode-tag (instance)
Writer: (setf opcode-tag) (instance)
Package

difflib.

Source

difflib.lisp.

Target Slot

tag.

Function: opcode= (op1 op2)

Tests two opcodes for equality.

Package

difflib.

Source

difflib.lisp.

Function: unified-diff (stream a b &key from-file to-file from-file-date to-file-date n test-function junk-function)
Package

difflib.

Source

difflib.lisp.


5.1.2 Generic functions

Generic Function: get-opcodes (matcher)
Package

difflib.

Source

difflib.lisp.

Methods
Method: get-opcodes ((self sequence-matcher))
Generic Reader: junk-function (object)
Package

difflib.

Methods
Reader Method: junk-function ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

junk-function.

Generic Writer: (setf junk-function) (object)
Package

difflib.

Methods
Writer Method: (setf junk-function) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

junk-function.

Generic Function: quick-similarity-ratio (matcher)
Package

difflib.

Source

difflib.lisp.

Methods
Method: quick-similarity-ratio ((self sequence-matcher))
Generic Reader: sequence-a (object)
Package

difflib.

Methods
Reader Method: sequence-a ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

a.

Generic Writer: (setf sequence-a) (object)
Package

difflib.

Methods
Writer Method: (setf sequence-a) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

a.

Generic Reader: sequence-b (object)
Package

difflib.

Methods
Reader Method: sequence-b ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

b.

Generic Writer: (setf sequence-b) (object)
Package

difflib.

Methods
Writer Method: (setf sequence-b) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

b.

Generic Function: set-sequence-a (matcher seq &optional force-p)
Package

difflib.

Source

difflib.lisp.

Methods
Method: set-sequence-a ((self sequence-matcher) a &optional force-p)
Generic Function: set-sequence-b (matcher seq &optional force-p)
Package

difflib.

Source

difflib.lisp.

Methods
Method: set-sequence-b ((self sequence-matcher) b &optional force-p)
Generic Function: set-sequences (matcher seq-a seq-b &optional force-p)
Package

difflib.

Source

difflib.lisp.

Methods
Method: set-sequences ((self sequence-matcher) a b &optional force-p)
Generic Function: similarity-ratio (matcher)
Package

difflib.

Source

difflib.lisp.

Methods
Method: similarity-ratio ((self sequence-matcher))

Returns a measure of the sequences’ similarity (a value in [0, 1]).

Generic Reader: test-function (object)
Package

difflib.

Methods
Reader Method: test-function ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

test-function.

Generic Writer: (setf test-function) (object)
Package

difflib.

Methods
Writer Method: (setf test-function) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

test-function.

Generic Function: very-quick-similarity-ratio (matcher)
Package

difflib.

Source

difflib.lisp.

Methods
Method: very-quick-similarity-ratio ((self sequence-matcher))

5.1.3 Standalone methods

Method: initialize-instance :after ((self sequence-matcher) &key)
Source

difflib.lisp.

Method: print-object ((self opcode) stream)
Source

difflib.lisp.


5.1.4 Structures

Structure: opcode

A single instruction for modifying sequence A into sequence B, where TAG has the following possible values and meanings:

:REPLACE a[i1:i2] should be replaced by b[j1:j2] :DELETE a[i1:i2] should be deleted
:INSERT b[j2:j2] should be inserted
:EQUAL a[i1:i2] = b[j1:j2]

Package

difflib.

Source

difflib.lisp.

Direct superclasses

structure-object.

Direct methods

print-object.

Direct slots
Slot: tag
Readers

opcode-tag.

Writers

(setf opcode-tag).

Slot: i1
Readers

opcode-i1.

Writers

(setf opcode-i1).

Slot: i2
Readers

opcode-i2.

Writers

(setf opcode-i2).

Slot: j1
Readers

opcode-j1.

Writers

(setf opcode-j1).

Slot: j2
Readers

opcode-j2.

Writers

(setf opcode-j2).


5.1.5 Classes

Class: sequence-matcher

The sequence-matcher class compares pairs of
sequences. The main restriction is that sequence elements must be hashable (use :test-function to specify the type of hashtable).

Package

difflib.

Source

difflib.lisp.

Direct methods
Direct slots
Slot: a
Initargs

:a

Readers

sequence-a.

Writers

(setf sequence-a).

Slot: b
Initargs

:b

Readers

sequence-b.

Writers

(setf sequence-b).

Slot: junk-function
Initargs

:junk-function

Readers

junk-function.

Writers

(setf junk-function).

Slot: test-function
Initform

(function eql)

Initargs

:test-function

Readers

test-function.

Writers

(setf test-function).

Slot: b-junk-function
Readers

b-junk-function.

Writers

(setf b-junk-function).

Slot: b2j
Readers

b2j.

Writers

(setf b2j).

Slot: b-popular-function
Readers

b-popular-function.

Writers

(setf b-popular-function).

Slot: opcodes
Readers

opcodes.

Writers

(setf opcodes).

Slot: matching-blocks
Readers

matching-blocks.

Writers

(setf matching-blocks).

Slot: full-b-count
Readers

full-b-count.

Writers

(setf full-b-count).


5.2 Internals


5.2.1 Macros

Macro: do-range ((var start-form end-form &optional result-form) &body body)

Iterates VAR through the range of integers in [START-FORM, END-FORM). Returns the value of END-FORM (at the time END-FORM is evaluated, VAR is bound to the value of END-FORM.

(do-range (i 10 (length s))
(print (elt s i)))

Package

difflib.

Source

difflib.lisp.

Macro: enumerate ((index-var elt-var sequence &optional result-form) &body body)

Iterates over a sequence while keeping track of an index.

(enumerate (i e ’(a b c))
(format T "~&~S ~S" i e))
=>
1 a
2 b
3 c

Package

difflib.

Source

difflib.lisp.


5.2.2 Ordinary functions

Function: calculate-similarity-ratio (matches length)
Package

difflib.

Source

difflib.lisp.

Function: copy-opcode (instance)
Package

difflib.

Source

difflib.lisp.

Function: has-key (key hash)

Checks whether a key value is present in a hash table.

Package

difflib.

Source

difflib.lisp.


5.2.3 Generic functions

Generic Reader: b-junk-function (object)
Package

difflib.

Methods
Reader Method: b-junk-function ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

b-junk-function.

Generic Writer: (setf b-junk-function) (object)
Package

difflib.

Methods
Writer Method: (setf b-junk-function) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

b-junk-function.

Generic Reader: b-popular-function (object)
Package

difflib.

Methods
Reader Method: b-popular-function ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

b-popular-function.

Generic Writer: (setf b-popular-function) (object)
Package

difflib.

Methods
Writer Method: (setf b-popular-function) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

b-popular-function.

Generic Reader: b2j (object)
Package

difflib.

Methods
Reader Method: b2j ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

b2j.

Generic Writer: (setf b2j) (object)
Package

difflib.

Methods
Writer Method: (setf b2j) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

b2j.

Generic Function: chain-b (matcher)
Package

difflib.

Source

difflib.lisp.

Methods
Method: chain-b ((self sequence-matcher))
Generic Function: find-longest-match (matcher alo ahi blo bhi)
Package

difflib.

Source

difflib.lisp.

Methods
Method: find-longest-match ((self sequence-matcher) alo ahi blo bhi)
Generic Reader: full-b-count (object)
Package

difflib.

Methods
Reader Method: full-b-count ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

full-b-count.

Generic Writer: (setf full-b-count) (object)
Package

difflib.

Methods
Writer Method: (setf full-b-count) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

full-b-count.

Generic Function: get-matching-blocks (matcher)
Package

difflib.

Source

difflib.lisp.

Methods
Method: get-matching-blocks ((self sequence-matcher))
Generic Function: helper (matcher alo ahi blo bhi answer)
Package

difflib.

Source

difflib.lisp.

Methods
Method: helper ((self sequence-matcher) alo ahi blo bhi answer)
Generic Reader: matching-blocks (object)
Package

difflib.

Methods
Reader Method: matching-blocks ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

matching-blocks.

Generic Writer: (setf matching-blocks) (object)
Package

difflib.

Methods
Writer Method: (setf matching-blocks) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

matching-blocks.

Generic Reader: opcodes (object)
Package

difflib.

Methods
Reader Method: opcodes ((sequence-matcher sequence-matcher))

automatically generated reader method

Source

difflib.lisp.

Target Slot

opcodes.

Generic Writer: (setf opcodes) (object)
Package

difflib.

Methods
Writer Method: (setf opcodes) ((sequence-matcher sequence-matcher))

automatically generated writer method

Source

difflib.lisp.

Target Slot

opcodes.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
B   C   D   E   F   G   H   I   J   M   O   P   Q   S   T   U   V  
Index Entry  Section

(
(setf b-junk-function): Private generic functions
(setf b-junk-function): Private generic functions
(setf b-popular-function): Private generic functions
(setf b-popular-function): Private generic functions
(setf b2j): Private generic functions
(setf b2j): Private generic functions
(setf full-b-count): Private generic functions
(setf full-b-count): Private generic functions
(setf junk-function): Public generic functions
(setf junk-function): Public generic functions
(setf matching-blocks): Private generic functions
(setf matching-blocks): Private generic functions
(setf opcode-i1): Public ordinary functions
(setf opcode-i2): Public ordinary functions
(setf opcode-j1): Public ordinary functions
(setf opcode-j2): Public ordinary functions
(setf opcode-tag): Public ordinary functions
(setf opcodes): Private generic functions
(setf opcodes): Private generic functions
(setf sequence-a): Public generic functions
(setf sequence-a): Public generic functions
(setf sequence-b): Public generic functions
(setf sequence-b): Public generic functions
(setf test-function): Public generic functions
(setf test-function): Public generic functions

B
b-junk-function: Private generic functions
b-junk-function: Private generic functions
b-popular-function: Private generic functions
b-popular-function: Private generic functions
b2j: Private generic functions
b2j: Private generic functions

C
calculate-similarity-ratio: Private ordinary functions
chain-b: Private generic functions
chain-b: Private generic functions
context-diff: Public ordinary functions
copy-opcode: Private ordinary functions

D
do-range: Private macros

E
enumerate: Private macros

F
find-longest-match: Private generic functions
find-longest-match: Private generic functions
full-b-count: Private generic functions
full-b-count: Private generic functions
Function, (setf opcode-i1): Public ordinary functions
Function, (setf opcode-i2): Public ordinary functions
Function, (setf opcode-j1): Public ordinary functions
Function, (setf opcode-j2): Public ordinary functions
Function, (setf opcode-tag): Public ordinary functions
Function, calculate-similarity-ratio: Private ordinary functions
Function, context-diff: Public ordinary functions
Function, copy-opcode: Private ordinary functions
Function, get-close-matches: Public ordinary functions
Function, group-opcodes: Public ordinary functions
Function, has-key: Private ordinary functions
Function, make-opcode: Public ordinary functions
Function, opcode-i1: Public ordinary functions
Function, opcode-i2: Public ordinary functions
Function, opcode-j1: Public ordinary functions
Function, opcode-j2: Public ordinary functions
Function, opcode-p: Public ordinary functions
Function, opcode-range: Public ordinary functions
Function, opcode-tag: Public ordinary functions
Function, opcode=: Public ordinary functions
Function, unified-diff: Public ordinary functions

G
Generic Function, (setf b-junk-function): Private generic functions
Generic Function, (setf b-popular-function): Private generic functions
Generic Function, (setf b2j): Private generic functions
Generic Function, (setf full-b-count): Private generic functions
Generic Function, (setf junk-function): Public generic functions
Generic Function, (setf matching-blocks): Private generic functions
Generic Function, (setf opcodes): Private generic functions
Generic Function, (setf sequence-a): Public generic functions
Generic Function, (setf sequence-b): Public generic functions
Generic Function, (setf test-function): Public generic functions
Generic Function, b-junk-function: Private generic functions
Generic Function, b-popular-function: Private generic functions
Generic Function, b2j: Private generic functions
Generic Function, chain-b: Private generic functions
Generic Function, find-longest-match: Private generic functions
Generic Function, full-b-count: Private generic functions
Generic Function, get-matching-blocks: Private generic functions
Generic Function, get-opcodes: Public generic functions
Generic Function, helper: Private generic functions
Generic Function, junk-function: Public generic functions
Generic Function, matching-blocks: Private generic functions
Generic Function, opcodes: Private generic functions
Generic Function, quick-similarity-ratio: Public generic functions
Generic Function, sequence-a: Public generic functions
Generic Function, sequence-b: Public generic functions
Generic Function, set-sequence-a: Public generic functions
Generic Function, set-sequence-b: Public generic functions
Generic Function, set-sequences: Public generic functions
Generic Function, similarity-ratio: Public generic functions
Generic Function, test-function: Public generic functions
Generic Function, very-quick-similarity-ratio: Public generic functions
get-close-matches: Public ordinary functions
get-matching-blocks: Private generic functions
get-matching-blocks: Private generic functions
get-opcodes: Public generic functions
get-opcodes: Public generic functions
group-opcodes: Public ordinary functions

H
has-key: Private ordinary functions
helper: Private generic functions
helper: Private generic functions

I
initialize-instance: Public standalone methods

J
junk-function: Public generic functions
junk-function: Public generic functions

M
Macro, do-range: Private macros
Macro, enumerate: Private macros
make-opcode: Public ordinary functions
matching-blocks: Private generic functions
matching-blocks: Private generic functions
Method, (setf b-junk-function): Private generic functions
Method, (setf b-popular-function): Private generic functions
Method, (setf b2j): Private generic functions
Method, (setf full-b-count): Private generic functions
Method, (setf junk-function): Public generic functions
Method, (setf matching-blocks): Private generic functions
Method, (setf opcodes): Private generic functions
Method, (setf sequence-a): Public generic functions
Method, (setf sequence-b): Public generic functions
Method, (setf test-function): Public generic functions
Method, b-junk-function: Private generic functions
Method, b-popular-function: Private generic functions
Method, b2j: Private generic functions
Method, chain-b: Private generic functions
Method, find-longest-match: Private generic functions
Method, full-b-count: Private generic functions
Method, get-matching-blocks: Private generic functions
Method, get-opcodes: Public generic functions
Method, helper: Private generic functions
Method, initialize-instance: Public standalone methods
Method, junk-function: Public generic functions
Method, matching-blocks: Private generic functions
Method, opcodes: Private generic functions
Method, print-object: Public standalone methods
Method, quick-similarity-ratio: Public generic functions
Method, sequence-a: Public generic functions
Method, sequence-b: Public generic functions
Method, set-sequence-a: Public generic functions
Method, set-sequence-b: Public generic functions
Method, set-sequences: Public generic functions
Method, similarity-ratio: Public generic functions
Method, test-function: Public generic functions
Method, very-quick-similarity-ratio: Public generic functions

O
opcode-i1: Public ordinary functions
opcode-i2: Public ordinary functions
opcode-j1: Public ordinary functions
opcode-j2: Public ordinary functions
opcode-p: Public ordinary functions
opcode-range: Public ordinary functions
opcode-tag: Public ordinary functions
opcode=: Public ordinary functions
opcodes: Private generic functions
opcodes: Private generic functions

P
print-object: Public standalone methods

Q
quick-similarity-ratio: Public generic functions
quick-similarity-ratio: Public generic functions

S
sequence-a: Public generic functions
sequence-a: Public generic functions
sequence-b: Public generic functions
sequence-b: Public generic functions
set-sequence-a: Public generic functions
set-sequence-a: Public generic functions
set-sequence-b: Public generic functions
set-sequence-b: Public generic functions
set-sequences: Public generic functions
set-sequences: Public generic functions
similarity-ratio: Public generic functions
similarity-ratio: Public generic functions

T
test-function: Public generic functions
test-function: Public generic functions

U
unified-diff: Public ordinary functions

V
very-quick-similarity-ratio: Public generic functions
very-quick-similarity-ratio: Public generic functions