[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/typo a1c54f44e5 07/18: Summary: Allow for 'typo-level'
From: |
ELPA Syncer |
Subject: |
[elpa] externals/typo a1c54f44e5 07/18: Summary: Allow for 'typo-level' to be a function |
Date: |
Sun, 26 Mar 2023 08:01:31 -0400 (EDT) |
branch: externals/typo
commit a1c54f44e54e5e5abc20fd3c41422d24d369e195
Author: Philip Kaludercic <philip.kaludercic@fau.de>
Commit: Philip Kaludercic <philip.kaludercic@fau.de>
Summary: Allow for 'typo-level' to be a function
---
typo.el | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/typo.el b/typo.el
index 3407b2d232..9a172fc8f9 100644
--- a/typo.el
+++ b/typo.el
@@ -4,7 +4,7 @@
;; Author: Philip Kaludercic <philip.kaludercic@fau.de>
;; URL: https://wwwcip.cs.fau.de/~oj14ozun/src+etc/typo.el
-;; Version: $Id: typo.el,v 1.5 2023/01/15 12:49:56 oj14ozun Exp oj14ozun $
+;; Version: $Id: typo.el,v 1.6 2023/01/18 19:34:42 oj14ozun Exp oj14ozun $
;; Package-Requires: ((emacs "27.1"))
;; Package-Version: 1
;; Keywords: convenience
@@ -44,8 +44,11 @@
:group 'minibuffer)
(defcustom typo-level 8
- "Number of edits from the current word to a completion."
- :type 'natnum)
+ "Number of edits from the current word to a completion.
+Optionally this option may also be a function, that takes a
+number (indicating the length of the input) and returns a number
+indicating the maximal number of permitted typos."
+ :type '(choice function natnum))
(defcustom typo-shrink 1
"Number of characters a word may shrink."
@@ -58,8 +61,20 @@
(define-inline typo--test (word key)
(inline-letevals (word key)
(inline-quote
- (and (<= (string-distance ,word ,key) typo-level)
- (<= (- typo-shrink) (- (length ,word) (length ,key)) typo-expand)))))
+ (let* ((len-word (length ,word))
+ (len-key (length ,key))
+ (typo-level
+ (cond
+ ((functionp typo-level)
+ (ceiling (funcall typo-level len-word)))
+ ((natnump typo-level)
+ typo-level)
+ ((error "Invalid `typo-level' %S" typo-level)))))
+ (and (<= (- typo-shrink)
+ (- len-word len-key)
+ typo-expand)
+ (<= (string-distance ,word ,key)
+ typo-level))))))
(defun typo-edits (word collection pred)
"Generate a list of all multi-edit typos of WORD.
- [elpa] branch externals/typo created (now 281c9049c1), ELPA Syncer, 2023/03/26
- [elpa] externals/typo 88e9e7cd47 05/18: Summary: Document PRED in 'typo-{all, try}-completion', ELPA Syncer, 2023/03/26
- [elpa] externals/typo a1c54f44e5 07/18: Summary: Allow for 'typo-level' to be a function,
ELPA Syncer <=
- [elpa] externals/typo 5be4704665 09/18: Update headers for Sourcehut, ELPA Syncer, 2023/03/26
- [elpa] externals/typo c0283a403d 08/18: Summary: Set 'typo-level' to 'sqrt' by default, ELPA Syncer, 2023/03/26
- [elpa] externals/typo dde7825cc0 06/18: Summary: Check functionp before listp, ELPA Syncer, 2023/03/26
- [elpa] externals/typo db35f44b9a 01/18: Initial revision, ELPA Syncer, 2023/03/26
- [elpa] externals/typo e259ccabfb 15/18: Add a .gitignore, ELPA Syncer, 2023/03/26
- [elpa] externals/typo 281c9049c1 18/18: Bump version to 1.0.1 for GNU ELPA, ELPA Syncer, 2023/03/26
- [elpa] externals/typo 6c5e695ec2 13/18: Add licensing information, ELPA Syncer, 2023/03/26
- [elpa] externals/typo ffcd6d1d52 16/18: Add more links to the introductory README paragraph, ELPA Syncer, 2023/03/26
- [elpa] externals/typo ecec5009b5 10/18: Add user option 'typo-support-all-completions', ELPA Syncer, 2023/03/26
- [elpa] externals/typo f68cc15541 04/18: Summary: Add a "Package-Requires" header, ELPA Syncer, 2023/03/26