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

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

[elpa] externals/cape c51acf427c 1/2: cape-file: Quote file names in com


From: ELPA Syncer
Subject: [elpa] externals/cape c51acf427c 1/2: cape-file: Quote file names in comint/eshell buffers
Date: Tue, 6 Jun 2023 06:57:40 -0400 (EDT)

branch: externals/cape
commit c51acf427c75e58093ba100b5a82354779548f1b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    cape-file: Quote file names in comint/eshell buffers
---
 CHANGELOG.org |  1 +
 cape.el       | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 974c077330..c911a17ed6 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -6,6 +6,7 @@
 
 - =cape-dabbrev=: Respect =dabbrev-abbrev-char-regexp= and
   =dabbrev-abbrev-skip-leading-regexp=.
+- =cape-file=: Quote file names in comint/eshell buffers.
 
 * Version 0.15 (2023-04-17)
 
diff --git a/cape.el b/cape.el
index 0e777bf1c7..aefb68a7f6 100644
--- a/cape.el
+++ b/cape.el
@@ -292,6 +292,9 @@ See also `consult-history' for a more flexible variant 
based on
 
 ;;;;; cape-file
 
+(defvar comint-unquote-function)
+(defvar comint-requote-function)
+
 (defvar cape--file-properties
   (list :annotation-function (lambda (s) (if (string-suffix-p "/" s) " Dir" " 
File"))
         :company-kind (lambda (s) (if (string-suffix-p "/" s) 'folder 'file))
@@ -311,6 +314,7 @@ If INTERACTIVE is nil the function acts like a Capf."
                                       ('nil default-directory)
                                       ((pred stringp) cape-file-directory)
                                       (_ (funcall cape-file-directory))))
+                 ;; TODO: Bounds are not correct in comint/eshell buffers
                  (`(,beg . ,end) (cape--bounds 'filename))
                  (non-essential t)
                  (file (buffer-substring-no-properties beg end))
@@ -322,7 +326,13 @@ If INTERACTIVE is nil the function acts like a Capf."
                 (and (string-search "/" file)
                      (file-exists-p (file-name-directory file))))
         `(,beg ,end
-          ,(cape--nonessential-table #'read-file-name-internal)
+          ,(cape--nonessential-table
+            (if (derived-mode-p 'comint-mode 'eshell-mode)
+                (completion-table-with-quoting
+                 #'read-file-name-internal
+                 comint-unquote-function
+                 comint-requote-function)
+              #'read-file-name-internal))
           ,@(when (or org (string-match-p "./" file))
               '(:company-prefix-length t))
           ,@cape--file-properties)))))



reply via email to

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