emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/bash-completion 8b02aafc67 046/313: separators


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 8b02aafc67 046/313: separators
Date: Sat, 3 Dec 2022 10:59:15 -0500 (EST)

branch: elpa/bash-completion
commit 8b02aafc6784de7889a0e67b15e7f997c9a089da
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>

    separators
---
 bash-completion.el      | 20 ++++++++++----------
 bash-completion_test.el | 30 +++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 371938ee04..74ec8792d5 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -107,9 +107,12 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
   (bash-completion-split-postprocess
    (bash-completion-split-raw start end) start pos))
 
+(defun bash-completion-split-strings (accum)
+  (mapcar 'bash-completion-split-raw-get-str accum))
+
 (defun bash-completion-split-postprocess (accum start pos)
   (if (null pos)
-      (cons nil (mapcar 'bash-completion-split-raw-get-str accum))
+      (cons nil (bash-completion-split-strings accum))
     ;; find position
     (let ((index 0) (strings nil) (current nil) (accum-rest accum) (cword nil))
       (while accum-rest
@@ -134,11 +137,6 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
 (defsubst bash-completion-split-raw-get-range (current)
   (cons (cdr (assq 'start current)) (cdr (assq 'end current))))
 
-(defsubst bash-completion-split-raw-set-start (current)
-  (let ((start-cons (assq 'start current)))
-    (when (null (cdr start-cons))
-      (setcdr start-cons (point)))))
-
 (defsubst bash-completion-split-raw-set-end (current)
   (setcdr (assq 'end current) (point)))
 
@@ -157,11 +155,12 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
 (defun bash-completion-split-raw-new-element (end accum)
   (skip-chars-forward " \t\n\r" end)
   (if (< (point) end)
-      (bash-completion-split-raw-0 end accum (copy-alist '((str . "") (start . 
nil) (end . nil))))
+      (bash-completion-split-raw-0 end accum (list (cons 'str "")
+                                                  (cons 'start (point))
+                                                  (cons 'end nil)))
     accum))
 
 (defun bash-completion-split-raw-0 (end accum current)
-  (bash-completion-split-raw-set-start current)
   (let ( (char-start (char-after))
         (quote nil) )
     (when (and char-start (or (= char-start ?') (= char-start ?\")))
@@ -171,7 +170,8 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
 
 (defun bash-completion-split-raw-1 (end quote accum current)
   (let ((local-start (point)))
-    (skip-chars-forward (bash-completion-nonsep quote) end)
+    (when (= (skip-chars-forward "[;&|]" end) 0)
+      (skip-chars-forward (bash-completion-nonsep quote) end))
     (bash-completion-split-raw-append-str
      current
      (buffer-substring-no-properties local-start (point))))
@@ -201,7 +201,7 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
     (bash-completion-split-raw-new-element end accum))))
 
 (defconst bash-completion-nonsep-alist
-  '((nil . "^ \t\n\r'\"")
+  '((nil . "^ \t\n\r;&|'\"")
     (?' . "^ \t\n\r'")
     (?\" . "^ \t\n\r\"")))
 
diff --git a/bash-completion_test.el b/bash-completion_test.el
index fa869c55a3..bfa6dea1ab 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -108,6 +108,34 @@ cases. That's why they need to be enabled manually.")
        (bash-completion-split 1 (line-end-position) (point)))
       '(2 . ("a" "hello" "world" "b" "c")))
 
+     ("bash-completion-split-raw unescaped semicolon"
+      (sz-testutils-with-buffer
+       "to infinity;and\\ beyond"
+       (bash-completion-split-strings
+       (bash-completion-split-raw 1 (line-end-position))))
+      '("to" "infinity" ";" "and beyond"))
+
+     ("bash-completion-split-raw unescaped &&"
+      (sz-testutils-with-buffer
+       "to infinity&&and\\ beyond"
+       (bash-completion-split-strings
+       (bash-completion-split-raw 1 (line-end-position))))
+      '("to" "infinity" "&&" "and beyond"))
+
+     ("bash-completion-split-raw unescaped ||"
+      (sz-testutils-with-buffer
+       "to infinity||and\\ beyond"
+       (bash-completion-split-strings
+       (bash-completion-split-raw 1 (line-end-position))))
+      '("to" "infinity" "||" "and beyond"))
+
+     ("bash-completion-split-raw quoted ;&|"
+      (sz-testutils-with-buffer
+       "to \"infinity;&|and\" beyond"
+       (bash-completion-split-strings
+       (bash-completion-split-raw 1 (line-end-position))))
+      '("to" "infinity;&|and" "beyond"))
+
 ;;      ("bash-completion-split cursor at the beginning"
 ;;       (sz-testutils-with-buffer
 ;;        '(" " cursor " a hello world b c")
@@ -415,7 +443,7 @@ garbage
        (bash-completion-nonsep nil)
        (bash-completion-nonsep ?')
        (bash-completion-nonsep ?\"))
-      '("^ \t\n\r'\"" "^ \t\n\r'" "^ \t\n\r\""))
+      '("^ \t\n\r;&|'\"" "^ \t\n\r'" "^ \t\n\r\""))
 
 
      ("bash-completion-escape"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]