[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 4b80c75c43 272/313: Take current directory
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 4b80c75c43 272/313: Take current directory from shell when in single-process mode. |
Date: |
Sat, 3 Dec 2022 10:59:37 -0500 (EST) |
branch: elpa/bash-completion
commit 4b80c75c433e5a5db9ba11fd6cc0832a30bff603
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Take current directory from shell when in single-process mode.
This change avoids having to rely on directory tracking to keep
default-directory in sync with the shell's current directory. When
possible, the current directory is sent out together with the
completion.
---
bash-completion.el | 22 +++++++++++++---------
test/bash-completion-integration-test.el | 8 ++++++++
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index c2c935cd6c..b9c2d4c571 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -924,8 +924,9 @@ for directory name detection to work.
Post-processing includes escaping special characters, adding a /
to directory names, replacing STUB with UNPARSED-STUB in the
result. See `bash-completion-fix' for more details."
- (let ((output) (candidates))
+ (let ((output) (candidates) (pwd))
(with-current-buffer buffer
+ (setq pwd (bash-completion--parse-side-channel-data "pwd"))
(let ((compopt (bash-completion--parse-side-channel-data "compopt")))
(cond
((string= "-o nospace" compopt)
@@ -934,13 +935,16 @@ result. See `bash-completion-fix' for more details."
(setf (bash-completion--compopt comp) '((nospace . nil))))))
(setq output (buffer-string)))
(setq candidates (delete-dups (split-string output "\n" t)))
- (if (eq 1 (length candidates))
- (list (bash-completion-fix (car candidates) comp t))
- ;; multiple candidates
- (let ((result (list)))
- (dolist (completion candidates)
- (push (bash-completion-fix completion comp nil) result))
- (delete-dups (nreverse result))))))
+ (let ((default-directory (if pwd
+ (concat (file-remote-p default-directory) pwd)
+ default-directory)))
+ (if (eq 1 (length candidates))
+ (list (bash-completion-fix (car candidates) comp t))
+ ;; multiple candidates
+ (let ((result (list)))
+ (dolist (completion candidates)
+ (push (bash-completion-fix completion comp nil) result))
+ (delete-dups (nreverse result)))))))
(defun bash-completion-fix (str comp single)
"Fix completion candidate in STR for COMP
@@ -1350,7 +1354,7 @@ completion candidates."
(concat
(if bash-completion-use-separate-processes
(bash-completion-cd-command-prefix)
- "")
+ (bash-completion--side-channel-data "pwd" "${PWD}"))
(cond
((eq 'command completion-type)
(concat "compgen -b -c -a -A function -- " quoted-stub))
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index d718110052..be9765f5aa 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -530,4 +530,12 @@ other
4 history
$ ")))))
+(ert-deftest bash-completion-integration-bad-directory-tracking ()
+ "When using single-process, bad directory tracking shouldn't be a problem."
+ (bash-completion_test-with-shell-harness
+ "" ; .bashrc
+ nil ; use-separate-process
+ (let ((default-directory "/does-not-exist/"))
+ (should (equal "ls some/" (bash-completion_test-complete "ls so"))))))
+
;;; bash-completion-integration-test.el ends here
- [nongnu] elpa/bash-completion 4fcddf83c9 242/313: Make /etc/bash_completion scripts work with escaped spaces., (continued)
- [nongnu] elpa/bash-completion 4fcddf83c9 242/313: Make /etc/bash_completion scripts work with escaped spaces., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2dbc7e61f6 248/313: Extend bash-completion-refresh to refresh everything, test it., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 04393bca0f 250/313: Apply filename post-processing even when prefix doesn't match., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2a937b3763 255/313: Don't let Emacs post-filter completions built by bash., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e95867c993 256/313: completion-table-with-cache captures and restore buffer and variables., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 747920fdbf 265/313: Avoid having to set BASH_COMPLETION., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f15176ee59 267/313: Fix to properly evaluate PROMPT_COMMAND after restoring it., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b4ae893243 268/313: Test prompt and history manipulation, fix $? in prompt., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 20feaf909d 258/313: Fix markdown markup., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8713edbb92 269/313: Mention that completion works with bash 5, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4b80c75c43 272/313: Take current directory from shell when in single-process mode.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion ea5cc15b99 273/313: Let status code of compgen through when in single-process mode., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 12da4f0e91 289/313: Better handle slow completion functions., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7186a18cad 012/313: Integrated into comm, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e81c478032 020/313: bash-complete -> bash-completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8270e09294 023/313: pass words as command-line arguments to the function, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 482383dcd7 021/313: handle slash for directory, usable completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion cd2ec103d1 026/313: Expand directory names with quotes and spaces, but no further, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1d7af7e40d 027/313: Remove debug messages, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion dda4697cfb 029/313: included bash-completion into google env, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 21eabde7f9 045/313: Reimplemented split, ELPA Syncer, 2022/12/03