[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 583d1dde61 151/313: Remove usage of seq-po
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 583d1dde61 151/313: Remove usage of seq-position with a custom implementation. |
Date: |
Sat, 3 Dec 2022 10:59:25 -0500 (EST) |
branch: elpa/bash-completion
commit 583d1dde611c513aa81a0165e809e8d5bafb915a
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Remove usage of seq-position with a custom implementation.
seq.el isn't available in older emacs versions.
---
bash-completion-test.el | 6 ++++++
bash-completion.el | 20 +++++++++++++-------
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/bash-completion-test.el b/bash-completion-test.el
old mode 100644
new mode 100755
index cde751e50b..1ef90ac66c
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -361,6 +361,12 @@ garbage
(default-directory "/test"))
(bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1
nil)))))
+(ert-deftest bash-completion--find-last-test ()
+ (should (equal nil (bash-completion--find-last ?a "xxxxx")))
+ (should (equal 3 (bash-completion--find-last ?d "abcdef")))
+ (should (equal 5 (bash-completion--find-last ?f "abcdef")))
+ (should (equal 9 (bash-completion--find-last ?d "abcdefabcdef"))))
+
(ert-deftest bash-completion-generate-list-test ()
;; empty str
(should (equal nil
diff --git a/bash-completion.el b/bash-completion.el
index ca15281907..da211ed8fb 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -373,22 +373,28 @@ This function is not meant to be called outside of
(after-wordbreak (nth 1 wordbreak-split))
(separator (nth 2 wordbreak-split))
(unparsed-stub (buffer-substring-no-properties stub-start pos))
- ;; separator-pos-in-unparsed finds the same separator that
- ;; was used for the split in unparsed-stub.
- (separator-pos-in-unparsed
- (- (length unparsed-stub)
- (or (seq-position (reverse unparsed-stub) separator) 0)))
+ (after-wordbreak-in-unparsed-pos
+ (1+ (or (bash-completion--find-last separator unparsed-stub) -1)))
(unparsed-after-wordbreak
(substring unparsed-stub
- separator-pos-in-unparsed
+ after-wordbreak-in-unparsed-pos
(length unparsed-stub))))
(when (> (length before-wordbreak) 0)
- (list (+ stub-start separator-pos-in-unparsed)
+ (list (+ stub-start after-wordbreak-in-unparsed-pos)
pos
(bash-completion--default-completion
after-wordbreak unparsed-after-wordbreak
open-quote 'wordbreak)))))
+(defun bash-completion--find-last (elt array)
+ "Return the position of the last intance of ELT in array or nil."
+ (catch 'bash-completion-return
+ (let ((array-len (length array)))
+ (dotimes (index array-len)
+ (if (eq elt (aref array (- array-len index 1)))
+ (throw 'bash-completion-return (- array-len index 1)))))
+ nil))
+
(defun bash-completion--default-completion
(stub unparsed-stub open-quote completion-type)
"Do default completion on the given STUB.
- [nongnu] elpa/bash-completion 3f86d75644 064/313: Trim strange results that are a subset of the current value, (continued)
- [nongnu] elpa/bash-completion 3f86d75644 064/313: Trim strange results that are a subset of the current value, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7f4bcd03a8 110/313: Avoid cluttering .bash_history with commands from, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c8ddd11ec3 113/313: Fix tests after "Make bash-completion.el work, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d2745d8923 114/313: Extended history, added a pointer to github, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6413d662ba 116/313: Rewrote the tests using ert instead of regress., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d65f7e018d 118/313: Skip integration tests if /bin/bash is not executable., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ec557d8949 123/313: shell-command.el is unnecessary, and has probably been so for years..., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 318e32979f 135/313: Display completion progress message only if completion takes too long., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2378b04eeb 140/313: More easily call bash-completion-dynamic-complete-nocomint, faking bash, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 43348d0be1 143/313: Bugfixes: remove references to nonexistent variables, such as, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 583d1dde61 151/313: Remove usage of seq-position with a custom implementation.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 664452aca2 157/313: Merge pull request #22 from kfogel/21-fix-completion-re-21149fdc, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ad8d72c626 162/313: README nit pick ; ), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c494a89070 168/313: Run tests under Emacs 24.1: alias letf to cl-letf., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f523a290a6 169/313: Make the integration tests run on Emacs 24.1., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion bbff4fa527 172/313: Merge branch 'master' of github.com:szermatt/emacs-bash-completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b307dc24c3 005/313: keep cword, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a79137cc86 004/313: escaped quotes, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 581864111e 039/313: integration test harness, process buffer cleanup, hidden buffer, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3e1481741c 031/313: remove messages, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0d360a45cd 017/313: fixed test case, ELPA Syncer, 2022/12/03