[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 8f877dc2ce 287/313: Let bash compute COMP_
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 8f877dc2ce 287/313: Let bash compute COMP_POINT, always at the end of COMP_LINE. |
Date: |
Sat, 3 Dec 2022 10:59:38 -0500 (EST) |
branch: elpa/bash-completion
commit 8f877dc2ce9d749bf616c295a22d170582e13a97
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Let bash compute COMP_POINT, always at the end of COMP_LINE.
This change simplifies the code and also avoids issues in situations
where Emacs and Bash have a different idea of what the character count
should be, when using multibyte encodings.
---
bash-completion.el | 5 +----
test/bash-completion-test.el | 22 ++--------------------
2 files changed, 3 insertions(+), 24 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index a73324af48..8acb540ed7 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -276,7 +276,6 @@ Bash processes.")
(:conc-name bash-completion--)
(:copier nil))
line ; the relevant command (string)
- point ; 0-based position of the cursor in line (number)
words ; line split into words, unescaped (list of strings)
cword ; 0-based index of the word to be completed in words (number)
unparsed-stub ; unparsed version of the thing we are completing,
@@ -629,7 +628,6 @@ Returns a completion struct."
(cdr (assq 'str (car (last line-tokens)))))))
(bash-completion--make
:line rebuilt-line
- :point (length rebuilt-line)
:cword (- (length words) 1)
:words words
:stub-start stub-start
@@ -1336,9 +1334,8 @@ completion candidates."
(setcar (cdr function) "__emacs_complete_wrapper")
(format "__EMACS_COMPLETE_WRAPPER=%s compgen %s -- %s"
(bash-completion-quote
- (format "COMP_LINE=%s; COMP_POINT=%s; COMP_CWORD=%s;
COMP_WORDS=( %s ); %s %s %s %s"
+ (format "COMP_LINE=%s; COMP_POINT=$(( 1 + ${#COMP_LINE} ));
COMP_CWORD=%s; COMP_WORDS=( %s ); %s %s %s %s"
(bash-completion-quote (bash-completion--line comp))
- (bash-completion--point comp)
(bash-completion--cword comp)
(bash-completion-join (bash-completion--words comp))
(bash-completion-quote function-name)
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index a7c0b1618e..c88fc36cc1 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -145,7 +145,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "a hello world"
- :point 13
:cword 2
:words '("a" "hello" "world")
:stub-start 9
@@ -160,7 +159,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "a hello "
- :point 8
:cword 2
:words '("a" "hello" "")
:stub-start 9
@@ -175,7 +173,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "make -"
- :point 6
:cword 1
:words '("make" "-")
:stub-start 27
@@ -190,7 +187,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "sort -"
- :point 6
:cword 1
:words '("sort" "-")
:stub-start 20
@@ -205,7 +201,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "find -name '*.txt' -exec echo {} ';' -"
- :point 38
:cword 7
:words '("find" "-name" "*.txt" "-exec" "echo" "{}" ";" "-")
:stub-start 38
@@ -220,7 +215,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "ZORG=t"
- :point 6
:cword 0
:words '("ZORG=t")
:stub-start 24
@@ -235,7 +229,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "export PATH=/bin:/usr/bi"
- :point 24
:cword 1
:words '("export" "PATH=/bin:/usr/bi")
:stub-start 18
@@ -250,7 +243,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "export PATH=/bin:/usr/bi"
- :point 24
:cword 5
:words '("export" "PATH" "=" "/bin" ":" "/usr/bi")
:stub-start 18
@@ -265,7 +257,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "cd /vcr/shows/Dexter's"
- :point 22
:cword 1
:words '("cd" "/vcr/shows/Dexter's")
:stub-start 4
@@ -280,7 +271,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "cd /vcr/shows/Dexter's"
- :point 22
:cword 1
:words '("cd" "/vcr/shows/Dexter's")
:stub-start 4
@@ -295,7 +285,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "cd /vcr/shows/Dexter's"
- :point 22
:cword 1
:words '("cd" "/vcr/shows/Dexter's")
:stub-start 4
@@ -311,7 +300,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line "cd /vcr/shows/Dexter's"
- :point 22
:cword 1
:words '("cd" "/vcr/shows/Dexter's")
:stub-start 4
@@ -327,7 +315,6 @@ The return value is the one returned by BODY."
(should (equal
(bash-completion--make
:line ""
- :point 0
:cword 0
:words '("")
:stub-start 2
@@ -380,7 +367,6 @@ garbage
(bash-completion-generate-line
(bash-completion--make
:line "hello worl"
- :point 7
:words '("hello" "worl")
:stub "worl"
:unparsed-stub "worl"
@@ -392,7 +378,6 @@ garbage
(bash-completion-generate-line
(bash-completion--make
:line "zorg worl"
- :point 7
:words '("zorg" "worl")
:stub "worl"
:unparsed-stub "worl"
@@ -404,14 +389,13 @@ garbage
(concat
"cd >/dev/null 2>&1 /test && "
"__EMACS_COMPLETE_WRAPPER='COMP_LINE='\\''zorg blah worl'\\''; "
- "COMP_POINT=12; COMP_CWORD=2; "
+ "COMP_POINT=$(( 1 + ${#COMP_LINE} )); COMP_CWORD=2; "
"COMP_WORDS=( zorg blah worl ); "
"__zorg zorg worl blah' "
"compgen -F __emacs_complete_wrapper -- worl 2>/dev/null")
(bash-completion-generate-line
(bash-completion--make
:line "zorg blah worl"
- :point 12
:words '("zorg" "blah" "worl")
:cword 2
:stub "worl"
@@ -423,7 +407,7 @@ garbage
(concat
"cd >/dev/null 2>&1 /test && "
"__EMACS_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; "
- "COMP_POINT=7; "
+ "COMP_POINT=$(( 1 + ${#COMP_LINE} )); "
"COMP_CWORD=1; "
"COMP_WORDS=( zorg worl ); "
"__zorg zorg worl zorg' "
@@ -431,7 +415,6 @@ garbage
(bash-completion-generate-line
(bash-completion--make
:line "zorg worl"
- :point 7
:words '("zorg" "worl")
:cword 1
:stub "worl"
@@ -444,7 +427,6 @@ garbage
(bash-completion-generate-line
(bash-completion--make
:line "worl"
- :point 7
:words '("worl")
:cword 0
:stub "worl"
- [nongnu] elpa/bash-completion 79ce50bec9 262/313: Update README.md title, (continued)
- [nongnu] elpa/bash-completion 79ce50bec9 262/313: Update README.md title, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5e623ac270 275/313: Revert "Add test cases for TRAMP shell.", ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 702859f319 278/313: Cleanup strings containing bash commands., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 19d4fec42f 280/313: Use && instead of ; after cd, so completion fails if cd fails., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c584d4936b 281/313: Explicitly ignore error from the history command., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion de033933bd 282/313: Chain function definitions with && during setup., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e24a596631 283/313: Make integration tests stabler., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 51c7770758 284/313: Fix and update README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c6decb1d6c 285/313: Avoid escaping all non-ASCII characters., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4c216c4eea 286/313: Add an integration test to cover multiple completion results., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8f877dc2ce 287/313: Let bash compute COMP_POINT, always at the end of COMP_LINE.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 377969faa7 288/313: Fix typos in README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 72e9fce93d 291/313: Properly apply filter passed to the dynamic completion function., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 35d38fd3dc 295/313: Workaround for output containing \r\n instead of \n., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 666244383e 296/313: Workaround for command-line being echoed., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abb72c36b8 297/313: Merge branch 'master' of github.com:szermatt/emacs-bash-completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e35943f37e 299/313: Fix backward-compatibility issue on 24.3: avoid using alist-get., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abbe3bc268 301/313: Cleanup implementation of bash-completion-debug., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ca4fbce016 305/313: Turn off bash completion when non-bash prompts are detected., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abe93ae2f6 308/313: Fix whitespace (#47), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion df635e79fd 310/313: Replace deprecated `cl` package with `cl-lib` (#50), ELPA Syncer, 2022/12/03