[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 376dd532e2 057/313: modre documentation, u
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 376dd532e2 057/313: modre documentation, up until wordbreak |
Date: |
Sat, 3 Dec 2022 10:59:16 -0500 (EST) |
branch: elpa/bash-completion
commit 376dd532e28aa8b47dc3cd014199d89a459fa51a
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
modre documentation, up until wordbreak
---
bash-completion.el | 77 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 69 insertions(+), 8 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index cdc0722b58..c557201566 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -130,7 +130,7 @@ This function is not meant to be called outside of
after-wordbreak))
(comint-dynamic-simple-complete
after-wordbreak
- (bash-completion-extract after-wordbreak)))))
+ (bash-completion-extract-candidates after-wordbreak)))))
(defun bash-completion-join (words)
"Join WORDS into a shell command line.
@@ -442,26 +442,64 @@ environment (no quote, single quote and double quote).
Get it using `bash-completion-nonsep'.")
(defun bash-completion-nonsep (quote)
+ "Return the set of non-breaking characters when QUOTE is the current quote.
+
+QUOTE should be nil, ?' or ?\"."
(cdr (assq quote bash-completion-nonsep-alist)))
(defun bash-completion-comm (line pos words cword)
- "Set LINE, POS, WORDS and CWORD, call bash completion, return the result.
+ "Set LINE, POS, WORDS and CWORD, call compgen, return the result.
-This function starts a separate bash process if necessary, sets up the
-completion environment (COMP_LINE, COMP_POINT, COMP_WORDS, COMP_CWORD) and
-calls compgen.
+This function starts a separate bash process if necessary, sets
+up the completion environment (COMP_LINE, COMP_POINT, COMP_WORDS,
+COMP_CWORD) and calls compgen.
The result is a list of candidates, which might be empty."
- (bash-completion-send (concat (bash-completion-generate-line line pos words
cword) " 2>/dev/null"))
- (bash-completion-extract (nth cword words)))
+ (bash-completion-send
+ (concat
+ (bash-completion-generate-line line pos words cword)
+ " 2>/dev/null"))
+ (bash-completion-extract-candidates (nth cword words)))
+
+(defun bash-completion-extract-candidates (stub)
+ "Extract the completion candidates from the process buffer for STUB.
+
+This command takes the content of the completion process buffer, split
+it by newlines, post-process the candidates and returns them as a list
+of strings.
-(defun bash-completion-extract (stub)
+It should be invoked with the comint buffer as the current buffer
+for directory name detection to work.
+
+Post-processing includes escaping special characters, adding a /
+to directory names, merging STUB with the result. See `bash-completion-fix'
+for more details.
+"
(let ((bash-completion-prefix stub))
(mapcar 'bash-completion-fix
(with-current-buffer (bash-completion-buffer)
(split-string (buffer-string) "\n" t)))))
(defun bash-completion-fix (str &optional prefix)
+ "Fix completion candidate in STR if PREFIX is the current prefix.
+
+STR is the completion candidate to modify.
+
+PREFIX should be the current string being completed. If it is
+nil, the value of `bash-completion-prefix' is used. This allows
+calling this function from `mapcar'.
+
+Return a modified version of the completion candidate.
+
+Modification include:
+ - escaping of special characters in STR
+ - prepending PREFIX if STR does not contain all of it, when
+ completion was done after a wordbreak
+ - adding / to recognized directory names
+
+It should be invoked with the comint buffer as the current buffer
+for directory name detection to work."
+
(let ((prefix (or prefix bash-completion-prefix))
(suffix ""))
(bash-completion-addsuffix
@@ -504,12 +542,35 @@ Return a possibly escaped version of
COMPLETION-CANDIDATE."
(replace-regexp-in-string "\\([ '\"]\\)" "\\\\\\1" completion-candidate)))
(defun bash-completion-before-last-wordbreak (str)
+ "Return the part of STR that comes after the last wordbreak character.
+The return value does not include the worbreak character itself.
+
+If no wordbreak was found, it returns STR.
+
+Wordbreaks characters are defined in 'bash-completion-wordbreak'."
(car (bash-completion-last-wordbreak-split str)))
(defun bash-completion-after-last-wordbreak (str)
+ "Return the part of STR that comes before the last wordbreak character.
+The return value includes the worbreak character itself.
+
+If no wordbreak was found, it returns \"\".
+
+Wordbreaks characters are defined in 'bash-completion-wordbreak'."
(cdr (bash-completion-last-wordbreak-split str)))
(defun bash-completion-last-wordbreak-split (str)
+ "Split STR into two parts: before the last wordbreak character and after.
+
+The part before the last wordbreak character includes the wordbreak character
+itself. It is \"\" if no wordbreak character was found.
+
+The part after the last wordbreak character does not include the wordbreak
character.
+It is STR if no wordbreak character was found.
+
+Wordbreaks characters are defined in 'bash-completion-wordbreak'.
+
+Return a CONS containing (before . after)."
(catch 'bash-completion-return
(let ((end (- (length str) 1)))
(while (> end 0)
- [nongnu] elpa/bash-completion 432c2d15c9 142/313: Add a space after the completion candidate for single completion., (continued)
- [nongnu] elpa/bash-completion 432c2d15c9 142/313: Add a space after the completion candidate for single completion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0f3f8c22b4 146/313: Add a space after a single custom completion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion eacb8061e3 147/313: Fallback to filename completion when custom completion didn't find, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 081d03bedc 156/313: Fix issue #21 completion bug, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1c2153d287 159/313: Call make-obsolete with three arguments, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7965b914da 160/313: Re-enable directory expansion for custom completion. fixes #23, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2c0b8d6a6e 163/313: Merge pull request #27 from vorburger/patch-1, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0c77c64b50 174/313: Disable bash-completion-enable-caching if completion-table-with-cache, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion b281e1e181 008/313: bash-complete-add-to-alist, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1144ae69a9 056/313: documented the tokenizer, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 376dd532e2 057/313: modre documentation, up until wordbreak,
ELPA Syncer <=
- [nongnu] elpa/bash-completion fd7e0e6fbe 078/313: added documentation, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion dd34b278bf 069/313: stopping at point; the easy way, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8756e80737 184/313: Replace 'options' in the completion struct with 'nospace'., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 2c4cb6edd2 186/313: Replace bash-completion-integration-test with a higher-level test for, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0aed19067b 188/313: When using Bash 4, split words as Bash 4 does., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4581a7823f 189/313: Bash 4: set COMP_TYPE and COMP_KEY to TAB, to let completion functions, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 802eb4e5a8 194/313: Set EMACS_BASH_COMPLETE even on remote (tramp) completion., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fbdc78b877 198/313: Support compopt when using Bash 4., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f1bd3d528f 201/313: Improve some docstrings, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fa49dbb382 209/313: Improve status code retrieval, ELPA Syncer, 2022/12/03