[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion d8f02ecbb1 231/313: Merge branch 'master'
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion d8f02ecbb1 231/313: Merge branch 'master' into use-separate-processes-opt |
Date: |
Sat, 3 Dec 2022 10:59:33 -0500 (EST) |
branch: elpa/bash-completion
commit d8f02ecbb1c4e9185b6e3142f668c3cc3b0fb3bb
Merge: 4d6fb40bec 783a1e79f0
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Merge branch 'master' into use-separate-processes-opt
---
.github/workflows/test.yml | 52 +++++++++++++
.gitignore | 2 +
Cask | 9 +++
Makefile | 40 ++++++++++
README.md | 3 +
bash-completion.el | 121 ++++++++++++++++++-------------
run_tests.sh | 28 -------
test/bash-completion-integration-test.el | 39 +++++-----
test/bash-completion-test.el | 2 +-
9 files changed, 195 insertions(+), 101 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000000..1bcac1b8f0
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,52 @@
+name: test
+on:
+ push: {branches: [master]}
+ pull_request: {branches: [master]}
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ emacs_version:
+ - '24.3'
+ - '25.1'
+ - '25.3'
+ - '26.1'
+ - '26.2'
+ - '26.3'
+ - 'snapshot'
+ include:
+ - emacs_version: 'snapshot'
+ allow_failure: true
+ steps:
+ - uses: actions/checkout@v1
+ - uses: purcell/setup-emacs@master
+ with:
+ version: ${{ matrix.emacs_version }}
+ - uses: conao3/setup-cask@master
+
+ - name: Run tests
+ if: matrix.allow_failure != true
+ run: 'cask && make test'
+
+ - name: Run tests (allow failure)
+ if: matrix.allow_failure == true
+ run: 'cask && make test || true'
+
+ test-macos-bash3:
+ runs-on: macos-10.15
+ strategy:
+ matrix:
+ emacs_version:
+ - '26.3'
+ steps:
+ - uses: actions/checkout@v1
+ - uses: purcell/setup-emacs@master
+ with:
+ version: ${{ matrix.emacs_version }}
+ - uses: conao3/setup-cask@master
+
+ - name: Run tests
+ run: 'cask && make test'
+
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index c531d9867f..90fdcfb681 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
*.elc
+.cask
+test/.set-bash-prog.el
diff --git a/Cask b/Cask
new file mode 100644
index 0000000000..739e198d5b
--- /dev/null
+++ b/Cask
@@ -0,0 +1,9 @@
+(source gnu)
+(source melpa)
+
+(package-file "bash-completion.el")
+
+(files "bash-completion.el")
+
+(development
+ (depends-on "ert-runner"))
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..d704525a25
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+CASK ?= cask
+EMACS ?= emacs
+BASH ?= bash
+
+setup_bash=test/.set-bash-prog.el
+
+all: test
+.PHONY: all
+
+test: clean-elc
+ ${MAKE} ert
+ ${MAKE} compile
+ ${MAKE} ert
+ ${MAKE} clean-elc
+.PHONY: test
+
+unit:
+ ${CASK} exec ert-runner test/bash-completion-test.el
+.PHONY: unit
+
+integration: setup_bash
+ ${CASK} exec ert-runner -l $(setup_bash) -p integration
test/bash-completion-integration-test.el
+.PHONY: integration
+
+ert: setup_bash
+ ${CASK} exec ert-runner -l $(setup_bash)
+.PHONY: ert
+
+compile:
+ ${CASK} build
+.PHONY: compile
+
+clean-elc:
+ ${CASK} clean-elc
+.PHONY: clean-elc
+
+setup_bash:
+ @echo '(setq bash-completion-prog "${BASH}")' >$(setup_bash)
+.PHONY: setup_bash
+
diff --git a/README.md b/README.md
index ae3dbbd1be..43ad912aec 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+# bash-completion
[![test](https://github.com/szermatt/emacs-bash-completion/workflows/test/badge.svg)](https://github.com/szermatt/emacs-bash-completion/actions)
[![melpa](https://melpa.org/packages/bash-completion-badge.svg)](https://melpa.org/#/bash-completion)
[![melpa-stable](https://stable.melpa.org/packages/bash-completion-badge.svg)](https://stable.melpa.org/#/bash-completion)
+
+
bash-completion.el defines dynamic completion hooks for shell-mode and
shell-command prompts that are based on bash completion.
diff --git a/bash-completion.el b/bash-completion.el
index 33f6f66a94..f16e26a32d 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -3,6 +3,11 @@
;; Copyright (C) 2009 Stephane Zermatten
;; Author: Stephane Zermatten <szermatt@gmx.net>
+;; Maintainer: Stephane Zermatten <szermatt@gmail.com>
+;; Version: 2.1.1
+;; Keywords: shell bash bash-completion
+;; URL: http://github.com/szermatt/emacs-bash-completion
+;; Package-Requires: ((emacs "24.1"))
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
@@ -41,7 +46,7 @@
;; running in term mode. Also, term mode is not available in
;; shell-command prompts.
;;
-;; Bash completion can also be run programatically, outside of a
+;; Bash completion can also be run programmatically, outside of a
;; shell-mode command, by calling
;; `bash-completion-dynamic-complete-nocomint'
;;
@@ -52,7 +57,7 @@
;; (autoload 'bash-completion-dynamic-complete \"bash-completion\"
;; \"BASH completion hook\")
;; (add-hook 'shell-dynamic-complete-functions
-;; 'bash-completion-dynamic-complete)
+;; 'bash-completion-dynamic-complete)
;;
;; or simpler, but forces you to load this file at startup:
;;
@@ -121,12 +126,11 @@
;; Full history is available on
;; https://github.com/szermatt/emacs-bash-completion
-(require 'comint)
-(require 'ansi-color)
-(eval-when-compile (require 'cl))
-
;;; Code:
+(require 'comint)
+(require 'cl-lib)
+
;;; ---------- Customization
(defgroup bash-completion nil
"BASH configurable command-line completion "
@@ -286,9 +290,9 @@ Bash processes.")
;; The main, completion structure, keeping track of the definition and
;; state of the current completion.
-(defstruct (completion (:constructor bash-completion--make)
- (:conc-name bash-completion--)
- (:copier nil))
+(cl-defstruct (completion (:constructor bash-completion--make)
+ (:conc-name bash-completion--)
+ (:copier nil))
line ; the relevant command (string)
point ; 0-based position of the cursor in line (number)
words ; line split into words, unescaped (list of strings)
@@ -301,7 +305,7 @@ Bash processes.")
open-quote ; quote open at stub end: nil, ?' or ?\""
compgen-args ; compgen arguments for this command (list of strings)
wordbreaks ; value of COMP_WORDBREAKS active for this completion
- compopt ; options forced with compopt nil or `(nospace . ,bool)
+ compopt ; options forced with compopt nil or `(nospace . ,bool)
)
(defun bash-completion--type (comp)
@@ -445,10 +449,10 @@ before it is needed. For an autoload version, add:
(autoload 'bash-completion-dynamic-complete \"bash-completion\"
\"BASH completion hook\")
(add-hook 'shell-dynamic-complete-functions
- 'bash-completion-dynamic-complete)
+ 'bash-completion-dynamic-complete)
"
(add-hook 'shell-dynamic-complete-functions
- 'bash-completion-dynamic-complete))
+ 'bash-completion-dynamic-complete))
;;;###autoload
(defun bash-completion-dynamic-complete ()
@@ -537,7 +541,7 @@ Returns (list stub-start stub-end completions) with
(bash-completion--complete comp process)))))))
(defun bash-completion--find-last (elt array)
- "Return the position of the last intance of ELT in array or nil."
+ "Return the position of the last instance of ELT in array or nil."
(catch 'bash-completion-return
(let ((array-len (length array)))
(dotimes (index array-len)
@@ -566,11 +570,15 @@ Return one string containing WORDS."
If WORD contains characters that aren't known to be harmless, this
functions adds single quotes around it and return the result."
- (if (string-match "^[a-zA-Z0-9_./-]*$" word)
- word
- (concat "'"
- (replace-regexp-in-string "'" "'\\''" word nil t)
- "'")))
+ (cond
+ ((string= "" word)
+ "''")
+ ((string-match "^[a-zA-Z0-9_./-]*$" word)
+ word)
+ (t
+ (concat "'"
+ (replace-regexp-in-string "'" "'\\''" word nil t)
+ "'"))))
(defun bash-completion--parse (comp-start comp-pos wordbreaks
bash-major-version)
"Process a command line split into TOKENS that end at POS.
@@ -588,11 +596,11 @@ Returns a completion struct."
wordbreaks "")))
(line-tokens (bash-completion-parse-current-command all-tokens))
(first-token (car line-tokens))
- (last-token (car (last line-tokens)))
+ (last-token (car (last line-tokens)))
(open-quote (bash-completion-tokenize-open-quote line-tokens))
- (start (or (car (bash-completion-tokenize-get-range first-token))
comp-pos))
- (end (or (cdr (bash-completion-tokenize-get-range last-token))
comp-pos))
- (words (bash-completion-strings-from-tokens line-tokens))
+ (start (or (car (bash-completion-tokenize-get-range first-token))
comp-pos))
+ (end (or (cdr (bash-completion-tokenize-get-range last-token))
comp-pos))
+ (words (bash-completion-strings-from-tokens line-tokens))
(stub-start) (unparsed-stub) (parsed-stub))
(if (or (> comp-pos end) (= start end))
(setq stub-start comp-pos
@@ -636,24 +644,24 @@ Return a sublist of TOKENS."
(catch 'bash-completion-return
(let ((command nil) (state 'initial))
(dolist (token tokens)
- (let* ((string (bash-completion-tokenize-get-str token))
- (is-terminal
- (and (member string '(";" "&" "|" "&&" "||"))
- (let ((range (bash-completion-tokenize-get-range token)))
- (= (- (cdr range) (car range))
- (length string))))))
- (cond
- (is-terminal
- (setq state 'initial)
- (setq command nil))
-
- ((and (eq state 'initial)
- (null (string-match "=" string)))
- (setq state 'args)
- (push token command))
-
- ((eq state 'args)
- (push token command)))))
+ (let* ((string (bash-completion-tokenize-get-str token))
+ (is-terminal
+ (and (member string '(";" "&" "|" "&&" "||"))
+ (let ((range (bash-completion-tokenize-get-range token)))
+ (= (- (cdr range) (car range))
+ (length string))))))
+ (cond
+ (is-terminal
+ (setq state 'initial)
+ (setq command nil))
+
+ ((and (eq state 'initial)
+ (null (string-match "=" string)))
+ (setq state 'args)
+ (push token command))
+
+ ((eq state 'args)
+ (push token command)))))
(or command (last tokens))))))
(defun bash-completion-strings-from-tokens (tokens)
@@ -714,14 +722,14 @@ This function is meant to be called exclusively from
This function expect the point to be at the start of a new
element to be added to the list of tokens.
-Return TOKENS with new tokens found betwen the current point and
+Return TOKENS with new tokens found between the current point and
END prepended to it."
(skip-chars-forward " \t\n\r" end)
(if (< (point) end)
(bash-completion-tokenize-0 end tokens
- (list
- (cons 'str "")
- (cons 'range (cons (point) nil))))
+ (list
+ (cons 'str "")
+ (cons 'range (cons (point) nil))))
tokens))
(defun bash-completion-tokenize-0 (end tokens token)
@@ -743,7 +751,7 @@ TOKEN is the token currently being built.
Return TOKENS with new tokens prepended to it."
(let ((char-start (char-after))
- (quote nil) )
+ (quote nil) )
(when (and char-start (or (= char-start ?') (= char-start ?\")))
(forward-char)
(setq quote char-start))
@@ -1015,11 +1023,11 @@ Return a CONS containing (before . after)."
(let ((end (- (length str) 1)))
(while (>= end 0)
(when (bash-completion--find-last (aref str end) wordbreaks)
- (throw 'bash-completion-return
+ (throw 'bash-completion-return
(list (substring str 0 (1+ end))
(substring str (1+ end))
(aref str end))))
- (setq end (1- end))))
+ (setq end (1- end))))
(list "" str ?\0)))
(defun bash-completion-last-char (str)
@@ -1031,7 +1039,7 @@ Return a CONS containing (before . after)."
(defun bash-completion-starts-with (str prefix)
"Return t if STR starts with PREFIX."
(let ((prefix-len (length prefix))
- (str-len (length str)))
+ (str-len (length str)))
(and
(>= str-len prefix-len)
(string= (substring str 0 prefix-len) prefix))))
@@ -1118,7 +1126,12 @@ is set to t."
;; but only in some environment. disable this dreadful
;; business to get a saner way of handling spaces.
;; Noticed in bash_completion v1.872.
- "function quote_readline { echo \"$1\"; }\n"))
+ "function quote_readline { echo \"$1\"; }\n"
+ ;; User's profiles can turn line editing back on,
+ ;; so make sure it's off
+ "set +o emacs\n"
+ "set +o vi\n"))
+
(bash-completion-send "PROMPT_COMMAND='';PS1='\t$?\v'" process
bash-completion-initial-timeout)
(bash-completion--setup-bash-common process)
(push (cons remote process) bash-completion-processes)
@@ -1170,7 +1183,7 @@ Return a bash command-line for going to default-directory
or \"\"."
BUFFER should contains the output of:
complete -p
-The returned alist is a sligthly parsed version of the output of
+The returned alist is a slightly parsed version of the output of
\"complete -p\"."
(let ((alist (list)))
(with-current-buffer buffer
@@ -1184,7 +1197,7 @@ The returned alist is a sligthly parsed version of the
output of
(line-end-position)))))
(when (string= "complete" (car words))
(if (member "-D" (cdr words))
- ;; default completion
+ ;; default completion
(push (cons nil (delete "-D" (cdr words))) alist)
;; normal completion
(let* ((reverse-wordsrest (nreverse (cdr words)))
@@ -1301,7 +1314,7 @@ and would like bash completion in Emacs to take these
changes into account."
(kill-process process))
(let ((buffer (bash-completion--get-buffer process)))
(when (buffer-live-p buffer)
- (kill-buffer buffer)))))
+ (kill-buffer buffer)))))
(defun bash-completion-buffer ()
"Return the buffer of the BASH process, create the BASH process if
necessary."
@@ -1448,4 +1461,8 @@ Return the parsed value, as a string or nil."
(delete-region (match-beginning 0) (match-end 0)))))))
(provide 'bash-completion)
+
+;; Local Variables:
+;; indent-tabs-mode: nil
+;; End:
;;; bash-completion.el ends here
diff --git a/run_tests.sh b/run_tests.sh
deleted file mode 100755
index e0b7b6905a..0000000000
--- a/run_tests.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-# Compiles and runs test using the emacs binary specified by
-# ${EMACSCMD}, which defaults to emacs, and the bash binary specified
-# by ${BASHCMD}, which defaults to bash.
-#
-rootdir="$(dirname "$0")"
-testdir="${rootdir}/test"
-emacscmd="${EMACSCMD:-emacs}"
-bashcmd="${BASHCMD:-$(which bash)}"
-echo "Testing against ${emacscmd} and ${bashcmd}:"
-"${emacscmd}" \
- -Q \
- -batch \
- -eval "(setq byte-compile-error-on-warn t)" \
- -L "${rootdir}" \
- -f batch-byte-compile \
- "${rootdir}/bash-completion.el" \
- || exit 1
-exec "${emacscmd}" \
- -Q \
- -batch \
- -eval "(setq bash-completion-prog \"${bashcmd}\")" \
- -L "${rootdir}" \
- -L "${testdir}" \
- -l "${testdir}/bash-completion-test.el" \
- -l "${testdir}/bash-completion-integration-test.el" \
- -f ert-run-tests-batch-and-exit
diff --git a/test/bash-completion-integration-test.el
b/test/bash-completion-integration-test.el
index 1d6a4558f2..e856b438b2 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -34,26 +34,25 @@
(require 'ert)
(defmacro bash-completion_test-harness (bashrc &rest body)
- `(if (file-executable-p bash-completion-prog)
- (let ((test-env-dir (bash-completion_test-setup-env ,bashrc)))
- (let ((bash-completion-processes nil)
- (bash-completion-nospace nil)
- (bash-completion-start-files nil)
- (bash-completion-args
- (list "--noediting"
- "--noprofile"
- "--rcfile" (expand-file-name "bashrc" test-env-dir)))
- (kill-buffer-query-functions '())
- (minibuffer-message-timeout 0)
- (default-directory test-env-dir))
- ;; Give Emacs time to process any input or process state
- ;; change from bash-completion-reset.
- (while (accept-process-output nil 0.1))
- (unwind-protect
- (progn ,@body)
- (progn
- (bash-completion_test-teardown-env test-env-dir)
- (bash-completion-reset-all)))))))
+ `(let ((test-env-dir (bash-completion_test-setup-env ,bashrc)))
+ (let ((bash-completion-processes nil)
+ (bash-completion-nospace nil)
+ (bash-completion-start-files nil)
+ (bash-completion-args
+ (list "--noediting"
+ "--noprofile"
+ "--rcfile" (expand-file-name "bashrc" test-env-dir)))
+ (kill-buffer-query-functions '())
+ (minibuffer-message-timeout 0)
+ (default-directory test-env-dir))
+ ;; Give Emacs time to process any input or process state
+ ;; change from bash-completion-reset.
+ (while (accept-process-output nil 0.1))
+ (unwind-protect
+ (progn ,@body)
+ (progn
+ (bash-completion_test-teardown-env test-env-dir)
+ (bash-completion-reset-all))))))
(defmacro bash-completion_test-with-shell-harness (bashrc &rest body)
`(bash-completion_test-harness
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index d9f98223e3..9e88932669 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -927,7 +927,7 @@ When `bash-completion-send' is called, it pops the result
from
--captured-commands.
Directories in --directories get a / appended to them. Note that
-the current directory in this environemnt is /tmp/test.
+the current directory in this environment is /tmp/test.
The body is run with a test buffer as current buffer. Fill it with the
command-line
before calling `bash-completion-dynamic-complete-nocomint'.
- [nongnu] elpa/bash-completion ffe0640440 212/313: Cosmetic changes, (continued)
- [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
- [nongnu] elpa/bash-completion f1bd7b0e17 215/313: Use more meaningful names for the functions returning completion processes, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 1e13f6ffa4 216/313: Apply the name changes introduced by the previous commit in the test files, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4d6fb40bec 217/313: Accept output only from the process performing completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 61592a1ce1 218/313: bash-completion.el (bash-completion-quote): Add case for empty string (#37), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 504dd26b1d 219/313: Use cl-defstruct instead of defstruct (#39), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 96ce14af96 221/313: Fix typo (#41), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 783a1e79f0 230/313: Add melpa and melpa-stable badges to README., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d8f02ecbb1 231/313: Merge branch 'master' into use-separate-processes-opt,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 10569a4625 232/313: Fix bash-completion-test-send., ELPA Syncer, 2022/12/03
- [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