[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/flx 4cd6d9c9e4 078/182: flx: require cl-lib; avoid ugly ev
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/flx 4cd6d9c9e4 078/182: flx: require cl-lib; avoid ugly eval-when-compile |
Date: |
Tue, 13 Dec 2022 03:59:32 -0500 (EST) |
branch: elpa/flx
commit 4cd6d9c9e4524b66a6b4ee76d2b7679c5c7d2376
Author: Ramkumar Ramachandra <artagnon@gmail.com>
Commit: Ramkumar Ramachandra <artagnon@gmail.com>
flx: require cl-lib; avoid ugly eval-when-compile
Also prefix various functions with "cl-", and add a Package-Requires
header.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
flx.el | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/flx.el b/flx.el
index 301e4a2bb4..b3a2f5cc3f 100644
--- a/flx.el
+++ b/flx.el
@@ -7,6 +7,7 @@
;; Description: fuzzy matching with good sorting
;; Created: Wed Apr 17 01:01:41 2013 (+0800)
;; Version: 0.1
+;; Package-Requires: ((cl-lib "0.3"))
;; URL: https://github.com/lewang/flx
;; This file is NOT part of GNU Emacs.
@@ -49,7 +50,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defface flx-highlight-face '((t (:inherit font-lock-variable-name-face :bold
t :underline t)))
"Face used by flx for highlighting flx match characters."
@@ -62,7 +63,7 @@
(let* ((res (make-hash-table :test 'eq :size 32))
(str-len (length str))
char)
- (loop for index from (1- str-len) downto 0
+ (cl-loop for index from (1- str-len) downto 0
do (progn
(setq char (downcase (aref str index)))
(push index (gethash char res))))
@@ -102,8 +103,8 @@ from BEG (inclusive) to end (not inclusive).
(or end
(setq end (length vec)))
(while (< beg end)
- (incf (aref vec beg) inc)
- (incf beg))
+ (cl-incf (aref vec beg) inc)
+ (cl-incf beg))
vec)
;; So we store one fixnum per character. Is this too memory inefficient?
@@ -118,9 +119,9 @@ See documentation for logic."
(penalty-lead ?.)
(groups-alist (list (list -1 0))))
;; ++++ final char bonus
- (incf (aref scores str-last-index) 1)
+ (cl-incf (aref scores str-last-index) 1)
;; Establish baseline mapping
- (loop for char across str
+ (cl-loop for char across str
for index from 0
with last-char = nil
with group-word-count = 0
@@ -131,13 +132,13 @@ See documentation for logic."
;; gets penalized compared to "foo/ab".
(if (zerop group-word-count) nil last-char)))
(when (flx-boundary-p effective-last-char char)
- (setcdr (cdar groups-alist) (cons index (cddar
groups-alist))))
+ (setcdr (cdar groups-alist) (cons index (cl-cddar
groups-alist))))
(when (and (not (flx-word-p last-char))
(flx-word-p char))
- (incf group-word-count)))
+ (cl-incf group-word-count)))
;; ++++ -45 penalize extension
(when (eq last-char penalty-lead)
- (incf (aref scores index) -45))
+ (cl-incf (aref scores index) -45))
(when (eq group-separator char )
(setcar (cdar groups-alist) group-word-count)
(setq group-word-count 0)
@@ -151,7 +152,7 @@ See documentation for logic."
(unless (zerop separator-count)
(flx-inc-vec scores (* -2 group-count)))
;; score each group further
- (loop for group in groups-alist
+ (cl-loop for group in groups-alist
for index from separator-count downto 0
with last-group-limit = nil
with basepath-found = nil
@@ -179,17 +180,17 @@ See documentation for logic."
-3
(+ -5 (1- index)))))
(flx-inc-vec scores num (1+ group-start) last-group-limit))
- (loop for word in (cddr group)
+ (cl-loop for word in (cddr group)
for word-index from (1- words-length) downto 0
with last-word = (or last-group-limit
str-len)
do (progn
- (incf (aref scores word)
+ (cl-incf (aref scores word)
;; ++++ beg word bonus AND
85)
- (loop for index from word below last-word
+ (cl-loop for index from word below last-word
for char-i from 0
- do (incf (aref scores index)
+ do (cl-incf (aref scores index)
(-
;; ++++ word order penalty
(* -3 word-index)
@@ -209,9 +210,9 @@ See documentation for logic."
if VAL is nil, return entire list."
(if val
- (loop for sub on sorted-list
+ (cl-loop for sub on sorted-list
do (when (> (car sub) val)
- (return sub)))
+ (cl-return sub)))
sorted-list))
(defun flx-get-matches (hash query &optional greater-than q-index)
@@ -289,15 +290,15 @@ e.g. (\"aab\" \"ab\") returns
0))
(contiguous-count 0)
last-match)
- (loop for index in match-positions
+ (cl-loop for index in match-positions
do (progn
(if (and last-match
(= (1+ last-match) index))
- (incf contiguous-count)
+ (cl-incf contiguous-count)
(setq contiguous-count 0))
- (incf score (aref heatmap index))
+ (cl-incf score (aref heatmap index))
(when (> contiguous-count 0)
- (incf score (+ 45 (* 15 (min contiguous-count
4)))))
+ (cl-incf score (+ 45 (* 15 (min contiguous-count
4)))))
(setq last-match index)))
(if (or (null best-score)
(> score (car best-score)))
@@ -317,7 +318,7 @@ SCORE of nil means to clear the properties."
(substring-no-properties obj))))
(unless (null score)
- (loop for char in (cdr score)
+ (cl-loop for char in (cdr score)
do (progn
(when (and last-char
(not (= (1+ last-char) char)))
- [nongnu] elpa/flx a1ac8f97ec 034/182: fix `ido-merge-work-directories`, (continued)
- [nongnu] elpa/flx a1ac8f97ec 034/182: fix `ido-merge-work-directories`, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx f068b2bc1f 056/182: Improve the formatting of the README and extend it a bit, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 1df93b286a 060/182: comment clarification, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a15638e403 064/182: Merge pull request #26 from bbatsov/master, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx c41f9f5087 065/182: reorder README sections, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx d77b703c37 069/182: Merge pull request #28 from bbatsov/marmalade, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 0c41fc616d 072/182: update package install instrucations, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx ce2d375f82 073/182: Makefile: introduce all, clean targets, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx e24352a502 074/182: add usage information, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 6800cc34a9 076/182: flx-ido: fix comment in advice for ido-set-matches-1, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 4cd6d9c9e4 078/182: flx: require cl-lib; avoid ugly eval-when-compile,
ELPA Syncer <=
- [nongnu] elpa/flx 569beec178 080/182: Merge pull request #39 from artagnon/minor-cleanups, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 2903e5d2a7 084/182: Merge pull request #42 from bbatsov/byte-compile-warning, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 9440288782 086/182: Refactor to make prefix match clear., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a1fef07104 087/182: Fix C-k to kill buffer at head., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 12589211c6 088/182: Implement case-fold searching, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 80bb88c32f 092/182: Clean test .elcs but never compile them., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 5591055c33 093/182: Recommend enabling ido-flex., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 48ebd6c857 094/182: Make prefix-matchine one way., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 1f46d67762 096/182: Update big list experiment., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx df036210c6 098/182: Switch to 24.4 delete dup runs algorithm., ELPA Syncer, 2022/12/13