[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 504dd26b1d 219/313: Use cl-defstruct inste
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 504dd26b1d 219/313: Use cl-defstruct instead of defstruct (#39) |
Date: |
Sat, 3 Dec 2022 10:59:32 -0500 (EST) |
branch: elpa/bash-completion
commit 504dd26b1de326ec03d2c45f2d2db1ad59481adf
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Stephane Zermatten <szermatt@gmx.net>
Use cl-defstruct instead of defstruct (#39)
* Use cl-defstruct instead of defstruct
The latter is defined in "cl.el", which is considered obsolete
starting with Emacs 27.
* Consistently use spaces for indentation
Also set `indent-tabs-mode' as a file-local value to decrease
the likelihood that we have to do this again in the future.
---
bash-completion.el | 108 +++++++++++++++++++++++++++--------------------------
1 file changed, 56 insertions(+), 52 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index b947a6083c..cb406e9dc0 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -52,7 +52,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,11 +121,11 @@
;; Full history is available on
;; https://github.com/szermatt/emacs-bash-completion
-(require 'comint)
-(eval-when-compile (require 'cl))
-
;;; Code:
+(require 'comint)
+(require 'cl-lib)
+
;;; ---------- Customization
(defgroup bash-completion nil
"BASH configurable command-line completion "
@@ -239,9 +239,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)
@@ -331,10 +331,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 ()
@@ -390,7 +390,7 @@ Returns (list stub-start stub-end completions) with
comp-start comp-pos
(process-get process 'wordbreaks)
(process-get process 'bash-major-version)))
- (stub-start (bash-completion--stub-start comp)))
+ (stub-start (bash-completion--stub-start comp)))
(bash-completion--customize comp process)
(list
stub-start
@@ -457,11 +457,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
@@ -505,24 +505,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)
@@ -588,9 +588,9 @@ 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)
@@ -612,7 +612,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))
@@ -884,11 +884,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)
@@ -900,7 +900,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))))
@@ -1200,7 +1200,7 @@ and would like bash completion in Emacs to take these
changes into account."
(kill-process process))
(let ((buffer (process-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."
@@ -1233,26 +1233,26 @@ of the command in the bash completion process buffer.
Return the status code of the command, as a number."
;; (message commandline)
(let ((process (or process (bash-completion-require-process)))
- (timeout (or timeout bash-completion-process-timeout)))
+ (timeout (or timeout bash-completion-process-timeout)))
(with-current-buffer (process-buffer process)
(erase-buffer)
(process-send-string process (concat commandline "\n"))
(while (not (progn (goto-char 1) (search-forward "\v" nil t)))
- (unless (accept-process-output process timeout)
- (error (concat
+ (unless (accept-process-output process timeout)
+ (error (concat
"Timeout while waiting for an answer from "
"bash-completion process.\nProcess output: <<<EOF\n%sEOF")
(buffer-string))))
(let* ((control-v-position (point))
- (control-t-position (progn (search-backward "\t" nil t) (point)))
- (status-code (string-to-number
- (buffer-substring-no-properties
- (1+ control-t-position) (1- control-v-position)))))
- (delete-region control-t-position (point-max))
- ;; (message "status: %d content: \"%s\""
- ;; status-code
- ;; (buffer-substring-no-properties
- ;; (point-min) (point-max)))
+ (control-t-position (progn (search-backward "\t" nil t) (point)))
+ (status-code (string-to-number
+ (buffer-substring-no-properties
+ (1+ control-t-position) (1- control-v-position)))))
+ (delete-region control-t-position (point-max))
+ ;; (message "status: %d content: \"%s\""
+ ;; status-code
+ ;; (buffer-substring-no-properties
+ ;; (point-min) (point-max)))
(if (string=
"124"
(bash-completion--parse-side-channel-data "wrapped-status"))
@@ -1309,4 +1309,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
- [nongnu] elpa/bash-completion dda29cb470 137/313: Fix backward-compatibility code for supporting pre-24 Emacs versions,, (continued)
- [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
- [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 <=
- [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, 2022/12/03
- [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