[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion aa9bea48ba 022/313: fix position
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion aa9bea48ba 022/313: fix position |
Date: |
Sat, 3 Dec 2022 10:59:12 -0500 (EST) |
branch: elpa/bash-completion
commit aa9bea48ba60c08ca0187e3b515f099d3740604f
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
fix position
---
bash-completion.el | 21 ++++++++++++++-------
bash-completion_test.el | 36 ++++++++++++++++++++++--------------
2 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 43fe828745..9f1bbd9662 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -58,9 +58,10 @@ Call bash to do the completion."
(setq cword (car wordsplit))
(setq words (cdr wordsplit))
(setq stub (nth cword words)))
- (comint-dynamic-simple-complete
- stub
- (bash-completion-comm line (- pos start) words cword))))
+ (let ((completions (bash-completion-comm line (- pos start) words cword)))
+ (comint-dynamic-simple-complete
+ stub
+ completions))))
(defun bash-completion-line-beginning-position (&optional start)
(save-excursion
@@ -95,6 +96,9 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
(goto-char start)
(let ((accum (cons nil nil)))
(setq accum (bash-completion-split-0 start end pos accum ""))
+ (when (and (not (null pos)) (null (car accum)))
+ (setcar accum (length (cdr accum)))
+ (setcdr accum (cons "" (cdr accum))))
(cons (car accum) (nreverse (cdr accum))))))
(defun bash-completion-split-0 (start end pos accum straccum)
@@ -107,6 +111,9 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
(defun bash-completion-split-1 (start end pos quote accum straccum)
(let ((local-start (point)))
+ (when (and (null (car accum)) (not (null pos)) (<= pos local-start))
+ (setcar accum (length (cdr accum)))
+ (setcdr accum (cons "" (cdr accum))))
(skip-chars-forward (bash-completion-nonsep quote) end)
(setq straccum (concat straccum (buffer-substring-no-properties
local-start (point)))))
(cond
@@ -132,11 +139,11 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
(concat straccum (char-to-string (char-before)))))
;; word end
(t
+ (when (and (null (car accum)) (not (null pos)) (<= pos (point)))
+ (setcar accum (length (cdr accum))))
(skip-chars-forward " \t\n\r" end)
(when (> (length straccum) 0)
- (setcdr accum (cons straccum (cdr accum)))
- (when (and (not (car accum)) (> pos 0) (<= pos (point)))
- (setcar accum (- (length (cdr accum)) 1))))
+ (setcdr accum (cons straccum (cdr accum))))
(if (< (point) end)
(bash-completion-split-0 (point) end pos accum "")
accum))))
@@ -270,7 +277,7 @@ Return `bash-completion-alist'."
(goto-char (point-max))
(while (= 0 (forward-line -1))
(bash-completion-add-to-alist
- (cdr (bash-completion-split (line-beginning-position)
(line-end-position) 0))))))
+ (cdr (bash-completion-split (line-beginning-position)
(line-end-position) nil))))))
bash-completion-alist)
(defun bash-completion-add-to-alist (words)
diff --git a/bash-completion_test.el b/bash-completion_test.el
index 64ef657b90..046368853c 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -43,49 +43,49 @@
("bash-completion-split simple"
(sz-testutils-with-buffer
'("a hello world b c")
- (bash-completion-split 1 (line-end-position) 0))
+ (bash-completion-split 1 (line-end-position) nil))
'(nil . ("a" "hello" "world" "b" "c")))
("bash-completion-split simple extra spaces"
(sz-testutils-with-buffer
'(" a hello \n world \t b \r c ")
- (bash-completion-split 1 (line-end-position 2) 0))
+ (bash-completion-split 1 (line-end-position 2) nil))
'(nil . ("a" "hello" "world" "b" "c")))
("bash-completion-split escaped space"
(sz-testutils-with-buffer
'("a hello\\ world b c")
- (bash-completion-split 1 (line-end-position) 0))
+ (bash-completion-split 1 (line-end-position) nil))
'(nil . ("a" "hello world" "b" "c")))
("bash-completion-split double quotes"
(sz-testutils-with-buffer
'("a \"hello world\" b c")
- (bash-completion-split 1 (line-end-position) 0))
+ (bash-completion-split 1 (line-end-position) nil))
'(nil . ("a" "hello world" "b" "c")))
("bash-completion-split double quotes escaped"
(sz-testutils-with-buffer
'("a \"-\\\"hello world\\\"-\" b c")
- (bash-completion-split 1 (line-end-position) 0))
+ (bash-completion-split 1 (line-end-position) nil))
'(nil . ("a" "-\"hello world\"-" "b" "c")))
("bash-completion-split single quotes"
(sz-testutils-with-buffer
'("a \"hello world\" b c")
- (bash-completion-split 1 (line-end-position) 0))
+ (bash-completion-split 1 (line-end-position) nil))
'(nil . ("a" "hello world" "b" "c")))
("bash-completion-split single quotes escaped"
(sz-testutils-with-buffer
'("a '-\\'hello world\\'-' b c")
- (bash-completion-split 1 (line-end-position) 0))
+ (bash-completion-split 1 (line-end-position) nil))
'(nil . ("a" "-'hello world'-" "b" "c")))
("bash-completion-split complex quote mix"
(sz-testutils-with-buffer
'("a hel\"lo w\"o'rld b'c d")
- (bash-completion-split 1 (line-end-position) 0))
+ (bash-completion-split 1 (line-end-position) nil))
'(nil . ("a" "hello world bc" "d")))
("bash-completion-split cursor at end of word"
@@ -104,13 +104,25 @@
(sz-testutils-with-buffer
'(" " cursor " a hello world b c")
(bash-completion-split 1 (line-end-position) (point)))
- '(0 . ("a" "hello" "world" "b" "c")))
+ '(0 . ("" "a" "hello" "world" "b" "c")))
("bash-completion-split cursor in the middle"
(sz-testutils-with-buffer
'("a hello " cursor " world b c")
(bash-completion-split 1 (line-end-position) (point)))
- '(1 . ("a" "hello" "world" "b" "c")))
+ '(2 . ("a" "hello" "" "world" "b" "c")))
+
+ ("bash-completion-split cursor at end"
+ (sz-testutils-with-buffer
+ '("a hello world b c" cursor)
+ (bash-completion-split 1 (line-end-position) (point)))
+ '(4 . ("a" "hello" "world" "b" "c")))
+
+ ("bash-completion-split cursor after end"
+ (sz-testutils-with-buffer
+ '("a hello world b c " cursor)
+ (bash-completion-split 1 (line-end-position) (point)))
+ '(5 . ("a" "hello" "world" "b" "c" "")))
("bash-completion-add-to-alist garbage"
(let ((bash-completion-alist nil))
@@ -191,10 +203,6 @@ garbage
(bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1))
"cd /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\'';
COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F
__bash_complete_wrapper -- worl")
- ("bash-completion-trim"
- (mapcar 'bash-completion-trim '(" hello " " world " "x"))
- '("hello" "world" "x"))
-
("bash-completion-line-beginning-position start"
(sz-testutils-with-buffer
"cd /home/x"
- [nongnu] elpa/bash-completion 72e9fce93d 291/313: Properly apply filter passed to the dynamic completion function., (continued)
- [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
- [nongnu] elpa/bash-completion 8e9c20dbfe 313/313: Replace or quote certain single quotes in docstrings (#55), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion aa9bea48ba 022/313: fix position,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 6aedd69000 164/313: Delete duplicates when extracting candidates. fixes #26, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 58447c67bf 206/313: Merge the send functions, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d6c28d3132 302/313: Add a troubleshooting section to README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d550256e3f 306/313: Disable flakey test for now., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a8f7de1e91 173/313: Merge remote-tracking branch 'montag451/remote-shell-support-rebase', ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9521f79b33 176/313: Display the emacs command run by the tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fc3f762d16 177/313: Track and support options -o default, filenames and nospace., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c6df9be78d 182/313: Store the alist as process property., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fefe5ae88e 191/313: Introduce bash-completion-remote-prog., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d99ad71050 199/313: Add a new option to disable the use of separate processes to perform completion, ELPA Syncer, 2022/12/03