diff options
| -rw-r--r-- | CHANGELOG.org | 1 | ||||
| -rw-r--r-- | cape.el | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org index 974c077..c911a17 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) @@ -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))))) |
