[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 094da8d6f8 115/313: Fallback to comint-dyn
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 094da8d6f8 115/313: Fallback to comint-dynamic-simple-complete for shellcommand, even under |
Date: |
Sat, 3 Dec 2022 10:59:22 -0500 (EST) |
branch: elpa/bash-completion
commit 094da8d6f83e5174b81b5601424b093eb9bbed4c
Author: Stephane Zermatten <stephane@boomer.local>
Commit: Stephane Zermatten <stephane@boomer.local>
Fallback to comint-dynamic-simple-complete for shellcommand, even under
emacs 24.1 for now.
---
bash-completion.el | 77 +++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 59 insertions(+), 18 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 68d0507864..49f65df8eb 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -53,7 +53,7 @@
;; (add-hook 'shell-dynamic-complete-functions
;; 'bash-completion-dynamic-complete)
;; (add-hook 'shell-command-complete-functions
-;; 'bash-completion-dynamic-complete)
+;; 'bash-completion-dynamic-complete-legacy)
;;
;; or simpler, but forces you to load this file at startup:
;;
@@ -294,15 +294,51 @@ before it is needed. For an autoload version, add:
(add-hook 'shell-dynamic-complete-functions
'bash-completion-dynamic-complete)
(add-hook 'shell-command-complete-functions
- 'bash-completion-dynamic-complete)
+ 'bash-completion-dynamic-complete-legacy)
"
(add-hook 'shell-dynamic-complete-functions
'bash-completion-dynamic-complete)
(add-hook 'shell-command-complete-functions
- 'bash-completion-dynamic-complete))
+ 'bash-completion-dynamic-complete-legacy))
;;;###autoload
(defun bash-completion-dynamic-complete ()
+ "Returns the completion table for bash command at point.
+
+This function is meant to be added into
+`shell-dynamic-complete-functions'. It uses `comint' to figure
+out what the current command is and returns a completion table or
+nil if no completions available.
+
+If emacs version is below 24.1 it calls
+`comint-dynamic-simple-complete-legacy' to do the completion instead."
+ (if bash-completion-comint-uses-standard-completion
+ (bash-completion-dynamic-complete-standard)
+ (bash-completion-dynamic-complete-legacy)))
+
+(defun bash-completion-dynamic-complete-legacy ()
+ "Returns the completion table for bash command at point.
+
+This function is meant to be added into
+`shell-dynamic-complete-functions' or
+`shell-command-complete-functions'. It uses `comint' to figure
+out what the current command is and calls
+`comint-dynamic-simple-complete' to do the completion instead.
+
+In most cases, you should call `bash-completion-dynamic' instead.
+This is only meant to be used when pre-emacs 24.1 behavior is
+required, such as when added to `shell-command-complete-functions'."
+ (let ((result (bash-completion-dynamic-complete-0)))
+ (when result
+ (let* ((stub (car result))
+ (completions (nth 3 result))
+ ;; Setting comint-completion-addsuffix overrides
+ ;; configuration for comint-dynamic-simple-complete.
+ ;; Bash adds a space suffix automatically.
+ (comint-completion-addsuffix nil))
+ (comint-dynamic-simple-complete stub completions)))))
+
+(defun bash-completion-dynamic-complete-standard ()
"Returns the completion table for bash command at point.
This function is meant to be added into
@@ -312,6 +348,17 @@ out what the current command is and returns a completion
table or
nil if no completions available. If emacs version is below 24.1
is calls `comint-dynamic-simple-complete' to do the completion
instead."
+ (cdr (bash-completion-dynamic-complete-0)))
+
+(defun bash-completion-dynamic-complete-0 ()
+ "Returns completion information for bash command at point.
+
+This function returns enough information for both
+`bash-completion-dynamic-complete-standard' and
+`bash-completion-dynamic-complete-legacy'. It is not meant to
+be called directly.
+
+Returns (list unescaped-stub stub-start pos completions)"
(when bash-completion-enabled
(when (not (window-minibuffer-p))
(message "Bash completion..."))
@@ -325,20 +372,13 @@ instead."
(cword (cdr (assq 'cword parsed)))
(words (cdr (assq 'words parsed)))
(stub-start (cdr (assq 'stub-start parsed)))
- (stub (nth cword words)) ; used only for older emacsen
+ (stub (nth cword words))
(completions (bash-completion-comm line point words cword
open-quote)))
(if completions
- (if bash-completion-comint-uses-standard-completion
- (list stub-start pos completions)
- ;; Setting comint-completion-addsuffix overrides
- ;; configuration for comint-dynamic-simple-complete.
- ;; Bash adds a space suffix automatically.
- (let ((comint-completion-addsuffix nil))
- (comint-dynamic-simple-complete stub completions)))
- ;; no standard completion
- ;; try default (file) completion after a wordbreak
- (bash-completion-dynamic-try-wordbreak-complete stub stub-start pos
- open-quote)))))
+ (list stub stub-start pos completions)
+ ;; fallback to default (file) completion after a wordbreak
+ (bash-completion-dynamic-try-wordbreak-complete
+ stub stub-start pos open-quote)))))
(defun bash-completion-dynamic-try-wordbreak-complete (stub stub-start pos
open-quote)
"Try wordbreak completion on STUB if the complete completion failed.
@@ -362,9 +402,10 @@ This function is not meant to be called outside of
(bash-completion-quote after-wordbreak)))
(let ((completions
(bash-completion-extract-candidates after-wordbreak open-quote)))
- (if bash-completion-comint-uses-standard-completion
- (list (+ stub-start (length before-wordbreak)) pos completions)
- (comint-dynamic-simple-complete after-wordbreak completions))))))
+ (list after-wordbreak
+ (+ stub-start (length before-wordbreak))
+ pos
+ completions)))))
;;; ---------- Functions: parsing and tokenizing
- [nongnu] elpa/bash-completion a2cf41d7fc 102/313: put in accidentally removed blank line from README, (continued)
- [nongnu] elpa/bash-completion a2cf41d7fc 102/313: put in accidentally removed blank line from README, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a8b652d00a 058/313: commented all functions, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b4fe25b51c 060/313: update tests for latest refactorings, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 49ae0ada64 076/313: keep open quote, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion aedcc114dc 105/313: Minor fixes to eliminate byte-compiler warnings., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8c771b10d1 082/313: fix typo, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9ca7e3a77f 085/313: Fixed errors in documentation, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 97cace2287 089/313: Split shopt sets; if one fails the rest can run, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 007765fdd1 111/313: Make bash-completion.el work under emacs trunk., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 102316ebf9 117/313: Test bash-completion-dynamic-complete-standard, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 094da8d6f8 115/313: Fallback to comint-dynamic-simple-complete for shellcommand, even under,
ELPA Syncer <=
- [nongnu] elpa/bash-completion acdedd0b48 122/313: Remove colon added by mistake in -test.el, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4e8090c081 128/313: Wrap use of obsolete fn in backward compatibility code path., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f639154925 134/313: Add bash-completion-dynamic-complete-nocomint for issue #13, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8fa510a174 136/313: Fix comments in header of bash-completion.el:, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion dda29cb470 137/313: Fix backward-compatibility code for supporting pre-24 Emacs versions,, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f3b11e1221 139/313: Preserve original, quoted version of the string being completed when, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2010d8bf9e 210/313: Fix history uncluttering, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion ffe0640440 212/313: Cosmetic changes, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion bb044ff2f0 213/313: Try to handle prompts with ANSI escape sequences, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e7ee0a5e07 214/313: Add a new prop to completion process to detect if it has been setup, ELPA Syncer, 2022/12/03