[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 5447034cdc 251/313: Respect completion-ign
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 5447034cdc 251/313: Respect completion-ignore-case setting from .inputrc. |
Date: |
Sat, 3 Dec 2022 10:59:35 -0500 (EST) |
branch: elpa/bash-completion
commit 5447034cdcd17ee0d6ac063c767bf4b5e2b60ff1
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Respect completion-ignore-case setting from .inputrc.
This change reads the setting completion-ignore-case set in .inputrc
and use it to set the Emacs variable completion-ignore-case to make
completion accept matches whose case don't match.
Case-insensitive completion only works on bash 4, not bash 3, as this
approach relies on compgen following the setting in .inputrc, which
only happens starting with bash 4.
This change, together with the previous changes accepting completion
output that don't start with the original word, fix issue #7.
---
bash-completion.el | 16 ++++++++++++++
test/bash-completion-integration-test.el | 36 +++++++++++++++++++++++++++++++-
test/bash-completion-test.el | 2 ++
3 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/bash-completion.el b/bash-completion.el
index c826741622..4c2f59b7e4 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -439,6 +439,14 @@ returned."
(buffer-substring-no-properties
(point-min) (point-max))))
(process-put process 'bash-major-version bash-major-version)
+
+ (bash-completion-send "bind -v 2>/dev/null" process)
+ (process-put process 'completion-ignore-case
+ (with-current-buffer (bash-completion--get-buffer process)
+ (save-excursion
+ (goto-char (point-min))
+ (search-forward "completion-ignore-case on" nil
'noerror))))
+
(process-put process 'setup-done t)))
;;; ---------- Inline functions
@@ -564,6 +572,14 @@ Returns (list stub-start stub-end completions) with
(process-get process 'bash-major-version)))
(stub-start (bash-completion--stub-start comp))
(use-separate-processes bash-completion-use-separate-processes))
+
+ ;; This sets completion-ignore-case which matters for the
+ ;; caller, as it needs to know how to post-process the
+ ;; results.
+ (let ((ignore-case (process-get process 'completion-ignore-case)))
+ (unless (eq completion-ignore-case ignore-case)
+ (setq completion-ignore-case ignore-case)))
+
(bash-completion--customize comp process)
(list
stub-start
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index ef2bdd21c2..09b190b166 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -45,6 +45,7 @@
(list "--noediting"
"--noprofile"
"--rcfile" (expand-file-name "bashrc" test-env-dir)))
+ (completion-ignore-case nil)
(explicit-shell-file-name bash-completion-prog)
(explicit-args-var (intern
(concat "explicit-"
@@ -386,5 +387,38 @@ for testing completion."
(should (equal "dummy 1 Yaaa "
(bash-completion_test-complete "dummy 1 Y")))))
-
+(ert-deftest bash-completion-integration-case-insensitive-test ()
+ (bash-completion_test-harness
+ (concat ; .bashrc
+ "INPUTRC=test-inputrc\n")
+ nil ; use-separate-process
+ (with-temp-file "test-inputrc"
+ (insert "set completion-ignore-case on\n"))
+ (make-directory "Uppercase")
+ (bash-completion_test-with-shell
+ (when (>= (bash-completion_test-bash-major-version) 4)
+ ;; Case insensitive completion is done by compgen which, under
+ ;; bash 4, respects the case sensitivity settings set in
+ ;; .inputrc.
+ (should (equal "ls some/" (bash-completion_test-complete "ls so")))
+ (should (equal "ls some/" (bash-completion_test-complete "ls So")))
+ (should (equal "ls Uppercase/" (bash-completion_test-complete "ls Up")))
+ (should (equal "ls Uppercase/" (bash-completion_test-complete "ls up")))
+ (should completion-ignore-case)))))
+
+(ert-deftest bash-completion-integration-case-sensitive-test ()
+ (bash-completion_test-harness
+ (concat ; .bashrc
+ "INPUTRC=test-inputrc\n")
+ nil ; use-separate-process
+ (with-temp-file "test-inputrc"
+ (insert "set completion-ignore-case off\n"))
+ (make-directory "Uppercase")
+ (bash-completion_test-with-shell
+ (should (equal "ls some/" (bash-completion_test-complete "ls so")))
+ (should (equal "ls So" (bash-completion_test-complete "ls So")))
+ (should (equal "ls Uppercase/" (bash-completion_test-complete "ls Up")))
+ (should (equal "ls up" (bash-completion_test-complete "ls up")))
+ (should (not completion-ignore-case)))))
+
;;; bash-completion-integration-test.el ends here
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index c4516e434a..5c794525a2 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -966,6 +966,8 @@ before calling `bash-completion-dynamic-complete-nocomint'.
wordbreaks)
((and (eq 'process process) (eq 'bash-major-version
prop))
bash-major-version)
+ ((and (eq 'process process) (eq
'completion-ignore-case prop))
+ completion-ignore-case)
(t (error "unexpected call")))))
((symbol-function 'bash-completion-buffer) (lambda ()
--process-buffer))
((symbol-function 'process-buffer) (lambda (p)
--process-buffer))
- [nongnu] elpa/bash-completion 1b7ec87915 233/313: Fix byte-compilation error under Emacs 24 and 25., (continued)
- [nongnu] elpa/bash-completion 1b7ec87915 233/313: Fix byte-compilation error under Emacs 24 and 25., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a2da7b910b 235/313: Updated README to push for bash-completion-use-separate-processes., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fd3ba68800 236/313: Force bash-completion-use-separate-processes to t in tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7f4410ebcb 237/313: Extend integration tests to cover single-process use-case., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f8c2083a14 239/313: Rename bash-completion-get-process., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c25f2203f5 240/313: Fix typo and extend note about use-separate-processes-opt., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 685ed73df0 243/313: Allow completion to replace the word being completed., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7dc20e1b09 244/313: Use separate processes in integration tests when it doesn't matter., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a0a5816ce4 245/313: Attempt to make in-process execution more robust., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion cad904abfd 247/313: Redefine quote_readline from setup-bash-common., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5447034cdc 251/313: Respect completion-ignore-case setting from .inputrc.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 42630fe6cc 254/313: Fix test case to cover substring completion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8f33a2aac4 257/313: Better document calling bash-completion from completion-at-point., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 96d2cef799 259/313: Prepare for a 3.0 release., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4aafffe76a 260/313: Create CONTRIBUTING.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2b9eba14fa 261/313: Update README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 79ce50bec9 262/313: Update README.md title, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5e623ac270 275/313: Revert "Add test cases for TRAMP shell.", ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 702859f319 278/313: Cleanup strings containing bash commands., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 19d4fec42f 280/313: Use && instead of ; after cd, so completion fails if cd fails., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c584d4936b 281/313: Explicitly ignore error from the history command., ELPA Syncer, 2022/12/03