[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion c64ca7a992 071/313: simplified parse-curre
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion c64ca7a992 071/313: simplified parse-current-command, all tests pass |
Date: |
Sat, 3 Dec 2022 10:59:17 -0500 (EST) |
branch: elpa/bash-completion
commit c64ca7a9924946d5eb9bff67ad74d9ad1b55fc56
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
simplified parse-current-command, all tests pass
---
bash-completion.el | 38 ++++----------------------------------
1 file changed, 4 insertions(+), 34 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 247e248853..e983fdd58a 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -278,7 +278,7 @@ Return a sublist of TOKENS."
(catch 'bash-completion-return
(let ((command nil) (state 'initial))
(dolist (token tokens)
- (let* ((position (bash-completion-tokenize-range-check pos token))
+ (let* (
(string (bash-completion-tokenize-get-str token))
(is-terminal
(and (member string '(";" "&" "|" "&&" "||"))
@@ -286,29 +286,18 @@ Return a sublist of TOKENS."
(= (- (cdr range) (car range))
(length string))))))
(cond
- ((and is-terminal
- (eq position 'after))
+ (is-terminal
(setq state 'initial)
(setq command nil))
- (is-terminal
- (throw 'bash-completion-return command))
-
((and (eq state 'initial)
(null (string-match "=" string)))
(setq state 'args)
(push token command))
- ((and (eq state 'initial)
- (eq position 'after)))
-
- ((eq state 'initial)
- (push token command)
- (throw 'bash-completion-return command))
-
((eq state 'args)
(push token command)))))
- command))))
+ (or command (last tokens))))))
(defun bash-completion-strings-from-tokens (tokens)
"Extract the strings from TOKENS.
@@ -319,24 +308,6 @@ list of strings.
TOKENS should be in the format returned by `bash-completion-tokenize'."
(mapcar 'bash-completion-tokenize-get-str tokens))
-(defun bash-completion-tokenize-range-check (pos token)
- "Describes where POS is in relation to TOKEN.
-
-If POS comes before TOKEN, return 'before.
-If POS comes after TOKEN, return 'after.
-If POS is inside TOKEN or just after it, return 'contains."
- (let ((range (bash-completion-tokenize-get-range token)))
- (cond
- ((< pos (car range))
- 'before)
-
- ((and (>= pos (car range))
- (<= pos (cdr range)))
- 'contains)
-
- ((> pos (cdr range))
- 'after))))
-
(defsubst bash-completion-tokenize-get-range (token)
"Return the TOKEN range as a cons: (start . end)."
(cdr token))
@@ -375,8 +346,7 @@ that belongs to the token. End is the position of the first
character that doesn't belong to the token. For example in the
string \" hello world \", the first token range is (2 . 7) and
the second token range (9 . 14). It can be accessed using
-`bash-completion-tokenize-get-range' and
-`bash-completion-tokenize-range-check'. The end position can be
+`bash-completion-tokenize-get-range'. The end position can be
set using `bash-completion-tokenize-set-end'.
Tokens should always be accessed using the functions specified above,
- [nongnu] elpa/bash-completion dda4697cfb 029/313: included bash-completion into google env, (continued)
- [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
- [nongnu] elpa/bash-completion 3c58afdb0d 033/313: expand file names in colon-separated paths, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5501cb63cf 042/313: Turn off mail warning, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0dcf43f91e 041/313: don't run integration tests by default, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5b76fc4a33 032/313: remove wrong a=b variable prefix handling, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7697f1a87c 063/313: comments about tried systems, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3efe7cb03c 067/313: escape #, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 42441e36b0 055/313: more documentation, a little refactoring, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 5661a34c4a 098/313: updated test case for cd 2>/dev/null, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c64ca7a992 071/313: simplified parse-current-command, all tests pass,
ELPA Syncer <=
- [nongnu] elpa/bash-completion cc1a462415 050/313: tested complex line, detect escaped separators, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 9ac7f58758 059/313: Gone through compgen, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e515453141 047/313: from an alist to (string start stop), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 582b489fb3 091/313: Added message about mailcheck, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7f0160d271 065/313: Trim strange results that are a subset of the current value: test case, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 583ecc7707 103/313: Merge pull request #1 from kemmason/master, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 52af1ff8f7 090/313: Really disable mail check this time ? Set MAILCHECK to -1, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3859be798a 108/313: Add support for complete -D., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 711ccc2df1 096/313: format example properly, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 7615b1bda5 083/313: changed e-mail address, ELPA Syncer, 2022/12/03