[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 7dc290e1c7 003/313: exclude quotes from re
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 7dc290e1c7 003/313: exclude quotes from result |
Date: |
Sat, 3 Dec 2022 10:58:59 -0500 (EST) |
branch: elpa/bash-completion
commit 7dc290e1c7e14e25f7ec77cc4932f3eb0f053984
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
exclude quotes from result
---
bash-complete.el | 33 ++++++++++++++++++++-------------
bash-complete_test.el | 10 +++++-----
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/bash-complete.el b/bash-complete.el
index 3ea39611fb..1b78c8c8eb 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -38,42 +38,49 @@ Return a list containing the words and the number of the
word
at POS, the current word: ( (word1 word2 ...) . wordnum )"
(save-excursion
(goto-char start)
- (nreverse (bash-complete-split-0 start end pos nil))))
+ (nreverse (bash-complete-split-0 start end pos nil ""))))
-(defun bash-complete-split-0 (start end pos accum)
+(defun bash-complete-split-0 (start end pos accum straccum)
(let ( (char-start (char-after))
(quote nil) )
(when (or (= char-start ?') (= char-start ?\"))
(forward-char)
(setq quote char-start))
- (bash-complete-split-1 start end pos quote accum)))
+ (bash-complete-split-1 start end pos quote accum straccum)))
-(defun bash-complete-split-1 (start end pos quote accum)
- (skip-chars-forward (bash-complete-nonsep quote) end)
+(defun bash-complete-split-1 (start end pos quote accum straccum)
+ (let ((local-start (point)))
+ (skip-chars-forward (bash-complete-nonsep quote) end)
+ (setq straccum (concat straccum (buffer-substring-no-properties
local-start (point)))))
(cond
;; an escaped char, skip, whatever it is
((and (char-before) (= ?\\ (char-before)))
(forward-char)
- (bash-complete-split-1 start end pos (if (and quote (= quote
(char-before))) nil quote) accum))
+ (bash-complete-split-1
+ start end pos
+ (if (and quote (= quote (char-before))) nil quote)
+ accum
+ (concat (substring straccum 0 (- (length straccum) 1)) (char-to-string
(char-before)))))
;; opening quote
((and (not quote) (char-after) (or (= ?' (char-after)) (= ?\"
(char-after))))
- (bash-complete-split-0 start end pos accum))
+ (bash-complete-split-0 start end pos accum straccum))
;; closing quote
((and quote (= quote (char-after)))
(forward-char)
- (bash-complete-split-0 start end pos accum))
+ (bash-complete-split-0 start end pos accum straccum))
;; space inside a quote
((and quote (not (= quote (char-after))))
(forward-char)
- (bash-complete-split-1 start end pos quote accum))
+ (bash-complete-split-1
+ start end pos quote accum
+ (concat straccum (char-to-string (char-before)))))
;; word end
(t
- (let ((str (buffer-substring-no-properties start (point))))
- (when str
- (push str accum)))
+ (when straccum
+ (push straccum accum))
(skip-chars-forward " \t\n\r" end)
(if (< (point) end)
- (bash-complete-split-0 (point) end pos accum)
+ (bash-complete-split-0 (point) end pos accum "")
accum))))
(defun bash-complete-nonsep (quote)
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 55789ef11a..5d6a276124 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -38,25 +38,25 @@
(sz-testutils-with-buffer
'("a hello\\ world b c")
(bash-complete-split 1 (line-end-position) 0))
- '("a" "hello\\ world" "b" "c"))
+ '("a" "hello world" "b" "c"))
("bash-complete-split double quotes"
(sz-testutils-with-buffer
'("a \"hello world\" b c")
(bash-complete-split 1 (line-end-position) 0))
- '("a" "\"hello world\"" "b" "c"))
+ '("a" "hello world" "b" "c"))
("bash-complete-split single quotes"
(sz-testutils-with-buffer
- '("a \"hello world\" b c")
+ '("a 'hello world' b c")
(bash-complete-split 1 (line-end-position) 0))
- '("a" "\"hello world\"" "b" "c"))
+ '("a" "hello world" "b" "c"))
("bash-complete-split complex quote mix"
(sz-testutils-with-buffer
'("a hel\"lo w\"o'rld b'c d")
(bash-complete-split 1 (line-end-position) 0))
- '("a" "hel\"lo w\"o'rld b'c" "d"))
+ '("a" "hello world bc" "d"))
)))
- [nongnu] branch elpa/bash-completion created (now 8e9c20dbfe), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7dc290e1c7 003/313: exclude quotes from result,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 540f8f516a 011/313: build bash cmdline, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6eebe8f965 016/313: cleaned up process launch, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 34d11220dd 024/313: add prefix if missing, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3036ef0394 028/313: disable quote_readline to get good whitespace handling for bash 3.2 at least, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ba83e81651 053/313: bash-completion-generate-line, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f7bfc68ea2 001/313: bash completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f5885ec87a 002/313: test case for bash-complete, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 208cb5ab76 007/313: Join, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 47a890dd72 010/313: launch process, send commands, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 53f2c5d30e 009/313: parse complete -p output, ELPA Syncer, 2022/12/03