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

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

[elpa] externals/corfu 065c7bb 1/5: Document file path completion (See #


From: ELPA Syncer
Subject: [elpa] externals/corfu 065c7bb 1/5: Document file path completion (See #9)
Date: Thu, 22 Jul 2021 15:57:08 -0400 (EDT)

branch: externals/corfu
commit 065c7bbef10f6d0f0f6338248059fd6c2c3d6dd2
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Document file path completion (See #9)
---
 README.org | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/README.org b/README.org
index 6519f79..7026ede 100644
--- a/README.org
+++ b/README.org
@@ -135,6 +135,33 @@
   - =M-h= -> ~corfu-show-documentation~
   - =C-g=, =ESC ESC ESC= -> ~corfu-quit~
 
+* File path completion inside strings
+
+  In order to additional complete file paths in string literals, we can reuse
+  the file path completion of the ~comint-mode~. Comit provides the
+  ~comint--complete-file-name-data~ completion-at-point-function (Capf). We 
write
+  a small wrapper function ~file-name-at-point~ and register it in the
+  ~completion-at-point-functions~ list for programming language modes.
+
+  #+begin_src emacs-lisp
+    (defun file-name-at-point ()
+      "File path completion function."
+      (when (comint--match-partial-filename)
+        (let ((comint-completion-addsuffix))
+          (comint--complete-file-name-data))))
+
+    (defun file-name-at-point-setup ()
+      "Setup file path completion at point in string literals."
+      (let ((global (memq t completion-at-point-functions)))
+        (setq-local completion-at-point-functions
+                    (delete-dups
+                     (append completion-at-point-functions
+                             (list #'file-name-at-point)
+                             (and global (list t)))))))
+
+    (add-hook 'prog-mode-hook #'file-name-at-point-setup)
+  #+end_src
+
 * Complementary packages
 
   Corfu works well together with all packages providing code completion via the



reply via email to

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