branch: elpa/helm
commit 35ff5cbe94470cb041bfcf12de7deee81c2886f3
Author: Thierry Volpiatto <[email protected]>
Commit: Thierry Volpiatto <[email protected]>

    Allow entering backslash in minibuffer from helm-comp-read
    
    This is done by adding a new keyword :raw-candidate to helm-comp-read.
    Use it in helm-find-files-eshell-command-on-file-1.
---
 helm-files.el |  5 ++++-
 helm-mode.el  | 14 ++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/helm-files.el b/helm-files.el
index 6b99b9162b..8906a1f89c 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -1776,7 +1776,10 @@ this working."
                  :raw-history t
                  :reverse-history helm-eshell-on-file-reverse-history
                  :input-history
-                 'helm-eshell-command-on-file-input-history))))
+                 'helm-eshell-command-on-file-input-history
+                 ;; Allow quoting when writing in minibuffer i.e. allow usage 
of
+                 ;; \@ and \#.
+                 :raw-candidate t))))
            (alias-value (car (assoc-default command 
eshell-command-aliases-list)))
            cmd-line)
       (if (or (equal helm-current-prefix-arg '(16))
diff --git a/helm-mode.el b/helm-mode.el
index 61fe5fbd78..da9ab9ddec 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -562,7 +562,8 @@ If COLLECTION is an `obarray', a TEST should be needed. See 
`obarray'."
 
 (defun helm-cr-default-transformer (candidates source)
   "Default filter candidate function for `helm-comp-read'."
-  (let ((must-match (helm-get-attr 'must-match source)))
+  (let ((must-match (helm-get-attr 'must-match source))
+        (raw-candidate (helm-get-attr 'raw-candidate source)))
     ;; Annotation and affixation are already handled in completion-in-region 
and
     ;; in helm-completing-read-default-2 when emacs style is in use.
     ;; For helm-completing-read-default-1 we handle them in an extra FCT; This
@@ -580,7 +581,9 @@ If COLLECTION is an `obarray', a TEST should be needed. See 
`obarray'."
              finally return
              ;; Unquote helm-pattern when it is added as candidate
              ;; (Bug#2015).
-             (let ((pat (replace-regexp-in-string "\\s\\" "" helm-pattern)))
+             (let ((pat (if raw-candidate
+                            helm-pattern
+                          (replace-regexp-in-string "\\s\\" "" helm-pattern))))
                (if (or (string= pat "")
                        (eq must-match t)
                        (helm-cr--pattern-in-candidates-p lst pat))
@@ -659,6 +662,7 @@ If COLLECTION is an `obarray', a TEST should be needed. See 
`obarray'."
                             multiline
                             allow-nest
                             coerce
+                            raw-candidate
                             (group 'helm))
   "Read a string in the minibuffer, with helm completion.
 
@@ -781,6 +785,9 @@ Keys description:
 
 - COERCE: See coerce in `helm-source'.
 
+- RAW-CANDIDATE: Do not unquote the unknown candidate coming from helm-pattern
+  when non nil. 
+
 - GROUP: See group in `helm-source'.
 
 Any prefix args passed during `helm-comp-read' invocation will be recorded
@@ -934,6 +941,9 @@ that use `helm-comp-read'.  See `helm-M-x' for example."
         (setq src-list (cl-loop for src in src-list
                              collect (cons '(nomark) src))))
       (when reverse-history (setq src-list (nreverse src-list)))
+      (when raw-candidate
+        (cl-loop for src in src-list
+                 do (helm-set-attr 'raw-candidate t src)))
       (add-hook 'helm-after-update-hook 
'helm-comp-read--move-to-first-real-candidate)
       (unwind-protect
            (setq result (helm

Reply via email to