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

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

[nongnu] elpa/bash-completion 3efe7cb03c 067/313: escape #


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion 3efe7cb03c 067/313: escape #
Date: Sat, 3 Dec 2022 10:59:17 -0500 (EST)

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

    escape #
---
 bash-completion.el      |  9 +++++----
 bash-completion_test.el | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 5e19bc327d..ef8d80c201 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -268,7 +268,9 @@ as returned by `bash-completion-parse-line' given the 
current position POS."
       (setq cword index)
       (push "" strings))
     (list
-     (cons 'line (buffer-substring-no-properties start (cdr 
(bash-completion-tokenize-get-range token))))
+     (cons 'line (buffer-substring-no-properties
+                 start
+                 (cdr (bash-completion-tokenize-get-range token))))
      (cons 'point (- pos start))
      (cons 'cword cword)
      (cons 'words (nreverse strings)))))
@@ -496,7 +498,7 @@ Return TOKENS with new tokens prepended to it."
     (bash-completion-tokenize-new-element end tokens))))
 
 (defconst bash-completion-nonsep-alist
-  '((nil . "^ \t\n\r;&|'\"")
+  '((nil . "^ \t\n\r;&|'\"#")
     (?' . "^ \t\n\r'")
     (?\" . "^ \t\n\r\""))
   "Alist of sets of non-breaking characters.
@@ -566,7 +568,6 @@ Modification include:
 
 It should be invoked with the comint buffer as the current buffer
 for directory name detection to work."
-
   (let ((prefix (or prefix bash-completion-prefix))
        (suffix ""))
     (bash-completion-addsuffix
@@ -612,7 +613,7 @@ like a quoted string.
 Return a possibly escaped version of COMPLETION-CANDIDATE."
   (if (string-match "^['\"]" completion-candidate)
       completion-candidate
-    (replace-regexp-in-string "\\([ '\"]\\)" "\\\\\\1" completion-candidate)))
+    (replace-regexp-in-string "\\([ '\"#]\\)" "\\\\\\1" completion-candidate)))
 
 (defconst bash-completion-known-suffixes-regexp
   (concat "[" (regexp-quote bash-completion-wordbreaks-str) "/ ]$")
diff --git a/bash-completion_test.el b/bash-completion_test.el
index b456c22d03..2d10eb5645 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -69,6 +69,13 @@ cases. That's why they need to be enabled manually.")
        (bash-completion-tokenize 1 (line-end-position))))
       '("a" "hello world" "b" "c"))
 
+     ("bash-completion-tokenize escaped #"
+      (sz-testutils-with-buffer
+       '("a hello \\#world\\# b")
+       (bash-completion-strings-from-tokens
+       (bash-completion-tokenize 1 (line-end-position))))
+      '("a" "hello" "#world#" "b"))
+
      ("bash-completion-tokenize double quotes"
       (sz-testutils-with-buffer
        '("a \"hello world\" b c")
@@ -476,13 +483,17 @@ 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-candidate"
       (bash-completion-escape-candidate "He said: \"hello, 'you'\"")
       "He\\ said:\\ \\\"hello,\\ \\'you\\'\\\"")
 
+     ("bash-completion-escape-candidate"
+      (bash-completion-escape-candidate "#hello#")
+      "\\#hello\\#")
+
      ("bash-completion-escape-candidate not if double quoted"
       (bash-completion-escape-candidate "\"hello, you")
       "\"hello, you")



reply via email to

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