[elpa] externals/eev 2c95478cf6: New video: (find-eev2022klavideo).

2022-12-03 Thread ELPA Syncer
branch: externals/eev
commit 2c95478cf6a26af5f0ab8ba100f3c2e5bdf67c5a
Author: Eduardo Ochs 
Commit: Eduardo Ochs 

New video: (find-eev2022klavideo).
---
 VERSION   |  4 ++--
 eev-intro.el  |  2 +-
 eev-videolinks.el | 27 +--
 eev.el|  2 +-
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/VERSION b/VERSION
index a12729411f..d78d5498da 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Sat Dec  3 05:00:40 GMT 2022
-Sat Dec  3 02:00:40 -03 2022
+Sat Dec  3 08:59:19 GMT 2022
+Sat Dec  3 05:59:19 -03 2022
diff --git a/eev-intro.el b/eev-intro.el
index 5f4909e274..227d7f5ef9 100644
--- a/eev-intro.el
+++ b/eev-intro.el
@@ -14647,7 +14647,7 @@ filename, like:
 
 \"/tmp/FOO/BAR/PLIC/bletch\"
 
-and then convert it to pair made of a `c' and a `d'? In that
+and then convert it to a pair made of a `c' and a `d'? In that
 example we have these three options,
 
(foo \"/tmp/FOO/\")
diff --git a/eev-videolinks.el b/eev-videolinks.el
index 5d1b7ad021..efa2dadcf7 100644
--- a/eev-videolinks.el
+++ b/eev-videolinks.el
@@ -19,7 +19,7 @@
 ;;
 ;; Author: Eduardo Ochs 
 ;; Maintainer: Eduardo Ochs 
-;; Version:20221107
+;; Version:20221203
 ;; Keywords:   e-scripts
 ;;
 ;; Latest version: <http://angg.twu.net/eev-current/eev-videolinks.el>
@@ -69,6 +69,7 @@
 ;;   «.find-2022eevwconfigvideo»   (to "find-2022eevwconfigvideo")
 ;;   «.find-2022yttranscriptvideo» (to "find-2022yttranscriptvideo")
 ;;   «.find-2022tikzvideo» (to "find-2022tikzvideo")
+;;   «.find-eev2022klavideo»   (to "find-eev2022klavideo")
 ;; «.more-info»(to "more-info")
 ;; «.ee-1stclassvideos-info»   (to "ee-1stclassvideos-info")
 ;;   «.eev2019»(to "eev2019")
@@ -100,6 +101,7 @@
 ;;   «.2022eevwconfig» (to "2022eevwconfig")
 ;;   «.2022yttranscript»   (to "2022yttranscript")
 ;;   «.2022tikz»   (to "2022tikz")
+;;   «.eev2022kla» (to "eev2022kla")
 ;; «.ee-1stclassvideos-field»  (to "ee-1stclassvideos-field")
 ;; «.second-class-videos»  (to "second-class-videos")
 ;;   «.code-eevvideo»  (to "code-eevvideo")
@@ -630,6 +632,16 @@ For more info on this particular video, run:
   (interactive)
   (find-1stclassvideo-video "2022tikz" time))
 
+;; «find-eev2022klavideo»  (to ".find-eev2022klavideo")
+;; Info: (find-1stclassvideo-links "eev2022kla")
+;; Play: (find-eev2022klavideo "0:00")
+(defun find-eev2022klavideo (&optional time &rest rest)
+  "Play one of the first-class videos of eev starting at TIME.
+For more info on this particular video, run:
+  (find-1stclassvideo-links \"eev2022kla\")"
+  (interactive)
+  (find-1stclassvideo-video "eev2022kla" time))
+
 
 
 
@@ -1027,12 +1039,23 @@ For more info on this particular video, run:
  :mp4   "http://angg.twu.net/eev-videos/2022-eev-tikz.mp4";
  :yt"http://www.youtube.com/watch?v=d7nIzpXcV6c";
  :page  "http://angg.twu.net/eev-tikz.html";
- :lang  "portuguese"
  :date"2022nov02"
  :subs".vtt"
  :length  "1:36:27"
  :comment "A way to learn TikZ using examples from the manual.")
 ;;
+;; «eev2022kla»  (to ".eev2022kla")
+;; Play: (find-eev2022klavideo "0:00")
+;; Index: (find-1stclassvideoindex "eev2022kla")
+("eev2022kla"
+ :title "Bidirectional links with eev (@ EmacsConf 2022)"
+ :mp4   "http://angg.twu.net/eev-videos/emacsconf2022-kla.mp4";
+ :yt"http://www.youtube.com/watch?v=KRobfwXd7Cw";
+ :page  "http://angg.twu.net/emacsconf2022-kla.html";
+ :date"2022dec03"
+ :subs".vtt"
+ :length  "7:57"
+ :comment "A video about eev-kla.el.")
 ))
 
 
diff --git a/eev.el b/eev.el
index c073e6e354..1d0dd8dc62 100644
--- a/eev.el
+++ b/eev.el
@@ -6,7 +6,7 @@
 ;; Package-Requires: ((emacs "24.4"))
 ;; Keywords: lisp e-scripts
 ;; URL: http://angg.twu.net/#eev
-;; Version: 20221108
+;; Version: 20221203
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by



[elpa] externals/eev 7315f1c9c7: Fixed the ChangeLog.

2022-12-03 Thread ELPA Syncer
branch: externals/eev
commit 7315f1c9c7442de2fd8da0a4ac0306bd78c8b524
Author: Eduardo Ochs 
Commit: Eduardo Ochs 

Fixed the ChangeLog.
---
 ChangeLog | 5 +
 VERSION   | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 91ec5a880b..3e3bb83ca8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-12-03  Eduardo Ochs  
+
+   * eev-videolinks.el (find-eev2022klavideo): new function.
+   (ee-1stclassvideos-info): added an entry for "eev2022kla".
+
 2022-12-02  Eduardo Ochs  
 
* eev-rstdoc.el (ee-code-rstdoc): added `find-{c}dochelp'.
diff --git a/VERSION b/VERSION
index d78d5498da..bc251a4e7d 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Sat Dec  3 08:59:19 GMT 2022
-Sat Dec  3 05:59:19 -03 2022
+Sat Dec  3 09:59:52 GMT 2022
+Sat Dec  3 06:59:52 -03 2022



[elpa] externals/org-modern 7d037569bc: Append org-modern-symbol face

2022-12-03 Thread ELPA Syncer
branch: externals/org-modern
commit 7d037569bc4a05f40262ea110c4cda05c69b5c52
Author: Daniel Mendler 
Commit: Daniel Mendler 

Append org-modern-symbol face
---
 org-modern.el | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/org-modern.el b/org-modern.el
index 79f70b8703..37945c1bbc 100644
--- a/org-modern.el
+++ b/org-modern.el
@@ -572,6 +572,12 @@ the font.")
   (define-fringe-bitmap 'org-modern--block-end
 (vconcat (make-vector (- 127 h) #x80) [#xFF] (make-vector h 0)) nil 
nil 'bottom
 
+(defun org-modern--symbol (str)
+  "Add `org-modern-symbol' face to STR."
+  (setq str (copy-sequence str))
+  (add-face-text-property 0 (length str) 'org-modern-symbol 'append str)
+  str)
+
 (defun org-modern--make-font-lock-keywords ()
   "Compute font-lock keywords."
   (append
@@ -626,19 +632,15 @@ the font.")
   (when org-modern-internal-target
 `((,(format "\\(<<\\)%s\\(>>\\)" target)
(0 '(face org-modern-internal-target) t)
-   (1 '(face nil display ,(propertize (car org-modern-internal-target)
-  'face 'org-modern-symbol)))
-   (3 '(face nil display ,(propertize (caddr 
org-modern-internal-target)
-  'face 'org-modern-symbol)))
+   (1 '(face nil display ,(org-modern--symbol (car 
org-modern-internal-target
+   (3 '(face nil display ,(org-modern--symbol (caddr 
org-modern-internal-target
,@(unless (cadr org-modern-internal-target)
'((2 '(face nil display "")))
   (when org-modern-radio-target
 `((,(format "\\(<<<\\)%s\\(>>>\\)" target)
(0 '(face org-modern-radio-target) t)
-   (1 '(face nil display ,(propertize (car org-modern-radio-target)
-  'face 'org-modern-symbol)))
-   (3 '(face nil display ,(propertize (caddr org-modern-radio-target)
-  'face 'org-modern-symbol)))
+   (1 '(face nil display ,(org-modern--symbol (car 
org-modern-radio-target
+   (3 '(face nil display ,(org-modern--symbol (caddr 
org-modern-radio-target
,@(unless (cadr org-modern-radio-target)
'((2 '(face nil display "")
(when org-modern-timestamp
@@ -694,20 +696,17 @@ the font.")
(org-modern-mode
 (setq
  org-modern--star-cache
- (vconcat (mapcar
-   (lambda (x) (propertize x 'face 'org-modern-symbol))
-   org-modern-star))
+ (vconcat (mapcar #'org-modern--symbol org-modern-star))
  org-modern--hide-stars-cache
  (and (stringp org-modern-hide-stars)
-  (list (propertize org-modern-hide-stars 'face 'org-modern-symbol)
-(propertize org-modern-hide-stars 'face 'org-modern-symbol)))
+  (list (org-modern--symbol org-modern-hide-stars)
+(org-modern--symbol org-modern-hide-stars)))
  org-modern--progress-cache
  (vconcat (mapcar
-   (lambda (x) (concat " " (propertize x 'face 'org-modern-symbol) 
" "))
+   (lambda (x) (concat " " (org-modern--symbol x) " "))
org-modern-progress))
  org-modern--checkbox-cache
- (mapcar (pcase-lambda (`(,k . ,v))
-   (cons k (propertize v 'face 'org-modern-symbol)))
+ (mapcar (pcase-lambda (`(,k . ,v)) (cons k (org-modern--symbol v)))
  org-modern-checkbox)
  org-modern--font-lock-keywords
  (append (remove '(org-fontify-meta-lines-and-blocks) 
org-font-lock-keywords)



[nongnu] elpa/cider updated (5064287ba7 -> 6c5f89bc4e)

2022-12-03 Thread ELPA Syncer
elpasync pushed a change to branch elpa/cider.

  from  5064287ba7 Scroll repl buffer in other frame
   new  24b9891e0b Allow connecting to nbb via connect-clj (#3061) (#3272)
   new  6c5f89bc4e Touch up the previous commit


Summary of changes:
 CHANGELOG.md   |  2 ++
 cider-connection.el| 34 +-
 cider-eval.el  | 19 +---
 cider-overlays.el  |  1 +
 cider-repl.el  |  3 +-
 cider.el   |  6 +++-
 doc/modules/ROOT/nav.adoc  |  1 +
 .../ROOT/pages/platforms/scittle_and_friends.adoc  | 29 ++
 test/cider-connection-tests.el | 20 +
 9 files changed, 108 insertions(+), 7 deletions(-)
 create mode 100644 doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc



[nongnu] elpa/cider 6c5f89bc4e 2/2: Touch up the previous commit

2022-12-03 Thread ELPA Syncer
branch: elpa/cider
commit 6c5f89bc4ee3813af6c6c251f13ea5cf51c7923e
Author: Bozhidar Batsov 
Commit: Bozhidar Batsov 

Touch up the previous commit
---
 cider-connection.el | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/cider-connection.el b/cider-connection.el
index ab71b34801..f7a18d255f 100644
--- a/cider-connection.el
+++ b/cider-connection.el
@@ -451,16 +451,16 @@ about this buffer (like variable `cider-repl-type')."
   (plist-get nrepl-endpoint :port))
 
 (defvar-local cider-connection-capabilities '()
-  "A list of some of the capabilites of this connection buffer.
-Aka what assumptions we make about the runtime.
+  "A list of some of the capabilities of this connection buffer.
+In other words - what assumptions we make about the runtime.
 This is more general than
 `cider-nrepl-op-supported-p' and `cider-library-present-p'.
 But does not need to replace them.")
 
-(defun cider-connection-has-capability-p (capability :optional 
connection-buffer)
-  "Return non nil when the cider connection has CAPABILITY.
+(defun cider-connection-has-capability-p (capability &optional conn-buf)
+  "Return non nil when the cider connection has CAPABILITY for CONN-BUF.
 By default it assumes the connection buffer is current."
-  (with-current-buffer (or connection-buffer (current-buffer))
+  (with-current-buffer (or conn-buf (current-buffer))
 (member capability cider-connection-capabilities)))
 
 



[nongnu] elpa/cider 24b9891e0b 1/2: Allow connecting to nbb via connect-clj (#3061) (#3272)

2022-12-03 Thread ELPA Syncer
branch: elpa/cider
commit 24b9891e0b4603dca7519427d02ff4af2cfac57a
Author: Benjamin <38900087+benjamin-a...@users.noreply.github.com>
Commit: GitHub 

Allow connecting to nbb via connect-clj (#3061) (#3272)

This is for nbb, scittle, joyride.
Better support for "pain" repls, support "cljs" without setup.

We want to:

1. connect with a plain nREPL client
2. make any assumptions explicit about the nREPL server/runtime
3. connect cljs buffers with those plain repls

1. Check for cider middleware being present, before using it
(already being done)
2. Check for cider-library-present-p, before relying on anything in
the runtime.
3. Make assumptions about the runtime explicit

My suggestion is to solve these problems is `cider-connection-capabilities`.
Currently, there was an implicit assumption about the compilation
error format.

Changes to `cider-repls`:

Now returns cljs, if the repl capabilities include 'cljs.
This way we can make a "plain" clj client, upgrade on connect with
cljs capability and have it be connected in cljs buffers.

This is more a concession / workaround the current repl-type setup.

Here's the slack discussion that lead to this PR:
https://clojurians.slack.com/archives/C04CAKAGADU
---
 CHANGELOG.md   |  2 ++
 cider-connection.el| 34 +-
 cider-eval.el  | 19 +---
 cider-overlays.el  |  1 +
 cider-repl.el  |  3 +-
 cider.el   |  6 +++-
 doc/modules/ROOT/nav.adoc  |  1 +
 .../ROOT/pages/platforms/scittle_and_friends.adoc  | 29 ++
 test/cider-connection-tests.el | 20 +
 9 files changed, 108 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4792e29ff8..a0cad9b5d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,8 @@
 - [#3251](https://github.com/clojure-emacs/cider/pull/3251): Disable undo in 
`*cider-stacktrace*` buffers.
 - Consecutive overlays will not be spuriously deleted.
 - [#3260](https://github.com/clojure-emacs/cider/pull/3260): Scroll REPL 
buffer in other frame.
+- [#3061](https://github.com/clojure-emacs/cider/issues/3061): Allow
+  connect-clj for plain cljs repls (nbb etc).
 
 ## 1.5.0 (2022-08-24)
 
diff --git a/cider-connection.el b/cider-connection.el
index dace071292..ab71b34801 100644
--- a/cider-connection.el
+++ b/cider-connection.el
@@ -343,6 +343,19 @@ buffer."
(when cider-auto-mode
  (cider-enable-on-existing-clojure-buffers))
 
+   (setf cider-connection-capabilities
+ (append
+  (pcase (cider-runtime)
+('clojure '(clojure jvm-compilation-errors))
+('babashka '(babashka jvm-compilation-errors))
+(_ '()))
+  (when
+  ;; see `cider-sync-tooling-eval', but it is defined on a 
higher layer
+  (nrepl-dict-get
+   (nrepl-sync-request:eval "cljs.core/demunge" 
(current-buffer) nil 'tooling)
+   "value")
+'(cljs
+
(run-hooks 'cider-connected-hook)
 
 (defun cider--disconnected-handler ()
@@ -437,6 +450,19 @@ about this buffer (like variable `cider-repl-type')."
   (plist-get nrepl-endpoint :host)
   (plist-get nrepl-endpoint :port))
 
+(defvar-local cider-connection-capabilities '()
+  "A list of some of the capabilites of this connection buffer.
+Aka what assumptions we make about the runtime.
+This is more general than
+`cider-nrepl-op-supported-p' and `cider-library-present-p'.
+But does not need to replace them.")
+
+(defun cider-connection-has-capability-p (capability :optional 
connection-buffer)
+  "Return non nil when the cider connection has CAPABILITY.
+By default it assumes the connection buffer is current."
+  (with-current-buffer (or connection-buffer (current-buffer))
+(member capability cider-connection-capabilities)))
+
 
 ;;; Connection Management Commands
 
@@ -885,7 +911,13 @@ no linked session or there is no REPL of TYPE within the 
current session."
 (cond ((null buffer-repl-type) nil)
   ((or (null type) (eq type 'multi) (eq type 'any)) t)
   ((listp type) (member buffer-repl-type type))
-  (t (string= type buffer-repl-type)
+  (t
+   (or (string= type buffer-repl-type)
+   (let ((capabilities
+  (buffer-local-value 'cider-connection-capabilities 
buffer)))
+ (cond ((listp type)
+(cl-some (lambda (it) (member it capabilities)) type))
+   (t (member type capabilities)
 
 (defun cider--get-host-from-session (session)
  

[nongnu] elpa/cider 43318f39c1 2/2: Fix a typo

2022-12-03 Thread ELPA Syncer
branch: elpa/cider
commit 43318f39c1fb7095bb1997059134fcbe7119ff2b
Author: Bozhidar Batsov 
Commit: Bozhidar Batsov 

Fix a typo
---
 doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc 
b/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc
index 0840dd7869..91ba6a9a4d 100644
--- a/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc
+++ b/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc
@@ -17,7 +17,7 @@ make CIDER more runtime-agnostic.
 
 == The Solution
 
-As of CIDER 1.3, the default CIDER connection command `cider-connect-clj` is
+As of CIDER 1.6, the default CIDER connection command `cider-connect-clj` is
 capable of connecting to any nREPL server that provides minimal required
 functionality.
 



[nongnu] elpa/cider a354b4c6b5 1/2: [Docs] Tweak the Scittle/nbb docs

2022-12-03 Thread ELPA Syncer
branch: elpa/cider
commit a354b4c6b50bdfff38ddc3a622636133ccab33f8
Author: Bozhidar Batsov 
Commit: Bozhidar Batsov 

[Docs] Tweak the Scittle/nbb docs
---
 .../ROOT/pages/platforms/scittle_and_friends.adoc  | 36 --
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc 
b/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc
index 5c72c6460a..0840dd7869 100644
--- a/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc
+++ b/doc/modules/ROOT/pages/platforms/scittle_and_friends.adoc
@@ -1,29 +1,45 @@
-= Scittle, Nbb, Joyride, and future plain repls
+= Scittle, Nbb, Joyride, and future (n)REPLs
 
-The default cider (clj-repl) should be capable of connecting to any
-nrepl server that provides minimal functionality.
+== The Problem
+
+CIDER was created in the early days of Clojure where there weren't any
+of the alternative implementation that exist today. This lead to a design
+that relied on knowledge of certain specifics of Clojure internal and
+the Clojure nREPL server.
+
+Later, with the introduction of ClojureScript we made another set
+of assumptions, related to the way hosted ClojureScript works. (e.g. that
+you start with an ordinary Clojure REPL that gets "upgraded" to a
+ClojureScript REPL by the invocation of a special form)
+
+Lately we've been working to address this and
+make CIDER more runtime-agnostic.
+
+== The Solution
+
+As of CIDER 1.3, the default CIDER connection command `cider-connect-clj` is
+capable of connecting to any nREPL server that provides minimal required
+functionality.
 
 As such, all of these work:
 https://github.com/babashka/nbb[nbb],
 https://github.com/babashka/scittle[scittle], 
https://github.com/BetterThanTomorrow/joyride[joyride]
 
-First start an nrepl server (the project's Readme usually has a section
-on starting a nrepl server).
+First start an nREPL server (the project's Readme usually has a section
+on starting a nREPL server).
 
 You can use
 
 kbd:[M-x `cider-connect-clj` ]
 
-to connect to any plain Clojure(Script) nrepl server.
+to connect to any Clojure(Script) nREPL server.
 
 Features:
 
 * Eval, load file etc.
 * Errors as overlays. (The default cider error buffer is not implemented 
currently).
-* Other nrepl features the server provides; This might be rather minimal.
+* Other nREPL features the server provides; This might be rather minimal.
 
 Nbb, Scittle and Joyride all have quite cool completions already.
 
-== Note
-
-For nbb you can alternatively connect via cljs, see xref:platform/nbb.adoc[Nbb]
+NOTE: For nbb you can alternatively connect via cljs, see 
xref:platform/nbb.adoc[Nbb]



[nongnu] elpa/cider updated (6c5f89bc4e -> 43318f39c1)

2022-12-03 Thread ELPA Syncer
elpasync pushed a change to branch elpa/cider.

  from  6c5f89bc4e Touch up the previous commit
   new  a354b4c6b5 [Docs] Tweak the Scittle/nbb docs
   new  43318f39c1 Fix a typo


Summary of changes:
 .../ROOT/pages/platforms/scittle_and_friends.adoc  | 36 --
 1 file changed, 26 insertions(+), 10 deletions(-)



[elpa] externals/ef-themes edaae8c1d1: Refine ef-themes--toggle-theme-p family check

2022-12-03 Thread ELPA Syncer
branch: externals/ef-themes
commit edaae8c1d1bea8e80a511255086dd9967025f782
Author: Protesilaos Stavrou 
Commit: Protesilaos Stavrou 

Refine ef-themes--toggle-theme-p family check
---
 ef-themes.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ef-themes.el b/ef-themes.el
index 34b2c430e4..b3ffc93911 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -491,7 +491,8 @@ is ignored in this scenario."
 (defun ef-themes--toggle-theme-p ()
   "Return non-nil if `ef-themes-to-toggle' are valid."
   (mapc (lambda (theme)
-  (if (memq theme ef-themes-collection)
+  (if (or (memq theme ef-themes-collection)
+  (memq theme (ef-themes--list-known-themes)))
   theme
 (user-error "`%s' is not part of `ef-themes-collection'" theme)))
 ef-themes-to-toggle))



[nongnu] elpa/helm updated (115847b8d5 -> 75c85ae152)

2022-12-03 Thread ELPA Syncer
elpasync pushed a change to branch elpa/helm.

  from  115847b8d5 Fix bug #2574 by let-binding ffap-machine-p-known
   new  fb8cc8390d Try to fix some use cases where the initial window 
(#2575)
   new  75c85ae152 Do not check no-other-window (#2575)


Summary of changes:
 helm-core.el | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)



[nongnu] elpa/helm fb8cc8390d 1/2: Try to fix some use cases where the initial window (#2575)

2022-12-03 Thread ELPA Syncer
branch: elpa/helm
commit fb8cc8390da2c58094a259b61f8d5a0d87dd0e1f
Author: Thierry Volpiatto 
Commit: Thierry Volpiatto 

Try to fix some use cases where the initial window (#2575)

is not suitable for PA.
---
 helm-core.el | 25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/helm-core.el b/helm-core.el
index 92c33b016d..30d73f0b8f 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -7077,15 +7077,22 @@ splitting inconditionally, it is unused actually."
  (attr-val (if (eq attr 'persistent-action-if)
(funcall (assoc-default attr source) selection)
  (assoc-default attr source)))
- ;; If attr value is a cons, use its car as persistent function
- ;; and its car to decide if helm window should be splitted.
+ ;; If attr value is a cons, use its car as persistent function.
  (fn   (if (and (consp attr-val)
 ;; maybe a lambda.
 (not (functionp attr-val)))
(car attr-val) attr-val))
+ ;; And its cdr to decide if helm window should be splitted.
  (no-split (and (consp attr-val)
 (not (functionp attr-val))
 (cdr attr-val)))
+ ;; Is next-window (from helm-window) a suitable window for PA?
+ (no-suitable-win
+  (helm-aand (not helm--buffer-in-new-frame-p)
+ (next-window (helm-window) 1 helm-initial-frame)
+ (or (window-dedicated-p it)
+ (window-parameter it 'no-other-window)
+ (window-parameter it 'window-side
  (cursor-in-echo-area t)
  mode-line-in-non-selected-windows)
 (progn
@@ -7097,10 +7104,11 @@ splitting inconditionally, it is unused actually."
   (when source
 (with-helm-window
   (save-selected-window
+;; FIXME: Simplify SPLIT behavior, it is a mess actually. 
 (if no-split
 (helm-select-persistent-action-window :split 'never)
   (helm-select-persistent-action-window
-   :split (or split helm-onewindow-p)))
+   :split (or split helm-onewindow-p no-suitable-win)))
 (helm-log "helm-execute-persistent-action"
   "current-buffer = %S" (current-buffer))
 (let ((helm-in-persistent-action t)
@@ -7138,8 +7146,15 @@ The symbol `never' is kept for backward compatibility."
(get-buffer-window-list helm-buffer
  helm-persistent-action-display-window)
 ((and helm--buffer-in-new-frame-p helm-initial-frame)
- (with-selected-frame helm-initial-frame (selected-window)))
-((and split (not (eq split 'never))) (split-window))
+ (with-selected-frame helm-initial-frame
+   (let ((win (selected-window)))
+ (if (or (window-dedicated-p win)
+ (window-parameter win 'no-other-window)
+ (window-parameter win 'window-side))
+ (next-window win 1)
+   win
+((and split (not (eq split 'never)))
+ (split-window))
 ((get-buffer-window helm-current-buffer))
 (t (previous-window (selected-window) 1))
 



[nongnu] elpa/helm-core updated (115847b8d5 -> 75c85ae152)

2022-12-03 Thread ELPA Syncer
elpasync pushed a change to branch elpa/helm-core.

  from  115847b8d5 Fix bug #2574 by let-binding ffap-machine-p-known
  adds  fb8cc8390d Try to fix some use cases where the initial window 
(#2575)
  adds  75c85ae152 Do not check no-other-window (#2575)

No new revisions were added by this update.

Summary of changes:
 helm-core.el | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)



[nongnu] elpa/helm 75c85ae152 2/2: Do not check no-other-window (#2575)

2022-12-03 Thread ELPA Syncer
branch: elpa/helm
commit 75c85ae15286c108d1f32f7ff92f6eaa89a553ef
Author: Thierry Volpiatto 
Commit: Thierry Volpiatto 

Do not check no-other-window (#2575)

no-other-window is already set during the helm session on all windows
beside helm-window to prevent escaping from minibuffer.
So checking only for side or dedicated windows should be enough.
---
 helm-core.el | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/helm-core.el b/helm-core.el
index 30d73f0b8f..0f01dd853d 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -7089,9 +7089,8 @@ splitting inconditionally, it is unused actually."
  ;; Is next-window (from helm-window) a suitable window for PA?
  (no-suitable-win
   (helm-aand (not helm--buffer-in-new-frame-p)
- (next-window (helm-window) 1 helm-initial-frame)
+ (get-buffer-window helm-current-buffer)
  (or (window-dedicated-p it)
- (window-parameter it 'no-other-window)
  (window-parameter it 'window-side
  (cursor-in-echo-area t)
  mode-line-in-non-selected-windows)
@@ -7149,7 +7148,6 @@ The symbol `never' is kept for backward compatibility."
  (with-selected-frame helm-initial-frame
(let ((win (selected-window)))
  (if (or (window-dedicated-p win)
- (window-parameter win 'no-other-window)
  (window-parameter win 'window-side))
  (next-window win 1)
win



[elpa] elpa-admin 835a42acea 2/2: Merge branch 'elpa-admin' of git+ssh://git.sv.gnu.org/srv/git/emacs/elpa into elpa-admin

2022-12-03 Thread Stefan Monnier via
branch: elpa-admin
commit 835a42acea09d1ba626b363ec5f4645142a16e4b
Merge: fd19544fba baa3e4671b
Author: Stefan Monnier 
Commit: Stefan Monnier 

Merge branch 'elpa-admin' of git+ssh://git.sv.gnu.org/srv/git/emacs/elpa 
into elpa-admin
---
 elpa-admin.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/elpa-admin.el b/elpa-admin.el
index 75fb8dc519..22e870f8ca 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -642,10 +642,10 @@ returns.  Return the selected revision."
 (write-region txt nil file nil 'silent)
 (when (and elpaa--email-to
(> (file-attribute-size (file-attributes file))
-  ;; Arbitrarily require a "2 chars increase" minimum
+  ;; Arbitrarily require a "8 chars increase" minimum
   ;; so we don't resend a notification when the timestamp
   ;; in the version got a bit longer.
-  (+ prev-size 2)))
+  (+ prev-size 8)))
   (let ((maintainers (elpaa--maintainers
   (or metadata
   (elpaa--metadata (elpaa--pkg-root pkg)



[elpa] elpa-admin fd19544fba 1/2: * elpa-admin.el (elpaa--select-revision): Simplify

2022-12-03 Thread Stefan Monnier via
branch: elpa-admin
commit fd19544fba19da9060b62dfc6cbcaa04a148698a
Author: Stefan Monnier 
Commit: Stefan Monnier 

* elpa-admin.el (elpaa--select-revision): Simplify
---
 elpa-admin.el | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/elpa-admin.el b/elpa-admin.el
index e8a268b825..75fb8dc519 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -349,11 +349,9 @@ returns.  Return the selected revision."
  (with-temp-buffer
;; Re-select the original branch/commit.
(elpaa--call t "git" "clean" "-x" "-d" "-f")
-   (if oldrev
-   (elpaa--call t "git" "reset" "--hard" oldrev)
- (elpaa--call t "git" "reset" "--hard")
- (when oldbranch
-   (elpaa--call t "git" "checkout" oldbranch)))
+   (elpaa--call t "git" "reset" "--hard" oldrev)
+   (when oldbranch
+ (elpaa--call t "git" "checkout" oldbranch))
(elpaa--message "Restored the head revision\n%s"
(buffer-string
 (or rev cur-rev)))



[nongnu] main ddfb68cf9f: elpa-packages (bash-completion): New package

2022-12-03 Thread Stefan Monnier via
branch: main
commit ddfb68cf9fa55823d815d426910e07ea3a2a5130
Author: Stefan Monnier 
Commit: Stefan Monnier 

elpa-packages (bash-completion): New package
---
 elpa-packages | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/elpa-packages b/elpa-packages
index 36d5f255e5..7fba97f5c1 100644
--- a/elpa-packages
+++ b/elpa-packages
@@ -43,6 +43,9 @@
  (autothemer   :url "https://github.com/jasonm23/autothemer.git";
   :readme "README.md")
 
+ (bash-completion  :url "https://github.com/szermatt/emacs-bash-completion";
+  :readme "README.md")
+
  (better-jumper:url 
"https://github.com/gilbertw1/better-jumper.git";
   :readme "Readme.md"
   :ignored-files ("LICENSE"))
@@ -297,10 +300,10 @@
   :readme "README.md"
   :ignored-files ("LICENSE"))
 
- (hl-column :url "https://codeberg.org/akib/emacs-hl-column";)
-
  (hl-block-mode:url 
"https://codeberg.org/ideasman42/emacs-hl-block-mode";)
 
+ (hl-column :url "https://codeberg.org/akib/emacs-hl-column";)
+
  (htmlize  :url "https://github.com/hniksic/emacs-htmlize";
   :ignored-files ("htmlize.el.html")
   :release-branch "stable")



[elpa] externals/hyperbole updated (b1f33afe37 -> 94c5d6ef99)

2022-12-03 Thread ELPA Syncer
elpasync pushed a change to branch externals/hyperbole.

  from  b1f33afe37 Updates in prep for Emacs and Org talk
   new  a17d305749 Expand smart-org to handle opening and closing src 
block/result hdrs
   new  94c5d6ef99 Update Hyperbole doc for today's pre-release


Summary of changes:
 ChangeLog  |21 +
 hibtypes.el| 9 +-
 hpath.el   |48 +-
 hsys-org.el|14 +-
 hui-mouse.el   |47 +-
 hyperbole.el   | 4 +-
 man/hyperbole.html | 14479 ---
 man/hyperbole.info |   Bin 595856 -> 592243 bytes
 man/hyperbole.pdf  |   Bin 1343289 -> 1344559 bytes
 man/hyperbole.texi |34 +-
 man/version.texi   | 4 +-
 test/hsys-org-tests.el |10 +-
 12 files changed, 7667 insertions(+), 7003 deletions(-)



[elpa] externals/hyperbole a17d305749 1/2: Expand smart-org to handle opening and closing src block/result hdrs

2022-12-03 Thread ELPA Syncer
branch: externals/hyperbole
commit a17d305749429f75863d78c20cc14b3f5bfae4de
Author: Bob Weiner 
Commit: Bob Weiner 

Expand smart-org to handle opening and closing src block/result hdrs

Fix hpath:expand-with-variable to expand local files properly.

Add Ruby traceback messages to grep-msg ibtype.
---
 ChangeLog  | 21 +
 hibtypes.el|  9 ++---
 hpath.el   | 48 ++--
 hsys-org.el| 14 +++---
 hui-mouse.el   | 47 ++-
 hyperbole.el   |  4 ++--
 man/hyperbole.texi | 34 +++---
 man/version.texi   |  4 ++--
 test/hsys-org-tests.el | 10 +-
 9 files changed, 134 insertions(+), 57 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 54d180b177..52a1449def 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2022-12-03  Bob Weiner  
+
+* hpath.el (hpath:expand-with-variable): Fix to expand from local dir first
+before using dirs in hpath:expand-with-variable.
+
+* hibtypes.el (grep-msg): Add support for Ruby traceback stack messages.
+
+* hsys-org.el (hsys-org-src-block-start-at-p): Add.
+  test/hsys-org-tests.el (hsys-org:src-block-start-at-p): Test it.
+
+2022-12-02  Bob Weiner  
+
+* man/hyperbole.texi (Implicit Button Types): Update Smart Key Org mode 
description.
+  hui-mouse.el (smart-org): Add doc for :dir path handling and for removing 
code
+block results with the Assist Key.  Also, make the Smart Keys work the same
+when point is on a #+RESULTS headers as they do when on a code header.
+
 2022-11-27  Bob Weiner  
 
 * hmouse-tag.el (smart-tags-org-src-block-p): Add and use in 
'smart-tags-file-list'
@@ -50,6 +67,10 @@
 * hact.el (htype:symbol): Add as autoload since used in "hsys-youtube.el"
 autoloads.
 
+2022-11-22  Bob Weiner  
+
+* hsys-youtube.el: Add all public functions as autoloads.
+
 2022-11-21  Bob Weiner  
 
 * hycontrol.el (framemove, windmove): Conditionally requires these libs
diff --git a/hibtypes.el b/hibtypes.el
index 65c1589c22..381673e7e5 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -3,7 +3,7 @@
 ;; Author:   Bob Weiner
 ;;
 ;; Orig-Date:19-Sep-91 at 20:45:31
-;; Last-Mod: 26-Nov-22 at 11:44:48 by Bob Weiner
+;; Last-Mod:  3-Dec-22 at 01:08:43 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022 Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -928,8 +928,10 @@ in grep and shell buffers."
 (looking-at "Compiling \\(\\S-+\\)\\.\\.\\.$")
 (looking-at "Loading \\(\\S-+\\) (\\S-+)\\.\\.\\.$")
  ;; Grep matches (allowing for Emacs Lisp vars with : in
-;; name within the pathname), UNIX C compiler and Introl 68HC11 C 
compiler errors
+;; name within the pathname), Ruby, UNIX C compiler and Introl 
68HC11 C compiler errors
  (looking-at "\\([^ \t\n\r\"'`]*[^ \t\n\r:\"'`]\\): 
?\\([1-9][0-9]*\\)[ :]")
+;; Ruby tracebacks
+ (looking-at "[ \t]+[1-9][0-9]*: from \\([^ \t\n\r\"'`]*[^ 
\t\n\r:\"'`]\\):\\([1-9][0-9]*\\):in")
  ;; Grep matches, UNIX C compiler and Introl 68HC11 C
  ;; compiler errors, allowing for file names with
  ;; spaces followed by a null character rather than a :
@@ -1437,7 +1439,8 @@ arg1 ... argN '>'.  For example, ."
(when (and (memq actype '(hy hynote))
   (string-match-p " " lbl))
  (setq lbl (replace-regexp-in-string "\"\\(.*\\)\\'" "\\1\""
- (combine-and-quote-strings 
(split-string lbl) "\" \""
+ (combine-and-quote-strings
+  (split-string lbl) "\" \""
 (setq action (read (concat "(" lbl ")"))
   args (cdr action))
;; Ensure action uses an fboundp symbol if executing a
diff --git a/hpath.el b/hpath.el
index 6dc0d4556f..a75b9269c3 100644
--- a/hpath.el
+++ b/hpath.el
@@ -3,7 +3,7 @@
 ;; Author:   Bob Weiner
 ;;
 ;; Orig-Date: 1-Nov-91 at 00:44:23
-;; Last-Mod:  6-Nov-22 at 11:43:43 by Bob Weiner
+;; Last-Mod:  3-Dec-22 at 02:20:47 by Bob Weiner
 ;;
 ;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
@@ -1258,9 +1258,9 @@ it, else return nil."
 
 (defun hpath:expand-with-variable (path)
   "Prepend to relative PATH the ${load var name} from 
`hpath:auto-variable-alist'.
-When PATH is relative, prepend to it the first file matching regexp in
-`hpath:auto-variable-alist' sans any compression suffix in
-`hpath:compressed-suffix-regexp'.
+When PATH is relative, try to expand in local directory first.  If that fails,
+prepend to it the first file matching regexp in `hpath:auto-variable-alist' 
sans
+any compression suffix in `hpath:compressed-suffix-regexp'.
 If PATH i

[nongnu] branch elpa/bash-completion created (now 8e9c20dbfe)

2022-12-03 Thread ELPA Syncer
elpasync pushed a change to branch elpa/bash-completion.

at  8e9c20dbfe Replace or quote certain single quotes in docstrings 
(#55)

This branch includes the following new commits:

   new  f7bfc68ea2 bash completion
   new  f5885ec87a test case for bash-complete
   new  7dc290e1c7 exclude quotes from result
   new  a79137cc86 escaped quotes
   new  b307dc24c3 keep cword
   new  7ce100b7eb cursor position
   new  208cb5ab76 Join
   new  b281e1e181 bash-complete-add-to-alist
   new  53f2c5d30e parse complete -p output
   new  47a890dd72 launch process, send commands
   new  540f8f516a build bash cmdline
   new  7186a18cad Integrated into comm
   new  f6e1c44057 put everything together
   new  b5c2fbf4a2 add hooks
   new  c10cfef5b8 complex line split
   new  6eebe8f965 cleaned up process launch
   new  0d360a45cd fixed test case
   new  11e52fce6f Fixed initialization
   new  28ec870dd1 only one -complete method
   new  e81c478032 bash-complete -> bash-completion
   new  482383dcd7 handle slash for directory, usable completion
   new  aa9bea48ba fix position
   new  8270e09294 pass words as command-line arguments to the function
   new  34d11220dd add prefix if missing
   new  9eb026ae0b fixed current directory for adding slash, workaround for 
bash ~ expansion
   new  cd2ec103d1 Expand directory names with quotes and spaces, but no 
further
   new  1d7af7e40d Remove debug messages
   new  3036ef0394 disable quote_readline to get good whitespace handling 
for bash 3.2 at least
   new  dda4697cfb included bash-completion into google env
   new  02d1acf260 wordbreaks
   new  3e1481741c remove messages
   new  5b76fc4a33 remove wrong a=b variable prefix handling
   new  3c58afdb0d expand file names in colon-separated paths
   new  fc96b621e2 pass all tests in bash-completion, new test for -send
   new  0ffaad3ef0 wordbreak-split
   new  c28492a749 wordbreak before and after
   new  5931a2ba43 completion-fix
   new  6a0ada6278 completed test cases
   new  581864111e integration test harness, process buffer cleanup, hidden 
buffer
   new  1c6b2efb67 enormous test
   new  0dcf43f91e don't run integration tests by default
   new  5501cb63cf Turn off mail warning
   new  80cd654c35 turn off mailwarn and checkjobs, continue if this failed
   new  a78fd6b587 turn off mailwarn and checkjobs, continue if this failed
   new  21eabde7f9 Reimplemented split
   new  8b02aafc67 separators
   new  e515453141 from an alist to (string start stop)
   new  6b1be0da4c from split to tokenize and parse
   new  9f02a62609 re-enabled parse-line cursor at the beginning/in the 
middle tests
   new  cc1a462415 tested complex line, detect  escaped separators
   new  f5384c6176 A little refactoring, test case for wordbreak completion
   new  062acfab3e updated documentation
   new  ba83e81651 bash-completion-generate-line
   new  a2d322fb79 Added customization group
   new  42441e36b0 more documentation, a little refactoring
   new  1144ae69a9 documented the tokenizer
   new  376dd532e2 modre documentation, up until wordbreak
   new  a8b652d00a commented all functions
   new  9ac7f58758 Gone through compgen
   new  b4fe25b51c update tests for latest refactorings
   new  2390d5cdf3 more commends and documentation; still need a commentary 
section
   new  2d6ad3980a fixes for emacs 22
   new  7697f1a87c comments about tried systems
   new  3f86d75644 Trim strange results that are a subset of the current 
value
   new  7f0160d271 Trim strange results that are a subset of the current 
value: test case
   new  75e5de1494 fix initial completion
   new  3efe7cb03c escape #
   new  9583153e0b Fixed issue with wordbreak character being the first 
character
   new  dd34b278bf stopping at point; the easy way
   new  aadb2e20b2 simplified bash-completion-parse-line
   new  c64ca7a992 simplified parse-current-command, all tests pass
   new  f1d8d73b42 changed comment
   new  ca24f8ada4 forward last open quote
   new  8cc9c2fdc6 bugfix
   new  679d6f7765 bugfix at try afterbreak
   new  49ae0ada64 keep open quote
   new  3ec615a4ef added id
   new  fd7e0e6fbe added documentation
   new  f9903d4bd4 ran checkdoc again, re-ran integration tests
   new  6f7c2b8b4f removed initial version
   new  6fb6bf5588 Mention ghardy bash version
   new  8c771b10d1 fix typo
   new  7615b1bda5 changed e-mail address
   new  1aff6d8806 comment about shell-command
   new  9ca7e3a77f Fixed errors in documentation
   new  3eb77ec9c4 Moved shell configuration into config. Got rid of 
*/init.el, going back to */subdirs.el
   new  7dec35f302 Set MAIL to the empty string in case shopt -u mailwarn 
is not enough (and it 

[nongnu] elpa/bash-completion 7dc290e1c7 003/313: exclude quotes from result

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 7dc290e1c7e14e25f7ec77cc4932f3eb0f053984
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

exclude quotes from result
---
 bash-complete.el  | 33 -
 bash-complete_test.el | 10 +-
 2 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index 3ea39611fb..1b78c8c8eb 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -38,42 +38,49 @@ Return a list containing the words and the number of the 
word
 at POS, the current word: ( (word1 word2 ...) . wordnum )"
   (save-excursion
 (goto-char start)
-(nreverse (bash-complete-split-0 start end pos nil
+(nreverse (bash-complete-split-0 start end pos nil ""
 
-(defun bash-complete-split-0 (start end pos accum)
+(defun bash-complete-split-0 (start end pos accum straccum)
   (let ( (char-start (char-after))
 (quote nil) )
 (when (or (= char-start ?') (= char-start ?\"))
   (forward-char)
   (setq quote char-start))
-(bash-complete-split-1 start end pos quote accum)))
+(bash-complete-split-1 start end pos quote accum straccum)))
 
-(defun bash-complete-split-1 (start end pos quote accum)
-  (skip-chars-forward (bash-complete-nonsep quote) end)
+(defun bash-complete-split-1 (start end pos quote accum straccum)
+  (let ((local-start (point)))
+(skip-chars-forward (bash-complete-nonsep quote) end)
+(setq straccum (concat straccum (buffer-substring-no-properties 
local-start (point)
   (cond
;; an escaped char, skip, whatever it is
((and (char-before) (= ?\\ (char-before)))
 (forward-char)
-(bash-complete-split-1 start end pos (if (and quote (= quote 
(char-before))) nil quote) accum))
+(bash-complete-split-1
+ start end pos
+ (if (and quote (= quote (char-before))) nil quote)
+ accum
+ (concat (substring straccum 0 (- (length straccum) 1))  (char-to-string 
(char-before)
;; opening quote
((and (not quote) (char-after) (or (= ?' (char-after)) (= ?\" 
(char-after
-(bash-complete-split-0 start end pos accum))
+(bash-complete-split-0 start end pos accum straccum))
;; closing quote
((and quote (= quote (char-after)))
 (forward-char)
-(bash-complete-split-0 start end pos accum))
+(bash-complete-split-0 start end pos accum straccum))
;; space inside a quote
((and quote (not (= quote (char-after
 (forward-char)
-(bash-complete-split-1 start end pos quote accum))
+(bash-complete-split-1
+ start end pos quote accum
+ (concat straccum (char-to-string (char-before)
;; word end
(t
-(let ((str (buffer-substring-no-properties start (point
-  (when str
-   (push str accum)))
+(when straccum
+  (push straccum accum))
 (skip-chars-forward " \t\n\r" end)
 (if (< (point) end)
-   (bash-complete-split-0 (point) end pos accum)
+   (bash-complete-split-0 (point) end pos accum "")
   accum
 
 (defun bash-complete-nonsep (quote)
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 55789ef11a..5d6a276124 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -38,25 +38,25 @@
   (sz-testutils-with-buffer
'("a hello\\ world b c")
(bash-complete-split 1 (line-end-position) 0))
-  '("a" "hello\\ world" "b" "c"))
+  '("a" "hello world" "b" "c"))
 
  ("bash-complete-split double quotes"
   (sz-testutils-with-buffer
'("a \"hello world\" b c")
(bash-complete-split 1 (line-end-position) 0))
-  '("a" "\"hello world\"" "b" "c"))
+  '("a" "hello world" "b" "c"))
 
  ("bash-complete-split single quotes"
   (sz-testutils-with-buffer
-   '("a \"hello world\" b c")
+   '("a 'hello world' b c")
(bash-complete-split 1 (line-end-position) 0))
-  '("a" "\"hello world\"" "b" "c"))
+  '("a" "hello world" "b" "c"))
 
  ("bash-complete-split complex quote mix"
   (sz-testutils-with-buffer
'("a hel\"lo w\"o'rld b'c d")
(bash-complete-split 1 (line-end-position) 0))
-  '("a" "hel\"lo w\"o'rld b'c" "d"))
+  '("a" "hello world bc" "d"))
 
   )))
 



[nongnu] elpa/bash-completion 7ce100b7eb 006/313: cursor position

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 7ce100b7eb9df4317b075f045fafa5ceb2ab439d
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

cursor position
---
 bash-complete.el  |  6 --
 bash-complete_test.el | 30 ++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index 8af7b5619b..d12720c2b0 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -77,9 +77,11 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
  (concat straccum (char-to-string (char-before)
;; word end
(t
-(when straccum
-  (setcdr accum (cons straccum (cdr accum
 (skip-chars-forward " \t\n\r" end)
+(when (> (length straccum) 0)
+  (setcdr accum (cons straccum (cdr accum)))
+  (when (and (not (car accum)) (> pos 0) (<= pos (point)))
+   (setcar accum (- (length (cdr accum)) 1
 (if (< (point) end)
(bash-complete-split-0 (point) end pos accum "")
   accum
diff --git a/bash-complete_test.el b/bash-complete_test.el
index d3403a7343..ed832ec4b4 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -34,6 +34,12 @@
(bash-complete-split 1 (line-end-position) 0))
   '(nil . ("a" "hello" "world" "b" "c")))
 
+ ("bash-complete-split simple extra spaces"
+  (sz-testutils-with-buffer
+   '("  a  hello \n world \t b \r c  ")
+   (bash-complete-split 1 (line-end-position 2) 0))
+  '(nil . ("a" "hello" "world" "b" "c")))
+
  ("bash-complete-split escaped space"
   (sz-testutils-with-buffer
'("a hello\\ world b c")
@@ -70,6 +76,30 @@
(bash-complete-split 1 (line-end-position) 0))
   '(nil . ("a" "hello world bc" "d")))
 
+ ("bash-complete-split cursor at end of word"
+  (sz-testutils-with-buffer
+   '("a hello world" cursor " b c")
+   (bash-complete-split 1 (line-end-position) (point)))
+  '(2 . ("a" "hello" "world" "b" "c")))
+
+ ("bash-complete-split cursor in the middle of a word"
+  (sz-testutils-with-buffer
+   '("a hello wo" cursor "rld b c")
+   (bash-complete-split 1 (line-end-position) (point)))
+  '(2 . ("a" "hello" "world" "b" "c")))
+
+ ("bash-complete-split cursor at the beginnig"
+  (sz-testutils-with-buffer
+   '(" " cursor " a hello world b c")
+   (bash-complete-split 1 (line-end-position) (point)))
+  '(0 . ("a" "hello" "world" "b" "c")))
+
+ ("bash-complete-split cursor in the middle"
+  (sz-testutils-with-buffer
+   '("a hello " cursor " world b c")
+   (bash-complete-split 1 (line-end-position) (point)))
+  '(1 . ("a" "hello" "world" "b" "c")))
+
   )))
 
 



[nongnu] elpa/bash-completion 52af1ff8f7 090/313: Really disable mail check this time ? Set MAILCHECK to -1

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 52af1ff8f725b54ba1be8effc4b752ecbb0395d5
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Really disable mail check this time ? Set MAILCHECK to -1
---
 elisp/bash-completion.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/elisp/bash-completion.el b/elisp/bash-completion.el
index eaaf77308e..0cc1471d77 100644
--- a/elisp/bash-completion.el
+++ b/elisp/bash-completion.el
@@ -821,11 +821,11 @@ is set to t."
;; attempt to turn off unexpected status messages from bash
;; if the current version of bash does not support these options,
;; the commands will fail silently and be ignored.
-   ;; export MAIL='' is a desperate attempt to make sure the mail 
warning
-   ;; is really switched off
(bash-completion-send "shopt -u checkjobs" process)
(bash-completion-send "shopt -u mailwarn" process)
-   (bash-completion-send "export MAIL=''" process)
+   (bash-completion-send "export MAILCHECK=-1" process)
+   (bash-completion-send "export -n MAIL" process)
+   (bash-completion-send "export -n MAILPATH" process)
;; some bash completion functions use quote_readline to double-quote
;; strings - which compgen understands but only in some environment.
;; disable this dreadful business to get a saner way of handling



[nongnu] elpa/bash-completion 208cb5ab76 007/313: Join

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 208cb5ab76d6f24acf6f484f4d67bdd91d92d32e
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Join
---
 bash-complete.el  | 16 ++--
 bash-complete_test.el |  8 
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index d12720c2b0..f769d14afa 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -24,12 +24,16 @@ Call bash to do the completion."
  (bash-complete-comm
   line pos words cword)
 
-;; "hell o" wor\ ld 'baa b'a"hell o"world a
-
-;; (progn
-;;   (load-library "~/.emacs.d/bash-complete.el")
-;;   (let ((start 64) (end 108))
-;; (bash-complete-split start end 80)))
+(defun bash-complete-join (words)
+  "Join WORDS into a shell line, escaped all words with single quotes"
+  (if words
+  (concat "'"
+ (mapconcat
+  (lambda (word)
+(replace-regexp-in-string "'" "\\\'" word :literal t))
+  words "' '")
+ "'")
+""))
 
 (defun bash-complete-split (start end pos)
   "Split LINE like bash would do, keep track of current word at POS.
diff --git a/bash-complete_test.el b/bash-complete_test.el
index ed832ec4b4..7f7efe2f71 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -28,6 +28,14 @@
  ;;   GRADER - the desired result or a sexp which determines
  ;;   how we did
 
+ ("bash-complete-join simple"
+  (bash-complete-join '("a" "hello" "world" "b" "c"))
+  "'a' 'hello' 'world' 'b' 'c'")
+
+ ("bash-complete-join escape quote"
+  (bash-complete-join '("a" "hel'lo" "world" "b" "c"))
+  "'a' 'hel\\'lo' 'world' 'b' 'c'")
+
  ("bash-complete-split simple"
   (sz-testutils-with-buffer
'("a hello world b c")



[nongnu] elpa/bash-completion e77c841dac 107/313: Merge pull request #3 from seanmcl/master

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit e77c841dacbbf37cc0bcc0b8577a62ba9904793f
Merge: 983f5c28e9 aedcc114dc
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Merge pull request #3 from seanmcl/master

Fix compilation warnings
---
 bash-completion.el | 63 --
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 263fa39969..ed34c5942e 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -56,7 +56,7 @@
 ;; 'bash-completion-dynamic-complete)
 ;;
 ;;   or simpler, but forces you to load this file at startup:
-;; 
+;;
 ;;   (require 'bash-completion)
 ;;   (bash-completion-setup)
 ;;
@@ -132,11 +132,11 @@
 ;; 2009-11-25   Stephane Zermatten 
 ;;
 ;; * bash-completion-require-process: set MAILCHECK to -1
-;; to disable mail check message. 
+;; to disable mail check message.
 ;;
 ;; 2009-08-01   Stephane Zermatten 
 ;;
-;; * bash-completion-generate-line: add missing compgen 
+;; * bash-completion-generate-line: add missing compgen
 ;; option to complete commands (duh!).
 ;;
 ;; Current version:
@@ -206,6 +206,7 @@ to remove the extra space bash adds after a completion."
 
 (defvar bash-completion-process nil
   "Bash process object.")
+(defvar bash-completion-prefix "" "")
 (defvar bash-completion-alist nil
   "Maps from command name to the 'complete' arguments.
 
@@ -227,6 +228,32 @@ completion in colon-separated values.")
   (append bash-completion-wordbreaks-str nil)
   "`bash-completion-wordbreaks-str' as a list of characters.")
 
+;;; -- Inline functions
+
+(defsubst bash-completion-tokenize-get-range (token)
+  "Return the TOKEN range as a cons: (start . end)."
+  (cdr (assq 'range token)))
+
+(defsubst bash-completion-tokenize-set-end (token)
+  "Set the end position of TOKEN to the cursor position."
+  (setcdr (bash-completion-tokenize-get-range token) (point)))
+
+(defsubst bash-completion-tokenize-append-str (token str)
+  "Append to TOKEN the string STR."
+  (let ((str-cons (assq 'str token)))
+(setcdr str-cons (concat (cdr str-cons) str
+
+(defsubst bash-completion-tokenize-get-str (token)
+  "Return the TOKEN string."
+  (cdr (assq 'str token)))
+
+(defsubst bash-completion-tokenize-open-quote (tokens)
+  "Return the quote character that was still open in the last token.
+
+TOKENS is a list of token as returned by
+`bash-completion-tokenize'."
+  (cdr (assq 'quote (car (last tokens)
+
 ;;; -- Functions: completion
 
 ;;;###autoload
@@ -432,30 +459,6 @@ list of strings.
 TOKENS should be in the format returned by `bash-completion-tokenize'."
   (mapcar 'bash-completion-tokenize-get-str tokens))
 
-(defsubst bash-completion-tokenize-get-range (token)
-  "Return the TOKEN range as a cons: (start . end)."
-  (cdr (assq 'range token)))
-
-(defsubst bash-completion-tokenize-set-end (token)
-  "Set the end position of TOKEN to the cursor position."
-  (setcdr (bash-completion-tokenize-get-range token) (point)))
-
-(defsubst bash-completion-tokenize-append-str (token str)
-  "Append to TOKEN the string STR."
-  (let ((str-cons (assq 'str token)))
-(setcdr str-cons (concat (cdr str-cons) str
-
-(defsubst bash-completion-tokenize-get-str (token)
-  "Return the TOKEN string."
-  (cdr (assq 'str token)))
-
-(defsubst bash-completion-tokenize-open-quote (tokens)
-  "Return the quote character that was still open in the last token.
-
-TOKENS is a list of token as returned by
-`bash-completion-tokenize'."
-  (cdr (assq 'quote (car (last tokens)
-
 (defun bash-completion-tokenize (start end)
   "Tokenize the portion of the current buffer between START and END.
 
@@ -689,8 +692,8 @@ for directory name detection to work."
;; completion is a substring of prefix something's
;; gone wrong. Treat it as one (useless)
;; candidate.
-   (setq prefix "")
-   (setq rest str))
+(setq prefix "")
+str)
   ;; completion sometimes only applies to the last word, as
   ;; defined by COMP_WORDBREAKS. This detects and works around
   ;; this feature.
@@ -1040,7 +1043,7 @@ of the command in the bash completion process buffer."
(unless (accept-process-output process timeout)
  (error "Timeout while waiting for an answer from bash-completion 
process")))
   (goto-char (point-max))
-  (delete-backward-char 1
+  (delete-char -1
 
 (provide 'bash-completion)
 ;;; bash-completion.el ends here



[nongnu] elpa/bash-completion c64ca7a992 071/313: simplified parse-current-command, all tests pass

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit c64ca7a9924946d5eb9bff67ad74d9ad1b55fc56
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

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 3efe7cb03c 067/313: escape #

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 3efe7cb03c1b42831d325823930ee48de9a3a8f9
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

escape #
---
 bash-completion.el  |  9 +
 bash-completion_test.el | 13 -
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 5e19bc327d..ef8d80c201 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -268,7 +268,9 @@ as returned by `bash-completion-parse-line' given the 
current position POS."
   (setq cword index)
   (push "" strings))
 (list
- (cons 'line (buffer-substring-no-properties start (cdr 
(bash-completion-tokenize-get-range token
+ (cons 'line (buffer-substring-no-properties
+ start
+ (cdr (bash-completion-tokenize-get-range token
  (cons 'point (- pos start))
  (cons 'cword cword)
  (cons 'words (nreverse strings)
@@ -496,7 +498,7 @@ Return TOKENS with new tokens prepended to it."
 (bash-completion-tokenize-new-element end tokens
 
 (defconst bash-completion-nonsep-alist
-  '((nil . "^ \t\n\r;&|'\"")
+  '((nil . "^ \t\n\r;&|'\"#")
 (?' . "^ \t\n\r'")
 (?\" . "^ \t\n\r\""))
   "Alist of sets of non-breaking characters.
@@ -566,7 +568,6 @@ Modification include:
 
 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
@@ -612,7 +613,7 @@ like a quoted string.
 Return a possibly escaped version of COMPLETION-CANDIDATE."
   (if (string-match "^['\"]" completion-candidate)
   completion-candidate
-(replace-regexp-in-string "\\([ '\"]\\)" "\\1" completion-candidate)))
+(replace-regexp-in-string "\\([ '\"#]\\)" "\\1" completion-candidate)))
 
 (defconst bash-completion-known-suffixes-regexp
   (concat "[" (regexp-quote bash-completion-wordbreaks-str) "/ ]$")
diff --git a/bash-completion_test.el b/bash-completion_test.el
index b456c22d03..2d10eb5645 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -69,6 +69,13 @@ cases. That's why they need to be enabled manually.")
(bash-completion-tokenize 1 (line-end-position
   '("a" "hello world" "b" "c"))
 
+ ("bash-completion-tokenize escaped #"
+  (sz-testutils-with-buffer
+   '("a hello \\#world\\# b")
+   (bash-completion-strings-from-tokens
+   (bash-completion-tokenize 1 (line-end-position
+  '("a" "hello" "#world#" "b"))
+
  ("bash-completion-tokenize double quotes"
   (sz-testutils-with-buffer
'("a \"hello world\" b c")
@@ -476,13 +483,17 @@ garbage
(bash-completion-nonsep nil)
(bash-completion-nonsep ?')
(bash-completion-nonsep ?\"))
-  '("^ \t\n\r;&|'\"" "^ \t\n\r'" "^ \t\n\r\""))
+  '("^ \t\n\r;&|'\"#" "^ \t\n\r'" "^ \t\n\r\""))
 
 
  ("bash-completion-escape-candidate"
   (bash-completion-escape-candidate "He said: \"hello, 'you'\"")
   "He\\ said:\\ \\\"hello,\\ \\'you\\'\\\"")
 
+ ("bash-completion-escape-candidate"
+  (bash-completion-escape-candidate "#hello#")
+  "\\#hello\\#")
+
  ("bash-completion-escape-candidate not if double quoted"
   (bash-completion-escape-candidate "\"hello, you")
   "\"hello, you")



[nongnu] elpa/bash-completion dda4697cfb 029/313: included bash-completion into google env

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit dda4697cfb25e498216fc545ebe8650139e97885
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

included bash-completion into google env
---
 bash-completion.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index c174ac925b..09aaf77af1 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -332,4 +332,4 @@ Return `bash-completion-alist'."
(push (cons command options) bash-completion-alist
   bash-completion-alist)
 
-(provide 'bash-completion)
\ No newline at end of file
+(provide 'bash-completion)



[nongnu] elpa/bash-completion c10cfef5b8 015/313: complex line split

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit c10cfef5b8ae46c36f98bf3646c17f2382b95f0c
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

complex line split
---
 bash-complete.el  | 51 +++
 bash-complete_test.el | 22 ++
 2 files changed, 53 insertions(+), 20 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index 82a8072c8c..edbd4eacdb 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -35,7 +35,7 @@ Call bash to do the completion."
 
 (defun bash-complete-dynamic-complete-0 ()
 (let* ( (pos (point))
-   (start (comint-line-beginning-position))
+   (start (bash-complete-line-beginning-position))
(end (line-end-position))
(line (buffer-substring-no-properties start end))
(wordsplit)
@@ -52,6 +52,15 @@ Call bash to do the completion."
(bash-complete-comm
line (- pos start) words cword
 
+(defun bash-complete-line-beginning-position (&optional start)
+  (save-excursion
+(let ((start (or start (comint-line-beginning-position)))
+ (end (line-end-position)))
+  (goto-char start)
+  (if (search-forward-regexp "\\(;\\|\\(&&\\)\\|\\(||\\)\\)[ \t\n]" end t)
+ (match-end 0)
+   start
+
 (defun bash-complete-join (words)
   "Join WORDS into a shell line, escaped all words with single quotes"
   (if words
@@ -161,25 +170,27 @@ The result is a list of candidates, which might be empty."
   bash-complete-process)
 
 (defun bash-complete-generate-line (line pos words cword)
-  (let* ( (command (file-name-nondirectory (car words)))
- (compgen-args (cdr (assoc command bash-complete-alist))) )
-(if (not compgen-args)
-   ;; no custom completion. use default completion
-   (bash-complete-join (list "compgen" "-o" "default" (nth cword words)))
-  ;; custom completion
-  (let* ( (args (copy-tree compgen-args))
- (function (or (member "-F" args) (member "-C" args))) )
-   (if function
-   (let ((function-name (car (cdr function
- (setcar function "-F")
- (setcar (cdr function) "__bash_complete_wrapper")
- (format "__BASH_COMPLETE_WRAPPER=%s compgen %s -- %s"
- (bash-complete-quote (format "COMP_LINE=%s; 
COMP_POINT=%s; COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"$@\""
-  (bash-complete-quote line) 
pos cword (bash-complete-join words)
-  (bash-complete-quote 
function-name)))
- (bash-complete-join args)
- (bash-complete-quote (nth cword words
- (format "compgen %s -- %s" (bash-complete-join args) (nth cword 
words)))
+  (concat
+   (if default-directory (concat "cd " (bash-complete-quote default-directory) 
" && ") "")
+   (let* ( (command (file-name-nondirectory (car words)))
+  (compgen-args (cdr (assoc command bash-complete-alist))) )
+ (if (not compgen-args)
+;; no custom completion. use default completion
+(bash-complete-join (list "compgen" "-o" "default" (nth cword words)))
+   ;; custom completion
+   (let* ( (args (copy-tree compgen-args))
+  (function (or (member "-F" args) (member "-C" args))) )
+(if function
+(let ((function-name (car (cdr function
+  (setcar function "-F")
+  (setcar (cdr function) "__bash_complete_wrapper")
+  (format "__BASH_COMPLETE_WRAPPER=%s compgen %s -- %s"
+  (bash-complete-quote (format "COMP_LINE=%s; 
COMP_POINT=%s; COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"$@\""
+   (bash-complete-quote line) 
pos cword (bash-complete-join words)
+   (bash-complete-quote 
function-name)))
+  (bash-complete-join args)
+  (bash-complete-quote (nth cword words
+  (format "compgen %s -- %s" (bash-complete-join args) (nth cword 
words
 
 (defun bash-complete-kill-process ()
   (when (bash-complete-is-running)
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 3a77c25ba7..64e21ba716 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -191,6 +191,28 @@ garbage
   (mapcar 'bash-complete-trim '("  hello " "  world   " "x"))
   '("hello" "world" "x"))
 
+ ("bash-complete-line-beginning-position start"
+  (sz-testutils-with-buffer
+   "cd /home/x"
+   (bash-complete-line-beginning-position 1))
+  1)
+
+ ("bash-complete-line-beginning-position semicolon"
+  (sz-testutils-with-buffer
+   '("cd /home/x ; " cursor "echo hello")
+   (list
+   (point)
+   (bash-complete-line-beginning-position 1)))
+  '(14 14))
+
+ ("bash-complete-line-beginning-position &&"
+  (sz-testutils-with-buffer
+   '("cd /hom

[nongnu] elpa/bash-completion ba83e81651 053/313: bash-completion-generate-line

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit ba83e8165195cd37be6f2101a0e0bd5ae14bfb99
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

bash-completion-generate-line
---
 bash-completion.el | 53 +++--
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 1ecfecc816..4649607009 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -407,29 +407,38 @@ The result is a list of candidates, which might be empty."
   (concat
(bash-completion-cd-command-prefix)
(let* ( (command-name (file-name-nondirectory (car words)))
-  (compgen-args (cdr (assoc command-name bash-completion-alist))) )
- (if (not compgen-args)
-;; no custom completion. use default completion
-(if (= cword 0)
-;; a command. let emacs expand executable, let bash
-;; expand builtins, aliases and functions
-(concat (bash-completion-join (list "compgen" "-S" " " "-b" "-a" 
"-A" "function" (car words
-  ;; argument
-  (bash-completion-join (list "compgen" "-o" "default" (nth cword 
words
-   ;; custom completion
+  (compgen-args (cdr (assoc command-name bash-completion-alist)))
+  (stub (nth cword words)) )
+ (cond
+  ((= cword 0)
+   ;; a command. let emacs expand executable, let bash
+   ;; expand builtins, aliases and functions
+   (concat "compgen -S ' ' -b -a -A function " stub))
+
+  ((not compgen-args)
+   ;; no completion configured for this command
+   (bash-completion-join (list "compgen" "-o" "default" stub)))
+
+  ((or (member "-F" compgen-args) (member "-C" compgen-args))
+   ;; custom completion with a function of command
(let* ( (args (copy-tree compgen-args))
-  (function (or (member "-F" args) (member "-C" args))) )
-(if function
-(let ((function-name (car (cdr function
-  (setcar function "-F")
-  (setcar (cdr function) "__bash_complete_wrapper")
-  (format "__BASH_COMPLETE_WRAPPER=%s compgen %s -- %s"
-  (bash-completion-quote (format "COMP_LINE=%s; 
COMP_POINT=%s; COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"${COMP_WORDS[@]}\""
-   (bash-completion-quote 
line) pos cword (bash-completion-join words)
-   (bash-completion-quote 
function-name)))
-  (bash-completion-join args)
-  (bash-completion-quote (nth cword words
-  (format "compgen %s -- %s" (bash-completion-join args) (nth cword 
words
+  (function (or (member "-F" args) (member "-C" args)))
+  (function-name (car (cdr function))) )
+(setcar function "-F")
+(setcar (cdr function) "__bash_complete_wrapper")
+(format "__BASH_COMPLETE_WRAPPER=%s compgen %s -- %s"
+(bash-completion-quote
+ (format "COMP_LINE=%s; COMP_POINT=%s; COMP_CWORD=%s; 
COMP_WORDS=( %s ); %s \"${COMP_WORDS[@]}\""
+ (bash-completion-quote line)
+ pos
+ cword
+ (bash-completion-join words)
+ (bash-completion-quote function-name)))
+(bash-completion-join args)
+(bash-completion-quote stub
+  (t
+   ;; simple custom completion
+   (format "compgen %s -- %s" (bash-completion-join compgen-args) 
stub))
 
 (defun bash-completion-reset ()
   (interactive)



[nongnu] elpa/bash-completion 80cd654c35 043/313: turn off mailwarn and checkjobs, continue if this failed

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 80cd654c35c49bcebc8b4d1af9b95a8615b22445
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

turn off mailwarn and checkjobs, continue if this failed
---
 bash-completion.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index cdc46491d8..d1f30559fd 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -262,7 +262,7 @@ The result is a list of candidates, which might be empty."
   "*bash-completion*"
   (generate-new-buffer-name " bash-completion")
   bash-completion-prog
-  "--noediting" "+O" "mailwarn"))
+  "--noediting"))
(set-process-query-on-exit-flag process nil)
(let* ((shell-name (file-name-nondirectory bash-completion-prog))
   (startfile1 (concat "~/.emacs_" shell-name ".sh"))
@@ -274,6 +274,7 @@ The result is a list of candidates, which might be empty."
(process-send-string process (concat ". " startfile2 "\n")
(bash-completion-send "PS1='\v'" process 
bash-completion-initial-timeout)
(bash-completion-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER; }" process)
+   (bash-completion-send "shopt -u mailwarn; shopt -u checkjobs" 
process)
;; some bash completion functions use quote_readline to double-quote
;; strings - which compgen understands but only in some environment.
;; disable this dreadful business to get a saner way of handling



[nongnu] elpa/bash-completion a79137cc86 004/313: escaped quotes

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit a79137cc8690c9ce1379e2690ade76556bbf489b
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

escaped quotes
---
 bash-complete.el  |  7 +++
 bash-complete_test.el | 12 
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index 1b78c8c8eb..06df1d4b3a 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -57,19 +57,18 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
((and (char-before) (= ?\\ (char-before)))
 (forward-char)
 (bash-complete-split-1
- start end pos
- (if (and quote (= quote (char-before))) nil quote)
+ start end pos quote
  accum
  (concat (substring straccum 0 (- (length straccum) 1))  (char-to-string 
(char-before)
;; opening quote
((and (not quote) (char-after) (or (= ?' (char-after)) (= ?\" 
(char-after
 (bash-complete-split-0 start end pos accum straccum))
;; closing quote
-   ((and quote (= quote (char-after)))
+   ((and quote (char-after) (= quote (char-after)))
 (forward-char)
 (bash-complete-split-0 start end pos accum straccum))
;; space inside a quote
-   ((and quote (not (= quote (char-after
+   ((and quote (char-after) (not (= quote (char-after
 (forward-char)
 (bash-complete-split-1
  start end pos quote accum
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 5d6a276124..3c6f9447b6 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -46,12 +46,24 @@
(bash-complete-split 1 (line-end-position) 0))
   '("a" "hello world" "b" "c"))
 
+ ("bash-complete-split double quotes escaped"
+  (sz-testutils-with-buffer
+   '("a \"-\\\"hello world\\\"-\" b c")
+   (bash-complete-split 1 (line-end-position) 0))
+  '("a" "-\"hello world\"-" "b" "c"))
+
  ("bash-complete-split single quotes"
   (sz-testutils-with-buffer
'("a 'hello world' b c")
(bash-complete-split 1 (line-end-position) 0))
   '("a" "hello world" "b" "c"))
 
+ ("bash-complete-split single quotes escaped"
+  (sz-testutils-with-buffer
+   '("a '-\\'hello world\\'-' b c")
+   (bash-complete-split 1 (line-end-position) 0))
+  '("a" "-'hello world'-" "b" "c"))
+
  ("bash-complete-split complex quote mix"
   (sz-testutils-with-buffer
'("a hel\"lo w\"o'rld b'c d")



[nongnu] elpa/bash-completion c8ddd11ec3 113/313: Fix tests after "Make bash-completion.el work

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit c8ddd11ec36bb92b2bcd1a4ca5e9ae549d298f89
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Fix tests after "Make bash-completion.el work
under emacs trunk."
---
 bash-completion_test.el | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/bash-completion_test.el b/bash-completion_test.el
index 2c797459b9..c829bda400 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -188,7 +188,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "a hello world")
(point . 13)
(cword . 2)
-   (words . ("a" "hello" "world"
+   (words . ("a" "hello" "world"))
+   (stub-start . 9)))
 
  ("bash-completion-parse-line cursor in the middle of a word"
   (sz-testutils-with-buffer
@@ -197,7 +198,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "a hello wo")
(point . 10)
(cword . 2)
-   (words . ("a" "hello" "wo"
+   (words . ("a" "hello" "wo"))
+   (stub-start . 9)))
 
  ("bash-completion-parse-line cursor at the beginning"
   (sz-testutils-with-buffer
@@ -206,7 +208,9 @@ cases. That's why they need to be enabled manually.")
   '((line . "")
(point . 0)
(cword . 0)
-   (words . (""
+   (words . (""))
+   (stub-start . 2)
+   ))
 
  ("bash-completion-parse-line cursor in the middle"
   (sz-testutils-with-buffer
@@ -215,7 +219,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "a hello ")
(point . 8)
(cword . 2)
-   (words . ("a" "hello" ""
+   (words . ("a" "hello" ""))
+   (stub-start . 9)))
 
  ("bash-completion-parse-line cursor at end"
   (sz-testutils-with-buffer
@@ -224,7 +229,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "a hello world b c")
(point . 17)
(cword . 4)
-   (words . ("a" "hello" "world" "b" "c"
+   (words . ("a" "hello" "world" "b" "c"))
+   (stub-start . 17)))
 
  ("bash-completion-parse-line complex multi-command line"
   (sz-testutils-with-buffer
@@ -233,7 +239,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "make -")
(point . 6)
(cword . 1)
-   (words . ("make" "-"
+   (words . ("make" "-"))
+   (stub-start . 27)))
 
 
  ("bash-completion-parse-line pipe"
@@ -243,7 +250,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "sort -")
(point . 6)
(cword . 1)
-   (words . ("sort" "-"
+   (words . ("sort" "-"))
+   (stub-start . 20)))
 
  ("bash-completion-parse-line escaped semicolon"
   (sz-testutils-with-buffer
@@ -252,7 +260,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "find -name '*.txt' -exec echo {} ';' -")
(point . 38)
(cword . 7)
-   (words . ("find" "-name" "*.txt" "-exec" "echo" "{}" ";" "-"
+   (words . ("find" "-name" "*.txt" "-exec" "echo" "{}" ";" "-"))
+   (stub-start . 38)))
 
  ("bash-completion-parse-line at var assignment"
   (sz-testutils-with-buffer
@@ -261,7 +270,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "ZORG=t")
(point . 6)
(cword . 0)
-   (words . ("ZORG=t"
+   (words . ("ZORG=t"))
+   (stub-start . 19)))
 
  ("bash-completion-parse-line cursor after end"
   (sz-testutils-with-buffer
@@ -270,7 +280,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "a hello world b c ")
(point . 18)
(cword . 5)
-   (words . ("a" "hello" "world" "b" "c" ""
+   (words . ("a" "hello" "world" "b" "c" ""))
+   (stub-start . 19)))
 
  ("bash-completion-parse-line with escaped quote"
   (sz-testutils-with-buffer
@@ -279,7 +290,8 @@ cases. That's why they need to be enabled manually.")
   '((line . "cd /vcr/shows/Dexter\\'s")
(point . 23)
(cword . 1)
-   (words . ("cd" "/vcr/shows/Dexter's"
+   (words . ("cd" "/vcr/shows/Dexter's"))
+   (stub-start . 4)))
 
  ("bash-completion-add-to-alist garbage"
   (let ((bash-completion-alist nil))



[nongnu] elpa/bash-completion 96d764fb18 095/313: removed unnecessary quote escapes in documentation

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 96d764fb18035e429368cefedf512ec06c350953
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

removed unnecessary quote escapes in documentation
---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6fca099524..7588de29e0 100644
--- a/README.md
+++ b/README.md
@@ -29,8 +29,8 @@ shell-command prompts.
 2. add this into your .emacs file:
 
 (autoload 'bash-completion-dynamic-complete 
-  \"bash-completion\"
-  \"BASH completion hook\")
+  "bash-completion"
+  "BASH completion hook")
 (add-hook 'shell-dynamic-complete-functions
   'bash-completion-dynamic-complete)
 (add-hook 'shell-command-complete-functions



[nongnu] elpa/bash-completion 7186a18cad 012/313: Integrated into comm

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 7186a18cadef47f0406b6b56c11de9166d64a0c5
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Integrated into comm
---
 bash-complete.el  | 11 +++
 bash-complete_test.el | 14 +++---
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index 3f9292f379..0a2547d2f3 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -52,7 +52,9 @@ Call bash to do the completion."
 (defun bash-complete-quote (word)
   (if (string-match "^[a-zA-Z0-9_.-]*$" word)
   word
-(concat "'" (replace-regexp-in-string "'" "\\\'" word :literal t) "'")))
+(concat "'"
+   (replace-regexp-in-string "'" "'\\''" word :literal t)
+   "'")))
 
 (defun bash-complete-split (start end pos)
   "Split LINE like bash would do, keep track of current word at POS.
@@ -122,8 +124,9 @@ 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-complete-send (concat (bash-complete-generate-line line pos words 
cword) " 2>/dev/null"))
+  (with-current-buffer (bash-complete-buffer)
+(split-string (buffer-string) "\n" t)))
 
 (defun bash-complete-require-process ()
   ;; TODO(szermatt): if this fails, kill process and complain
@@ -136,8 +139,8 @@ The result is a list of candidates, which might be empty."
   "--noediting"))
 (set-process-query-on-exit-flag bash-complete-process nil)
 (bash-complete-send "PS1='\v'")
+(bash-complete-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER; }")
 (bash-complete-send "complete -p")
-(bash-complete-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER }")
 (bash-complete-build-alist (process-buffer bash-complete-process)))
   bash-complete-process)
 
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 41b93c7356..3969b7303c 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -34,7 +34,7 @@
 
  ("bash-complete-join escape quote"
   (bash-complete-join '("a" "hel'lo" "world" "b" "c"))
-  "a 'hel\\'lo' world b c")
+  "a 'hel'\\''lo' world b c")
 
  ("bash-complete-join escape space"
   (bash-complete-join '("a" "hello world" "b" "c"))
@@ -72,7 +72,7 @@
 
  ("bash-complete-split single quotes"
   (sz-testutils-with-buffer
-   '("a 'hello world' b c")
+   '("a \"hello world\" b c")
(bash-complete-split 1 (line-end-position) 0))
   '(nil . ("a" "hello world" "b" "c")))
 
@@ -159,13 +159,13 @@ garbage
   (bash-complete-quote "hello")
   "hello")
 
- ("bash-complete-quote not necessary"
+ ("bash-complete-quote space"
   (bash-complete-quote "hello world")
   "'hello world'")
 
- ("bash-complete-quote not necessary"
+ ("bash-complete-quote quote"
   (bash-complete-quote "hell'o")
-  "'hell\\'o'")
+  "'hell'\\''o'")
 
  ("bash-complete-generate-line no custom completion"
   (let ((bash-complete-alist nil))
@@ -180,12 +180,12 @@ garbage
  ("bash-complete-generate-line custom completion function"
   (let ((bash-complete-alist '(("zorg" . ("-F" "__zorg")
(bash-complete-generate-line "zorg worl" 7 '("zorg" "worl") 1))
-  "__BASH_COMPLETE_WRAPPER='COMP_LINE=\\'zorg worl\\'; COMP_POS=7; 
COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper worl")
+  "__BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; COMP_POS=7; 
COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper worl")
 
  ("bash-complete-generate-line custom completion command"
   (let ((bash-complete-alist '(("zorg" . ("-C" "__zorg")
(bash-complete-generate-line "zorg worl" 7 '("zorg" "worl") 1))
-  "__BASH_COMPLETE_WRAPPER='COMP_LINE=\\'zorg worl\\'; COMP_POS=7; 
COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper worl")
+  "__BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; COMP_POS=7; 
COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper worl")
 
   )))
 



[nongnu] elpa/bash-completion e515453141 047/313: from an alist to (string start stop)

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit e5154531415d2d92216b781a8156e066f05e5e3b
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

from an alist to (string start stop)
---
 bash-completion.el | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 74ec8792d5..61f37f2301 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -135,17 +135,16 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
   (cons cword (nreverse strings)
 
 (defsubst bash-completion-split-raw-get-range (current)
-  (cons (cdr (assq 'start current)) (cdr (assq 'end current
+  (cdr current))
 
 (defsubst bash-completion-split-raw-set-end (current)
-  (setcdr (assq 'end current) (point)))
+  (setcdr (cdr current) (point)))
 
 (defsubst bash-completion-split-raw-append-str (current str)
-  (let* ((str-cons (assq 'str current)) (straccum (cdr str-cons)))
-(setcdr str-cons (concat straccum str
+  (setcar current (concat (car current) str)))
 
 (defsubst bash-completion-split-raw-get-str (current)
-  (cdr (assq 'str current)))
+  (car current))
 
 (defun bash-completion-split-raw (start end)
   (save-excursion
@@ -155,9 +154,7 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
 (defun bash-completion-split-raw-new-element (end accum)
   (skip-chars-forward " \t\n\r" end)
   (if (< (point) end)
-  (bash-completion-split-raw-0 end accum (list (cons 'str "")
-  (cons 'start (point))
-  (cons 'end nil)))
+  (bash-completion-split-raw-0 end accum (list "" (point)))
 accum))
 
 (defun bash-completion-split-raw-0 (end accum current)



[nongnu] elpa/bash-completion 02d1acf260 030/313: wordbreaks

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 02d1acf2602a93ae7280ead2ca425f27d00744c2
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

wordbreaks
---
 bash-completion.el | 75 +-
 1 file changed, 51 insertions(+), 24 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 09aaf77af1..7b0102e736 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -170,23 +170,50 @@ The result is a list of candidates, which might be empty."
(with-current-buffer (bash-completion-buffer)
  (split-string (buffer-string) "\n" t)
 
-(defun bash-completion-fix (str)
-  (bash-completion-addsuffix 
-   (let* ((rest (cond
-   ((bash-completion-starts-with str bash-completion-prefix)
-(substring str (length bash-completion-prefix)))
-   ;; bash expands the home directory automatic. this is confusing
-   ;; for comint-dynamic-simple-complete
-   ((and (bash-completion-starts-with bash-completion-prefix "~")
- (bash-completion-starts-with str (expand-file-name "~")))
-(substring (concat "~" (substring str (length 
(expand-file-name "~"
-   (length bash-completion-prefix)))
-   ;; bash sometimes just prints whatever needs to be expanded,
-   ;; for example: "export PATH=". Prepend the old
-   ;; prefix to avoid confusing comint-dynamic-simple-complete
-   (t str
- (concat bash-completion-prefix (bash-completion-escape rest)
-
+(defun bash-completion-fix (str &optional prefix)
+  (let ((prefix (or prefix bash-completion-prefix))
+   (suffix ""))
+(bash-completion-addsuffix 
+ (let* ((rebuilt)
+   (rest (cond
+  ((bash-completion-starts-with str prefix)
+   (substring str (length prefix)))
+  ;; bash expands the home directory automatically. This is 
confusing
+  ;; for comint-dynamic-simple-complete
+  ((and (bash-completion-starts-with prefix "~")
+(bash-completion-starts-with str (expand-file-name 
"~")))
+   (substring (concat "~" (substring str (length 
(expand-file-name "~"
+  (length prefix)))
+  ;; bash sometimes just prints whatever needs to be expanded,
+  ;; for example: "export PATH=". Prepend the old
+  ;; prefix to avoid confusing comint-dynamic-simple-complete
+  ((bash-completion-starts-with 
+(setq rebuilt (concat 
(bash-completion-before-last-wordbreak prefix) str))
+prefix)
+   (substring rebuilt (length prefix)))
+  (t str
+   (when (bash-completion-ends-with rest " ")
+(setq rest (substring rest 0 -1))
+(setq suffix " "))
+   (message "str=>%s< rest=>%s< prefix=>%s<" str rest prefix)
+   (concat prefix (bash-completion-escape rest) suffix)
+
+(defun bash-completion-before-last-wordbreak (str)
+  (catch 'bash-completion-return 
+(let ((end (- (length str) 1)))
+  (while (> end 0)
+   (when (memq (aref str end) '( ?' ?@ ?> ?< ?= ?\; ?| ?& ?\( ?: ))
+ (throw 'bash-completion-return (substring str 0 (1+ end
+   (setq end (1- end
+  str))
+  
+(defun bash-completion-ends-with (str prefix)
+  (let ((prefix-len (length prefix))
+   (str-len (length str)))
+(and
+ (>= str-len prefix-len)
+ (equal (substring str (- prefix-len)) prefix
+  
 (defun bash-completion-starts-with (str prefix)
   (let ((prefix-len (length prefix))
(str-len (length str)))
@@ -195,12 +222,12 @@ The result is a list of candidates, which might be empty."
  (equal (substring str 0 prefix-len) prefix
 
 (defun bash-completion-addsuffix (str)
-  (let ((end (substring str -1)))
-(if (and (not (eq end " "))
-(not (eq end "/"))
-(file-accessible-directory-p (expand-file-name str 
default-directory)))
-   (concat str "/")
-str)))
+  (if (and (null (string-match "[/: ]$" str))
+  (file-accessible-directory-p (expand-file-name str 
default-directory)))
+  (progn
+   (message "accessible: %s" (expand-file-name str default-directory))
+   (concat str "/"))
+str))
 
 (defun bash-completion-require-process ()
   (if (bash-completion-is-running)
@@ -231,7 +258,7 @@ The result is a list of candidates, which might be empty."
;; strings - which compgen understands but only in some environment.
;; disable this dreadful business to get a saner way of handling
;; spaces.
-   (bash-completion-send "function quote_readline { echo \"$1\"; }")
+   (bash-completion-send "function quote_readline { echo \"$1\"; }" 
process)
(bash-completion-send "complete -p" pro

[nongnu] elpa/bash-completion 664452aca2 157/313: Merge pull request #22 from kfogel/21-fix-completion-re-21149fdc

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 664452aca2aa4a1f0c95848a41b81eae6d35cd51
Merge: a789093cd3 081d03bedc
Author: Stephane Zermatten 
Commit: GitHub 

Merge pull request #22 from kfogel/21-fix-completion-re-21149fdc

Fix issue #21 completion bug
---
 bash-completion.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 724697581a..79fd1aa473 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -991,8 +991,8 @@ is set to t."
(set-process-query-on-exit-flag process nil)
(let ((shell-name (file-name-nondirectory bash-completion-prog)))
   (dolist (start-file bash-completion-start-files)
-((file-exists-p startfile1)
- (process-send-string process (concat ". " startfile1 "\n")
+(when (file-exists-p start-file)
+  (process-send-string process (concat ". " start-file 
"\n")
(bash-completion-send "PROMPT_COMMAND='';PS1='\t$?\v'" process 
bash-completion-initial-timeout)
(bash-completion-send (concat "function __bash_complete_wrapper {"
  " eval $__BASH_COMPLETE_WRAPPER;"



[nongnu] elpa/bash-completion 0af9a70ff9 130/313: Merge pull request #16 from tarsius/master

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 0af9a70ff9f3951ac2a797c0e0b9a5adef1b16f3
Merge: 1659c7ca38 c5f2b2756f
Author: Stephane Zermatten 
Commit: GitHub 

Merge pull request #16 from tarsius/master

Fix various issues reported by the byte-compiler
---
 bash-completion-test.el | 1 -
 bash-completion.el  | 3 ++-
 sz-testutils.el | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bash-completion-test.el b/bash-completion-test.el
index 11c32f7928..b400fd36d7 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -31,7 +31,6 @@
 ;;; Code:
 (require 'ert)
 (require 'sz-testutils)
-(require 'cl)
 (require 'bash-completion)
 
 (defun bash-completion-test-send (buffer-content)
diff --git a/bash-completion.el b/bash-completion.el
index 49bbaf75d0..93bd540150 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -299,7 +299,8 @@ nil if no completions available."
;; configuration for comint-dynamic-simple-complete.
;; Bash adds a space suffix automatically.
(comint-completion-addsuffix nil))
-   (comint-dynamic-simple-complete stub completions))
+   (with-no-warnings
+ (comint-dynamic-simple-complete stub completions)))
 
 (defun bash-completion-dynamic-complete-0 ()
   "Returns completion information for bash command at point.
diff --git a/sz-testutils.el b/sz-testutils.el
index fbc2b84bd6..dc2cad6cc2 100644
--- a/sz-testutils.el
+++ b/sz-testutils.el
@@ -108,7 +108,7 @@ is: '(\"Here >>\" cursor \"<<.\")"
 (eval-when-compile
   ;; This code will not appear in the compiled (.elc) file
   (put 'sz-testutils-regress 'regression-suite t)
-  (setq sz-testutils-regress
+  (defvar sz-testutils-regress
'("sz-testutils-regress"
  ;; Each test in the suite is of the form:
  ;;   ([description] probe grader)
@@ -167,4 +167,4 @@ is: '(\"Here >>\" cursor \"<<.\")"
   (if (featurep 'regress)
   (regress sz-testutils-regress)))
 
-(provide 'sz-testutils)
\ No newline at end of file
+(provide 'sz-testutils)



[nongnu] elpa/bash-completion 47a890dd72 010/313: launch process, send commands

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 47a890dd721a9fa80ff94840b05cf0c3d8261369
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

launch process, send commands
---
 bash-complete.el | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/bash-complete.el b/bash-complete.el
index 0a2567d88d..e102496f33 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -1,6 +1,10 @@
 
 (require 'comint)
 
+(defvar bash-complete-executable "bash"
+  "Command-line to execute bash")
+(defvar bash-complete-process-timeout 2.5)
+
 (defvar bash-complete-process nil
   "Bash process object")
 (defvar bash-complete-alist nil
@@ -119,6 +123,41 @@ The result is a list of candidates, which might be empty."
 
   )
 
+(defun bash-complete-require-process ()
+  ;; TODO(szermatt): if this fails, kill process and complain
+  (unless (bash-complete-is-running)
+(setq bash-complete-process
+ (start-process
+  "*bash-complete*"
+  "*bash-complete*"
+  bash-complete-executable
+  "--noediting"))
+(set-process-query-on-exit-flag bash-complete-process nil)
+(bash-complete-send "PS1='\v'")
+(bash-complete-send "complete -p")
+(bash-complete-build-alist (process-buffer bash-complete-process)))
+  bash-complete-process)
+
+(defun bash-complete-kill-process ()
+  (when (bash-complete-is-running)
+(kill-process bash-complete-process)))
+
+(defun bash-complete-buffer ()
+  (process-buffer (bash-complete-require-process)))
+
+(defun bash-complete-is-running ()
+  (and bash-complete-process (eq 'run (process-status bash-complete-process
+
+(defun bash-complete-send (commandline)
+  (with-current-buffer (bash-complete-buffer)
+(erase-buffer)
+(process-send-string bash-complete-process (concat commandline "\n"))
+(while (not (progn (goto-char 1) (search-forward "\v" nil t)))
+  (unless (accept-process-output bash-complete-process 
bash-complete-process-timeout)
+   (error "Timeout while waiting for an answer from bash-complete 
process")))
+(goto-char (point-max))
+(delete-backward-char 1)))
+
 (defun bash-complete-build-alist (buffer)
   "Build `bash-complete-alist' with the content of BUFFER.
 



[nongnu] elpa/bash-completion 3f86d75644 064/313: Trim strange results that are a subset of the current value

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 3f86d756448ed6fd34d4b56c6681870ca1835cbf
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Trim strange results that are a subset of the current value
---
 bash-completion.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/bash-completion.el b/bash-completion.el
index 3419ffb127..8490821400 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -577,6 +577,12 @@ for directory name detection to work."
 (bash-completion-starts-with str (expand-file-name 
"~")))
(substring (concat "~" (substring str (length 
(expand-file-name "~"
   (length prefix)))
+  ((bash-completion-starts-with prefix str)
+   ;; completion is a substring of prefix something's
+   ;; gone wrong. Treat it as one (useless)
+   ;; candidate.
+   (setq prefix "")
+   (setq rest str))
   ;; completion sometimes only applies to the last word, as
   ;; defined by COMP_WORDBREAKS. This detects and works around
   ;; this feature.



[nongnu] elpa/bash-completion 540f8f516a 011/313: build bash cmdline

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 540f8f516ab5d297333537b5f990f55402670a99
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

build bash cmdline
---
 bash-complete.el  | 36 ++--
 bash-complete_test.el | 40 ++--
 2 files changed, 68 insertions(+), 8 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index e102496f33..3f9292f379 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -44,14 +44,16 @@ Call bash to do the completion."
 (defun bash-complete-join (words)
   "Join WORDS into a shell line, escaped all words with single quotes"
   (if words
-  (concat "'"
- (mapconcat
-  (lambda (word)
-(replace-regexp-in-string "'" "\\\'" word :literal t))
-  words "' '")
- "'")
+  (mapconcat
+   'bash-complete-quote
+   words " ")
 ""))
 
+(defun bash-complete-quote (word)
+  (if (string-match "^[a-zA-Z0-9_.-]*$" word)
+  word
+(concat "'" (replace-regexp-in-string "'" "\\\'" word :literal t) "'")))
+
 (defun bash-complete-split (start end pos)
   "Split LINE like bash would do, keep track of current word at POS.
 
@@ -135,9 +137,31 @@ The result is a list of candidates, which might be empty."
 (set-process-query-on-exit-flag bash-complete-process nil)
 (bash-complete-send "PS1='\v'")
 (bash-complete-send "complete -p")
+(bash-complete-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER }")
 (bash-complete-build-alist (process-buffer bash-complete-process)))
   bash-complete-process)
 
+(defun bash-complete-generate-line (line pos words cword)
+  (let* ( (command (file-name-nondirectory (car words)))
+ (compgen-args (cdr (assoc command bash-complete-alist))) )
+(if (not compgen-args)
+   ;; no custom completion. use default completion
+   (bash-complete-join (list "compgen" "-o" "default" (nth cword words)))
+  ;; custom completion
+  (let* ( (args (copy-tree compgen-args))
+ (function (or (member "-F" args) (member "-C" args))) )
+   (if function
+   (let ((function-name (car (cdr function
+ (setcar function "-F")
+ (setcar (cdr function) "__bash_complete_wrapper")
+ (format "__BASH_COMPLETE_WRAPPER=%s compgen %s %s"
+ (bash-complete-quote (format "COMP_LINE=%s; COMP_POS=%s; 
COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"$@\""
+  (bash-complete-quote line) 
pos cword (bash-complete-join words)
+  (bash-complete-quote 
function-name)))
+ (bash-complete-join args)
+ (bash-complete-quote (nth cword words
+ (format "compgen %s %s" (bash-complete-join args) (nth cword 
words)))
+
 (defun bash-complete-kill-process ()
   (when (bash-complete-is-running)
 (kill-process bash-complete-process)))
diff --git a/bash-complete_test.el b/bash-complete_test.el
index 31b17544db..41b93c7356 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -30,11 +30,15 @@
 
  ("bash-complete-join simple"
   (bash-complete-join '("a" "hello" "world" "b" "c"))
-  "'a' 'hello' 'world' 'b' 'c'")
+  "a hello world b c")
 
  ("bash-complete-join escape quote"
   (bash-complete-join '("a" "hel'lo" "world" "b" "c"))
-  "'a' 'hel\\'lo' 'world' 'b' 'c'")
+  "a 'hel\\'lo' world b c")
+
+ ("bash-complete-join escape space"
+  (bash-complete-join '("a" "hello world" "b" "c"))
+  "a 'hello world' b c")
 
  ("bash-complete-split simple"
   (sz-testutils-with-buffer
@@ -151,6 +155,38 @@ garbage
("cv" "-F" "_cdargs_aliases")
("cb" "-F" "_cdargs_aliases")))
 
+ ("bash-complete-quote not necessary"
+  (bash-complete-quote "hello")
+  "hello")
+
+ ("bash-complete-quote not necessary"
+  (bash-complete-quote "hello world")
+  "'hello world'")
+
+ ("bash-complete-quote not necessary"
+  (bash-complete-quote "hell'o")
+  "'hell\\'o'")
+
+ ("bash-complete-generate-line no custom completion"
+  (let ((bash-complete-alist nil))
+   (bash-complete-generate-line "hello worl" 7 '("hello" "worl") 1))
+  "compgen -o default worl")
+
+ ("bash-complete-generate-line custom completion no function or command"
+  (let ((bash-complete-alist '(("zorg" . ("-A" "-G" "*.txt")
+   (bash-complete-generate-line "zorg worl" 7 '("zorg" "worl") 1))
+  "compgen -A -G '*.txt' worl")
+
+ ("bash-complete-generate-line custom completion function"
+  (let ((bash-complete-alist '(("zorg" . ("-F" "__zorg")
+   (bash-complete-generate-line "zorg worl" 7 '("zorg" "worl") 1))
+  "__BASH_COMPLETE_WRAPPER='COMP_LINE=\\'zorg worl\\'; COMP_POS=7; 
COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper worl")
+
+ ("

[nongnu] elpa/bash-completion f7bfc68ea2 001/313: bash completion

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit f7bfc68ea28525f1ff4428d6c1859f6d1c10ac17
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

bash completion
---
 bash-complete.el | 91 
 1 file changed, 91 insertions(+)

diff --git a/bash-complete.el b/bash-complete.el
new file mode 100644
index 00..b15daea8d9
--- /dev/null
+++ b/bash-complete.el
@@ -0,0 +1,91 @@
+
+(defun bash-complete-dynamic-complete ()
+  "Bash completion function for `comint-complete-dynamic-functions'.
+
+Call bash to do the completion."
+  (when (comint-match-partial-filename)
+(unless (window-minibuffer-p (selected-window))
+  (message "Bash completion..."))
+(bash-complete-dynamic-complete-0)))
+
+(defun bash-complete-dynamic-complete-0 ()
+  (save-excursion
+(let* ( (pos (point))
+   (start (comint-line-beginning-position))
+   (end (line-end-position))
+   (line (buffer-substring-no-properties start end))
+   (wordsplit (bash-complete-split start end pos))
+   (words (car wordsplit))
+   (cword (cdr wordsplit))
+   (stub (nth cword words)) )
+  (comint-simple-complete stub
+ (bash-complete-comm
+  line pos words cword)
+
+(defun bash-complete-split (start end pos)
+  "Split LINE like bash would do, keep track of current word at POS.
+
+Return a list containing the words and the number of the word
+at POS, the current word: ( (word1 word2 ...) . wordnum )"
+  (save-excursion
+(goto-char start)
+(nreverse (bash-complete-split-0 start end pos nil
+
+(defun bash-complete-split-0 (start end pos accum)
+  (let ( (char-start (char-after))
+(quote nil) )
+(when (or (= char-start ?') (= char-start ?\"))
+  (forward-char)
+  (setq quote char-start))
+(bash-complete-split-1 start end pos quote accum)))
+
+;; "hell o" wor\ ld 'baa b'a"hell o"world a
+
+;; (progn
+;;   (load-library "~/.emacs.d/bash-complete.el")
+;;   (let ((start 64) (end 108))
+;; (bash-complete-split start end 80)))
+
+(defun bash-complete-split-1 (start end pos quote accum)
+  (skip-chars-forward (bash-complete-nonsep quote) end)
+  (cond
+   ;; an escaped char, skip, whatever it is
+   ((= ?\\ (char-before))
+(forward-char)
+(bash-complete-split-1 start end pos (if (and quote (= quote 
(char-before))) nil quote) accum))
+   ;; opening quote
+   ((and (not quote) (or (= ?' (char-after)) (= ?\" (char-after
+(bash-complete-split-0 start end pos accum))
+   ;; closing quote
+   ((and quote (= quote (char-after)))
+(forward-char)
+(bash-complete-split-0 start end pos accum))
+   ;; space inside a quote
+   ((and quote (not (= quote (char-after
+(forward-char)
+(bash-complete-split-1 start end pos quote accum))
+   ;; word end
+   (t
+(let ((str (buffer-substring-no-properties start (point
+  (when str
+   (push str accum)))
+(skip-chars-forward " \t\n\r" end)
+(if (< (point) end)
+   (bash-complete-split-0 (point) end pos accum)
+  accum
+
+(defun bash-complete-nonsep (quote)
+  (if quote
+  (concat "^ \t\n\r" (char-to-string quote))
+"^ \t\n\r'\""))
+
+(defun bash-complete-comm (line pos words cword)
+  "Set LINE, POS, WORDS and CWORD, call bash completion, 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.
+
+The result is a list of candidates, which might be empty."
+
+  )



[nongnu] elpa/bash-completion b5c2fbf4a2 014/313: add hooks

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit b5c2fbf4a20ef89c08924f12b020554ab8161ec0
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

add hooks
---
 bash-complete.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/bash-complete.el b/bash-complete.el
index 78f2d96980..82a8072c8c 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -18,6 +18,12 @@ the following entry is added to `bash-complete-alist':
 See `bash-complete-add-to-alist'.
 ")
 
+(defun bash-complete-setup ()
+  (add-hook 'shell-mode-hook 'bash-complete-setup-shell))
+
+(defun bash-complete-setup-shell ()
+  (add-hook 'comint-dynamic-complete-functions 'bash-complete-dynamic-complete 
t t))
+
 (defun bash-complete-dynamic-complete ()
   "Bash completion function for `comint-complete-dynamic-functions'.
 



[nongnu] elpa/bash-completion 7f4410ebcb 237/313: Extend integration tests to cover single-process use-case.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 7f4410ebcb188fa25d8728a0ab9c544cbdcb5cb5
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Extend integration tests to cover single-process use-case.
---
 test/bash-completion-integration-test.el | 63 +++-
 1 file changed, 45 insertions(+), 18 deletions(-)

diff --git a/test/bash-completion-integration-test.el 
b/test/bash-completion-integration-test.el
index ce4d9746fb..d71ad721d3 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -33,49 +33,66 @@
 (require 'dired)
 (require 'ert)
 
-(defmacro bash-completion_test-harness (bashrc &rest body)
+(defmacro bash-completion_test-harness (bashrc use-separate-process &rest body)
   `(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-use-separate-processes t)
+   (bash-completion-use-separate-processes ,use-separate-process)
(bash-completion-args
 (list "--noediting"
   "--noprofile"
   "--rcfile" (expand-file-name "bashrc" test-env-dir)))
+   (explicit-shell-file-name bash-completion-prog)
+   (explicit-args-var (intern
+   (concat "explicit-"
+   (file-name-nondirectory 
bash-completion-prog)
+   "-args")))
+   (old-explicit-args)
+   (shell-mode-hook nil)
+   (comint-mode-hook nil)
(kill-buffer-query-functions '())
(minibuffer-message-timeout 0)
(default-directory test-env-dir))
+   ;; Set explicit--args for shell-mode.
+   (when (boundp explicit-args-var)
+ (setq old-explicit-args (symbol-value explicit-args-var)))
+   (set explicit-args-var bash-completion-args)
+
;; 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
+   (set explicit-args-var old-explicit-args)
(bash-completion_test-teardown-env test-env-dir)
(bash-completion-reset-all))
 
-(defmacro bash-completion_test-with-shell-harness (bashrc &rest body)
+(defmacro bash-completion_test-with-shell-harness (bashrc use-separate-process 
&rest body)
   `(bash-completion_test-harness
 ,bashrc
+,use-separate-process
 (let ((shell-buffer))
   (unwind-protect
  (progn
(setq shell-buffer (shell (generate-new-buffer-name
   "*bash-completion_test-with-shell*")))
-   ;; accept process output until there's nothing left
-   (while (accept-process-output nil 0.6))
-   ;; do a completion and return the result
+(bash-completion--wait-for-prompt (get-buffer-process shell-buffer)
+  
(bash-completion--get-prompt-regexp)
+  3.0)
(with-current-buffer shell-buffer
-  (let ((comint-dynamic-complete-functions 
'(bash-completion-dynamic-complete))
-(bash-major-version (process-get 
(bash-completion-get-process)
- 'bash-major-version)))
+  (let ((comint-dynamic-complete-functions 
'(bash-completion-dynamic-complete)))
 (progn ,@body
-(progn ;; finally
-  (when (and shell-buffer (buffer-live-p shell-buffer))
+(when shell-buffer
+  (when (and (buffer-live-p shell-buffer)
+ (get-buffer-process shell-buffer))
 (kill-process (get-buffer-process shell-buffer)))
-  (when shell-buffer 
-(kill-buffer shell-buffer)))
+  (kill-buffer shell-buffer))
+
+(defun bash-completion_test-bash-major-version ()
+  "Return the major version of the bash process."
+  (process-get (bash-completion-get-process) 'bash-major-version))
 
 (defun bash-completion_test-complete (complete-me)
   (goto-char (point-max))
@@ -112,11 +129,18 @@ for testing completion."
 (ert-deftest bash-completion-integration-setenv-test ()
   (bash-completion_test-harness
""
+   t ; use-separate-process
(bash-completion-send "echo $EMACS_BASH_COMPLETE")
(with-current-buffer (bash-completion-buffer)
  (should (equal "t\n" (buffer-string))
 
-(ert-deftest bash-completion-integration-completion-test ()
+(ert-deftest bash-completion-integration-separate-processes-test ()
+  (bash-completion_test-completion-test t))
+
+(ert-deftest bash-completion-integration-single-process-test ()
+  (bash-completion_test-completion-test nil))
+
+(defun bash-completion_test-completion-test (use-separate-proces

[nongnu] elpa/bash-completion 7615b1bda5 083/313: changed e-mail address

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 7615b1bda579bf94d3660d3066e79956a9a80aaa
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

changed e-mail address
---
 bash-completion.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index be0de56472..657fd8c188 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1,6 +1,6 @@
 ;;; bash-completion.el --- BASH completion for the shell buffer
 
-;; Author: Stephane Zermatten 
+;; Author: Stephane Zermatten 
 
 ;;; Commentary:
 ;;



[nongnu] elpa/bash-completion 1c6b2efb67 040/313: enormous test

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 1c6b2efb677ed2dd71737a0d43ddf503497aecff
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

enormous test
---
 bash-completion_test.el | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/bash-completion_test.el b/bash-completion_test.el
index 1239869ea2..11a8de0161 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -459,6 +459,26 @@ garbage
(kill-buffer buffer)))
  (error (message "error in bash-completion_test tearDown: %s" err))
 
+  (defmacro bash-completion_test-with-shell (&rest body)
+`(bash-completion_test-harness
+   (let ((shell-buffer nil)
+ (explicit-shell-file-name bash-completion-prog))
+ (unwind-protect
+ (progn
+   (setq shell-buffer (shell (generate-new-buffer-name 
"*bash-completion_test-with-shell*")))
+   ;; accept process output until there's nothing left
+   (while (accept-process-output nil 0.6))
+   ;; do a completion and return the result
+   (with-current-buffer shell-buffer
+ (let ((start (point)))
+   (progn ,@body)
+   (buffer-substring-no-properties start (point-max)
+   ;; finally
+   (when (and shell-buffer (buffer-live-p shell-buffer))
+ (with-current-buffer shell-buffer
+   (insert "\nexit\n"))
+ (kill-buffer shell-buffer))
+
   (put 'bash-completion-regress-integration 'regression-suite t)
   (setq bash-completion-regress-integration '(
("bash-completion interaction"
@@ -483,6 +503,13 @@ garbage
   (buffer-string)))
"t\n")
 
+   ("bash-completion execute one completion"
+   (bash-completion_test-with-shell
+(let ((start (point)))
+  (insert "__bash_complete_")
+  (bash-completion-dynamic-complete)))
+   "__bash_complete_wrapper ")
+
)))
 
 ;; Run diagnostics when this module is evaluated or compiled



[nongnu] elpa/bash-completion 711ccc2df1 096/313: format example properly

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 711ccc2df1a8766489f3b2864943b2fbcdfffbfb
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

format example properly
---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 7588de29e0..21400290bd 100644
--- a/README.md
+++ b/README.md
@@ -89,8 +89,8 @@ important disadvantages:
   in the current buffer.
   In a standard terminal, you could do:
 
-  $ alias myalias=ls
-  $ myal
+$ alias myalias=ls
+$ myal
 
   and bash would propose the new alias.
   Bash-completion.el cannot do that, as it is not aware of anything



[nongnu] elpa/bash-completion ca24f8ada4 073/313: forward last open quote

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit ca24f8ada44c176dc1ea27a92dc2d89c96683f64
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

forward last open quote
---
 bash-completion.el  | 92 +++--
 bash-completion_test.el | 26 +-
 2 files changed, 84 insertions(+), 34 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 6551efeb12..679c6d1dec 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -157,13 +157,16 @@ completion.  Return nil if no match was found."
 (when (not (window-minibuffer-p))
   (message "Bash completion..."))
 (let* ( (start (comint-line-beginning-position))
-   (parsed (bash-completion-parse-line start (point)))
+   (end (point))
+   (tokens (bash-completion-tokenize start pos))
+   (open-quote (bash-completion-tokenize-open-quote tokens))
+   (parsed (bash-completion-parse-line tokens pos))
(line (cdr (assq 'line parsed)))
(point (cdr (assq 'point parsed)))
(cword (cdr (assq 'cword parsed)))
(words (cdr (assq 'words parsed)))
(stub (nth cword words))
-   (completions (bash-completion-comm line point words cword))
+   (completions (bash-completion-comm line point words cword 
open-quote))
;; Override configuration for comint-dynamic-simple-complete.
;; Bash adds a space suffix automatically.
(comint-completion-addsuffix nil) )
@@ -221,14 +224,21 @@ functions adds single quotes around it and return the 
result."
"'")))
 
 (defun bash-completion-parse-line (start pos)
-  "Parse a command line between START and POS, the cursor position.
+  "Split a command line in the current buffer between START and POS.
 
-This function parse the portion of the current buffer between
-START and POS as a BASH command-line and returns the variables
-compgen function expect in an association list.
+This function combines `bash-completion-tokenize' and
+`bash-completion-process-tokens'.  It takes the same arguments as
+`bash-completion-tokenize' and returns the same value as
+`bash-completion-process-tokens'."
+  (bash-completion-process-tokens
+   (bash-completion-tokenize start pos) pos))
 
-POS specifies the current cursor position and marks the word to
-be completed.
+(defun bash-completion-process-tokens (tokens pos)
+  "Process a command line split into TOKENS that end at POS.
+
+This function takes a list of tokens built by
+`bash-completion-tokenize' and returns the variables compgen
+function expect in an association list.
 
 Return an association list with the current symbol as keys:
  line - the relevant command between START and POS (string)
@@ -236,8 +246,7 @@ Return an association list with the current symbol as keys:
  words - line split into words, unescaped (list of strings)
  cword - 0-based index of the word to be completed in words (number)"
   (bash-completion-parse-line-postprocess
-   (bash-completion-parse-current-command
-(bash-completion-tokenize start pos)) pos))
+   (bash-completion-parse-current-command tokens) pos))
 
 (defun bash-completion-parse-line-postprocess (tokens pos)
   "Extract from TOKENS the data needed by compgen functions.
@@ -310,19 +319,27 @@ TOKENS should be in the format returned by 
`bash-completion-tokenize'."
 
 (defsubst bash-completion-tokenize-get-range (token)
   "Return the TOKEN range as a cons: (start . end)."
-  (cdr token))
+  (cdr (assq 'range token)))
 
 (defsubst bash-completion-tokenize-set-end (token)
   "Set the end position of TOKEN to the cursor position."
-  (setcdr (cdr token) (point)))
+  (setcdr (bash-completion-tokenize-get-range token) (point)))
 
 (defsubst bash-completion-tokenize-append-str (token str)
   "Append to TOKEN the string STR."
-  (setcar token (concat (car token) str)))
+  (let ((str-cons (assq 'str token)))
+(setcdr str-cons (concat (cdr str-cons) str
 
 (defsubst bash-completion-tokenize-get-str (token)
   "Return the TOKEN string."
-  (car token))
+  (cdr (assq 'str token)))
+
+(defsubst bash-completion-tokenize-open-quote (tokens)
+  "Return the quote character that was still open in the last token.
+
+TOKENS is a list of token as returned by
+`bash-completion-tokenize'."
+  (cdr (assq 'quote (car (last tokens)
 
 (defun bash-completion-tokenize (start end)
   "Tokenize the portion of the current buffer between START and END.
@@ -369,7 +386,10 @@ Return TOKENS with new tokens found betwen 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 "" (point)))
+  (bash-completion-tokenize-0 end tokens
+ (list
+  (cons 'str "")
+  (cons 'range (cons (point) nil
 tokens))
 
 (defun bash-completion-tokenize-0 (end tokens token)
@@ -448,6 +4

[nongnu] elpa/bash-completion 2dbc7e61f6 248/313: Extend bash-completion-refresh to refresh everything, test it.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 2dbc7e61f685178fdd0c1a0536e83f267955eabd
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Extend bash-completion-refresh to refresh everything, test it.
---
 bash-completion.el   | 12 ++--
 test/bash-completion-integration-test.el | 25 +
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 156e97ebf5..70a60c5b4b 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1350,18 +1350,18 @@ completion candidates."
 
 ;;;###autoload
 (defun bash-completion-refresh ()
-  "Refresh the completion table.
+  "Force a refresh the completion table.
 
 This can be called after changing the completion table on BASH,
-with the builtin complete.
+or after starting a new BASH job.
 
 This is only useful when `bash-completion-use-separate-processes'
 is t."
   (interactive)
-  (let* ((process (bash-completion--get-process))
- (buffer (bash-completion--get-buffer process)))
-(bash-completion-send "complete -p" process)
-(process-put process 'complete-p (bash-completion-build-alist buffer
+  (let* ((process (bash-completion--get-process)))
+(unless process
+  (error "Bash completion not available on current buffer."))
+(bash-completion--setup-bash-common process)))
   
 ;;;###autoload
 (defun bash-completion-reset ()
diff --git a/test/bash-completion-integration-test.el 
b/test/bash-completion-integration-test.el
index c767129a2b..7a8326a655 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -108,6 +108,15 @@
   (buffer-substring-no-properties
(line-beginning-position) (point)))
 
+(defun bash-completion_test-send (command)
+  "Execute COMMAND in a shell buffer."
+  (goto-char (point-max))
+  (delete-region (line-beginning-position) (line-end-position))
+  (insert command)
+  (comint-send-input)
+  (bash-completion--wait-for-regexp
+   (get-buffer-process (current-buffer)) comint-prompt-regexp 3.0))
+
 (defun bash-completion_test-candidates (complete-me)
   "Complete COMPLETE-ME and returns the candidates."
   (goto-char (point-max))
@@ -356,4 +365,20 @@ for testing completion."
(should (equal "dummy 1 Yooo "
   (bash-completion_test-complete "dummy 1 Y")
 
+(ert-deftest bash-completion-integration-refresh-test ()
+  (bash-completion_test-with-shell-harness
+   (concat ; .bashrc
+"function _dummy { COMPREPLY=(Yooo); }\n"
+"function dummy { echo $1; }\n"
+"complete -F _dummy dummy\n")
+   nil ; use-separate-process
+   (should (equal "dummy 1 Yooo "
+  (bash-completion_test-complete "dummy 1 Y")))
+   (bash-completion_test-send "function _dummy2 { COMPREPLY=(Yaaa); }")
+   (bash-completion_test-send "complete -F _dummy2 dummy")
+   (bash-completion-refresh)
+   (should (equal "dummy 1 Yaaa "
+  (bash-completion_test-complete "dummy 1 Y")
+
+   
 ;;; bash-completion-integration-test.el ends here



[nongnu] elpa/bash-completion 1d7af7e40d 027/313: Remove debug messages

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 1d7af7e40d9ab3c7656203bb59975f1c8c4146a6
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Remove debug messages
---
 bash-completion.el | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index a00acac890..910d11205e 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -166,7 +166,6 @@ 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"))
   (let ((bash-completion-prefix (nth cword words)))
-(message "prefix=>%s< words=%s cword=%s nth=%s" bash-completion-prefix 
words cword (nth 1 words))
 (mapcar 'bash-completion-fix 
(with-current-buffer (bash-completion-buffer)
  (split-string (buffer-string) "\n" t)
@@ -186,7 +185,6 @@ The result is a list of candidates, which might be empty."
;; for example: "export PATH=". Prepend the old
;; prefix to avoid confusing comint-dynamic-simple-complete
(t str
- (message "rest=>%s<, str=>%s< prefix=>%s<" rest str 
bash-completion-prefix)
  (concat bash-completion-prefix (bash-completion-escape rest)
 
 (defun bash-completion-starts-with (str prefix)
@@ -197,8 +195,6 @@ The result is a list of candidates, which might be empty."
  (equal (substring str 0 prefix-len) prefix
 
 (defun bash-completion-addsuffix (str)
-  (message "file=%s, accessible=%s" (expand-file-name str default-directory)
-  (file-accessible-directory-p (expand-file-name str 
default-directory)))
   (let ((end (substring str -1)))
 (if (and (not (eq end " "))
 (not (eq end "/"))
@@ -226,10 +222,8 @@ The result is a list of candidates, which might be empty."
   (startfile2 (concat "~/.emacs.d/init_" shell-name ".sh")))
  (cond
   ((file-exists-p startfile1)
-   (message "bash-completion: source %s" startfile1)
(process-send-string process (concat ". " startfile1 "\n")))
   ((file-exists-p startfile2)
-   (message "bash-completion: source %s" startfile2)
(process-send-string process (concat ". " startfile2 "\n")
(bash-completion-send "PS1='\v'" process 
bash-completion-initial-timeout)
(bash-completion-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER; }" process)
@@ -286,7 +280,7 @@ The result is a list of candidates, which might be empty."
   (and bash-completion-process (eq 'run (process-status 
bash-completion-process
 
 (defun bash-completion-send (commandline &optional process timeout)
-  (message commandline)
+  ;;(message commandline)
   (let ((process (or process (bash-completion-require-process)))
(timeout (or timeout bash-completion-process-timeout)))
 (with-current-buffer (process-buffer process)



[nongnu] elpa/bash-completion f01d8726de 179/313: Remove support filenames options.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit f01d8726de43052f8a2c888194caf108172ad31b
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Remove support filenames options.

Go back to always applying filename post-processing. This seems to be
what bash does.

Issue #19
---
 bash-completion.el   | 19 ---
 test/bash-completion-test.el | 12 ++--
 2 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 6c6135d71a..d1e2c122ce 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -851,8 +851,6 @@ character (' or \") or nil.
 
 OPTIONS configrues some behaviors:
  'nospace to not add a space after a single completion
- 'filenames to post-process candidates as filenames and detect
-  directories
 
 If SINGLE is non-nil, this is the single completion candidate.
 
@@ -911,11 +909,9 @@ for directory name detection to work."
((or (memq last-char bash-completion-wordbreaks)
 (eq ?/ last-char))
 (setq suffix ""))
-   ((and
- (memq 'filenames options)
- (file-accessible-directory-p
-  (bash-completion--expand-file-name (bash-completion-unescape
-  open-quote (concat parsed-prefix 
rest)
+   ((file-accessible-directory-p
+ (bash-completion--expand-file-name (bash-completion-unescape
+ open-quote (concat parsed-prefix 
rest
 (setq suffix "/"))
(single
 (setq suffix (concat close-quote-str final-space-str)))
@@ -1349,19 +1345,12 @@ Return the status code of the command, as a number."
   "Parse OPTIONS-STRINGS for compgen into a list of symbols.
 
 Supported options and compgen option equivalent:
- 'default: -o default
- 'nospace: -o nospace
- 'filenames: -o filenames"
+ 'nospace: -o nospace"
   (let ((options))
-(if (member "default" option-strings)
-(push 'default options))
 (if (bash-completion--check-option
  option-strings
  "nospace" bash-completion-nospace)
 (push 'nospace options))
-(if (or (member "filenames" option-strings)
-(memq 'default options))
-(push 'filenames options))
 options))
 
 (defun bash-completion--check-option
diff --git a/test/bash-completion-test.el b/test/bash-completion-test.el
index 72295a0192..1ddde4d471 100644
--- a/test/bash-completion-test.el
+++ b/test/bash-completion-test.el
@@ -572,13 +572,10 @@ Return (const return-value new-buffer-content)"
   (should (equal "hello\\ world"
 (bash-completion-fix " world" "hello" "hello" nil nil nil)))
 
-  ;; append / for home, with option filenames
+  ;; append / for home
   (should (equal "~/"
  (bash-completion-fix (expand-file-name "~")
   "~" "~" nil '(filenames) nil)))
-  (should (equal "~"
- (bash-completion-fix (expand-file-name "~")
-  "~" "~" nil nil nil)))
 
   (cl-letf (((symbol-function 'file-accessible-directory-p)
  (lambda (d) (equal d "/tmp/somedir"
@@ -1005,14 +1002,9 @@ before calling 
`bash-completion-dynamic-complete-nocomint'.
 (ert-deftest bash-completion--parse-options ()
   (let ((bash-completion-nospace 'as-configured))
 (should (equal nil (bash-completion--parse-options nil)))
-(should (equal '(filenames nospace default)
+(should (equal '(nospace)
(bash-completion--parse-options
 '("filenames" "nospace" "default"
-(should (equal '(filenames)
-   (bash-completion--parse-options
-'("filenames"
-(should (equal '(filenames default)
-   (bash-completion--parse-options '("default"
 (setq bash-completion-nospace nil)
 (should (equal '() (bash-completion--parse-options
 '("nospace"



[nongnu] elpa/bash-completion cd2ec103d1 026/313: Expand directory names with quotes and spaces, but no further

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit cd2ec103d1686de04346cfa12b4f8137932ee7fc
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Expand directory names with quotes and spaces, but no further
---
 bash-completion.el  | 42 +-
 bash-completion_test.el | 14 ++
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 0686c015b7..a00acac890 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -85,6 +85,9 @@ Call bash to do the completion."
(replace-regexp-in-string "'" "'\\''" word :literal t)
"'")))
 
+(defun bash-completion-escape (word)
+  (replace-regexp-in-string "\\([ '\"]\\)" "\\1" word))
+
 (defun bash-completion-split (start end pos)
   "Split LINE like bash would do, keep track of current word at POS.
 
@@ -100,6 +103,11 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
   (cons (car accum) (nreverse (cdr accum))
 
 (defun bash-completion-split-0 (start end pos accum straccum)
+  (when (eq "" straccum)
+(let ((local-start (point)))
+  (when (and (null (car accum)) (not (null pos)) (<= pos local-start))
+   (setcar accum (length (cdr accum)))
+   (setcdr accum (cons "" (cdr accum))
   (let ( (char-start (char-after))
 (quote nil) )
 (when (and char-start (or (= char-start ?') (= char-start ?\")))
@@ -109,9 +117,6 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
 
 (defun bash-completion-split-1 (start end pos quote accum straccum)
   (let ((local-start (point)))
-(when (and (null (car accum)) (not (null pos)) (<= pos local-start))
-  (setcar accum (length (cdr accum)))
-  (setcdr accum (cons "" (cdr accum
 (skip-chars-forward (bash-completion-nonsep quote) end)
 (setq straccum (concat straccum (buffer-substring-no-properties 
local-start (point)
   (cond
@@ -161,25 +166,28 @@ 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"))
   (let ((bash-completion-prefix (nth cword words)))
+(message "prefix=>%s< words=%s cword=%s nth=%s" bash-completion-prefix 
words cword (nth 1 words))
 (mapcar 'bash-completion-fix 
(with-current-buffer (bash-completion-buffer)
  (split-string (buffer-string) "\n" t)
 
 (defun bash-completion-fix (str)
   (bash-completion-addsuffix 
-   (cond
-((bash-completion-starts-with str bash-completion-prefix)
- str)
-;; bash expands the home directory automatic. this is confusing
-;; for comint-dynamic-simple-complete
-((and (bash-completion-starts-with bash-completion-prefix "~")
- (bash-completion-starts-with str (expand-file-name "~")))
- (concat "~" (substring str (length (expand-file-name "~")
-;; bash sometimes just prints whatever needs to be expanded,
-;; for example: "export PATH=". Prepend the old
-;; prefix to avoid confusing comint-dynamic-simple-complete
-(t
- (concat bash-completion-prefix str)
+   (let* ((rest (cond
+   ((bash-completion-starts-with str bash-completion-prefix)
+(substring str (length bash-completion-prefix)))
+   ;; bash expands the home directory automatic. this is confusing
+   ;; for comint-dynamic-simple-complete
+   ((and (bash-completion-starts-with bash-completion-prefix "~")
+ (bash-completion-starts-with str (expand-file-name "~")))
+(substring (concat "~" (substring str (length 
(expand-file-name "~"
+   (length bash-completion-prefix)))
+   ;; bash sometimes just prints whatever needs to be expanded,
+   ;; for example: "export PATH=". Prepend the old
+   ;; prefix to avoid confusing comint-dynamic-simple-complete
+   (t str
+ (message "rest=>%s<, str=>%s< prefix=>%s<" rest str 
bash-completion-prefix)
+ (concat bash-completion-prefix (bash-completion-escape rest)
 
 (defun bash-completion-starts-with (str prefix)
   (let ((prefix-len (length prefix))
@@ -240,7 +248,7 @@ The result is a list of candidates, which might be empty."
 
 (defun bash-completion-generate-line (line pos words cword)
   (concat
-   (if default-directory (concat "cd " (bash-completion-quote 
(expand-file-name default-directory)) " ; ") "")
+   (if default-directory (concat "cd 2>/dev/null " (bash-completion-quote 
(expand-file-name default-directory)) " ; ") "")
(let* ( (command-name (file-name-nondirectory (car words)))
   (compgen-args (cdr (assoc command-name bash-completion-alist))) )
  (if (not compgen-args)
diff --git a/bash-completion_test.el b/bash-completion_test.el
index cd64a75a65..55f9b01260 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -124,6 +124,12 @@
(bash-com

[nongnu] elpa/bash-completion 3c58afdb0d 033/313: expand file names in colon-separated paths

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 3c58afdb0dcb1b333de8830e24565e14ce246bd1
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

expand file names in colon-separated paths
---
 bash-completion.el | 45 +++--
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index c7aff97876..4537b288dd 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -29,6 +29,8 @@ the following entry is added to `bash-completion-alist':
 See `bash-completion-add-to-alist'.
 ")
 
+(defvar bash-completion-wordbreaks (append "\"'@><=;|&(:" nil))
+
 (defun bash-completion-setup ()
   (add-hook 'shell-dynamic-complete-functions
'bash-completion-dynamic-complete)
@@ -59,7 +61,13 @@ Call bash to do the completion."
   (setq words (cdr wordsplit))
   (setq stub (nth cword words)))
 (let ((completions (bash-completion-comm line (- pos start) words cword)))
-  (comint-dynamic-simple-complete stub completions
+  (if completions
+ (comint-dynamic-simple-complete stub completions)
+   ;; try default completion after a wordbreak
+   (let ((after-wordbreak (bash-completion-after-last-wordbreak stub)))
+ (when (not (equal stub after-wordbreak))
+   (bash-completion-send (concat (bash-completion-cd-command-prefix) 
"compgen -o default -- " after-wordbreak))
+   (comint-dynamic-simple-complete after-wordbreak 
(bash-completion-extract after-wordbreak
 
 (defun bash-completion-line-beginning-position (&optional start)
   (save-excursion
@@ -86,7 +94,10 @@ Call bash to do the completion."
"'")))
 
 (defun bash-completion-escape (word)
-  (replace-regexp-in-string "\\([ '\"]\\)" "\\1" word))
+  (message "escape: %s" word)
+  (if (string-match "^['\"]" word)
+  word
+(replace-regexp-in-string "\\([ '\"]\\)" "\\1" word)))
 
 (defun bash-completion-split (start end pos)
   "Split LINE like bash would do, keep track of current word at POS.
@@ -165,8 +176,11 @@ 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"))
-  (let ((bash-completion-prefix (nth cword words)))
-(mapcar 'bash-completion-fix 
+  (bash-completion-extract (nth cword words)))
+
+(defun bash-completion-extract (stub)
+  (let ((bash-completion-prefix stub))
+(mapcar 'bash-completion-fix
(with-current-buffer (bash-completion-buffer)
  (split-string (buffer-string) "\n" t)
 
@@ -198,14 +212,20 @@ The result is a list of candidates, which might be empty."
(concat prefix (bash-completion-escape rest) suffix)
 
 (defun bash-completion-before-last-wordbreak (str)
-  (catch 'bash-completion-return 
+  (car (bash-completion-last-wordbreak-split str)))
+
+(defun bash-completion-after-last-wordbreak (str)
+  (cdr (bash-completion-last-wordbreak-split str)))
+
+(defun bash-completion-last-wordbreak-split (str)
+  (catch 'bash-completion-return
 (let ((end (- (length str) 1)))
   (while (> end 0)
-   (when (memq (aref str end) '( ?' ?@ ?> ?< ?= ?\; ?| ?& ?\( ?: ))
- (throw 'bash-completion-return (substring str 0 (1+ end
+   (when (memq (aref str end) bash-completion-wordbreaks)
+ (throw 'bash-completion-return (cons (substring str 0 (1+ end)) 
(substring str (1+ end)
(setq end (1- end
-  str))
-  
+  (cons "" str)))
+
 (defun bash-completion-ends-with (str suffix)
   (let ((suffix-len (length suffix))
(str-len (length str)))
@@ -270,9 +290,14 @@ The result is a list of candidates, which might be empty."
(kill-process process)
  (error nil
 
+(defun bash-completion-cd-command-prefix ()
+  (if default-directory
+  (concat "cd 2>/dev/null " (bash-completion-quote (expand-file-name 
default-directory)) " ; ") 
+""))
+
 (defun bash-completion-generate-line (line pos words cword)
   (concat
-   (if default-directory (concat "cd 2>/dev/null " (bash-completion-quote 
(expand-file-name default-directory)) " ; ") "")
+   (bash-completion-cd-command-prefix)
(let* ( (command-name (file-name-nondirectory (car words)))
   (compgen-args (cdr (assoc command-name bash-completion-alist))) )
  (if (not compgen-args)



[nongnu] elpa/bash-completion 34d11220dd 024/313: add prefix if missing

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 34d11220dd5d474cfa3be2797388d566bd782860
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

add prefix if missing
---
 bash-completion.el  | 21 +
 bash-completion_test.el | 22 ++
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index f880c9ee65..d649d6c1d7 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -59,9 +59,7 @@ Call bash to do the completion."
   (setq words (cdr wordsplit))
   (setq stub (nth cword words)))
 (let ((completions (bash-completion-comm line (- pos start) words cword)))
-  (comint-dynamic-simple-complete
-   stub
-   completions
+  (comint-dynamic-simple-complete stub completions
 
 (defun bash-completion-line-beginning-position (&optional start)
   (save-excursion
@@ -163,7 +161,21 @@ 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"))
   (with-current-buffer (bash-completion-buffer)
-(mapcar 'bash-completion-addsuffix (split-string (buffer-string) "\n" t
+(let ((bash-completion-prefix (nth cword words)))
+  (mapcar 'bash-completion-fix (split-string (buffer-string) "\n" t)
+
+(defun bash-completion-fix (str)
+  (bash-completion-addsuffix 
+   (if (bash-completion-starts-with str bash-completion-prefix)
+   str
+ (concat bash-completion-prefix str
+
+(defun bash-completion-starts-with (str prefix)
+  (let ((prefix-len (length prefix))
+   (str-len (length str)))
+(and
+ (>= str-len prefix-len)
+ (equal (substring str 0 prefix-len) prefix
 
 (defun bash-completion-addsuffix (str)
   (let ((end (substring str -1)))
@@ -253,6 +265,7 @@ The result is a list of candidates, which might be empty."
   (and bash-completion-process (eq 'run (process-status 
bash-completion-process
 
 (defun bash-completion-send (commandline &optional process timeout)
+  (message commandline)
   (let ((process (or process (bash-completion-require-process)))
(timeout (or timeout bash-completion-process-timeout)))
 (with-current-buffer (process-buffer process)
diff --git a/bash-completion_test.el b/bash-completion_test.el
index 4c33ea003e..cd64a75a65 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -249,6 +249,28 @@ garbage
(bash-completion-line-beginning-position 1)))
   '(5 5))
 
+ ("bash-completion-line-beginning-position variable assignment"
+  (sz-testutils-with-buffer
+   '("ls ; c=d export a=b" cursor)
+   (bash-completion-line-beginning-position 1))
+  10)
+
+ ("bash-completion-starts-with empty str"
+  (bash-completion-starts-with "" "prefix")
+  nil)
+
+ ("bash-completion-starts-with starts with"
+  (bash-completion-starts-with "blah-blah" "blah-")
+  t)
+
+ ("bash-completion-starts-with does not starts with"
+  (bash-completion-starts-with "blah-blah" "blih-")
+  nil)
+
+ ("bash-completion-starts-with same"
+  (bash-completion-starts-with "blah-" "blah-")
+  t)
+
   )))
 
 



[nongnu] elpa/bash-completion cc1a462415 050/313: tested complex line, detect escaped separators

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit cc1a462415423d46d65e0c42554a8145712ef63b
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

tested complex line, detect  escaped separators
---
 bash-completion.el  |  6 +-
 bash-completion_test.el | 33 +
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index 3a08e0e11a..fa2f0d03b7 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -125,7 +125,11 @@ Call bash to do the completion."
   (dolist (current accum)
(let* ((position (bash-completion-tokenize-range-check current pos))
   (string (bash-completion-tokenize-get-str current))
-  (is-terminal (member string '(";" "&" "|" "&&" "||"
+  (is-terminal
+   (and (member string '(";" "&" "|" "&&" "||"))
+(let ((range (bash-completion-tokenize-get-range current)))
+  (= (- (cdr range) (car range))
+ (length string))
  (cond
   ((and is-terminal
 (eq position 'after))
diff --git a/bash-completion_test.el b/bash-completion_test.el
index a96fcd6219..688005598a 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -172,6 +172,39 @@ cases. That's why they need to be enabled manually.")
(cword . 4)
(words . ("a" "hello" "world" "b" "c"
 
+ ("bash-completion-parse-line complex multi-command line"
+  (sz-testutils-with-buffer
+   '("cd /var/tmp ; ZORG=t make -" cursor " -f Makefile && ./zorg")
+   (bash-completion-parse-line 1 (line-end-position) (point)))
+  '((line . "make - -f Makefile")
+   (cword . 1)
+   (words . ("make" "-" "-f" "Makefile"
+
+
+ ("bash-completion-parse-line pipe"
+  (sz-testutils-with-buffer
+   '("ls /var/tmp | sort -" cursor)
+   (bash-completion-parse-line 1 (line-end-position) (point)))
+  '((line . "sort -")
+   (cword . 1)
+   (words . ("sort" "-"
+
+ ("bash-completion-parse-line escaped semicolon"
+  (sz-testutils-with-buffer
+   '("find -name '*.txt' -" cursor " -exec echo {} ';' | head")
+   (bash-completion-parse-line 1 (line-end-position) (point)))
+  '((line . "find -name '*.txt' - -exec echo {} ';'")
+   (cword . 3)
+   (words . ("find" "-name" "*.txt" "-" "-exec" "echo" "{}" ";"
+
+ ("bash-completion-parse-line at var assignment"
+  (sz-testutils-with-buffer
+   '("cd /var/tmp ; A=f ZORG=t" cursor " make -f Makefile && ./zorg")
+   (bash-completion-parse-line 1 (line-end-position) (point)))
+  '((line . "ZORG=t")
+   (cword . 0)
+   (words . ("ZORG=t"
+
  ("bash-completion-split cursor after end"
   (sz-testutils-with-buffer
'("a hello world b c " cursor)



[nongnu] elpa/bash-completion 8270e09294 023/313: pass words as command-line arguments to the function

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 8270e09294a51f96c77d1475f405d0bfe84955db
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

pass words as command-line arguments to the function
---
 bash-completion.el  | 2 +-
 bash-completion_test.el | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 9f1bbd9662..f880c9ee65 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -233,7 +233,7 @@ The result is a list of candidates, which might be empty."
   (setcar function "-F")
   (setcar (cdr function) "__bash_complete_wrapper")
   (format "__BASH_COMPLETE_WRAPPER=%s compgen %s -- %s"
-  (bash-completion-quote (format "COMP_LINE=%s; 
COMP_POINT=%s; COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"$@\""
+  (bash-completion-quote (format "COMP_LINE=%s; 
COMP_POINT=%s; COMP_CWORD=%s; COMP_WORDS=( %s ); %s \"${COMP_WORDS[@]}\""
(bash-completion-quote 
line) pos cword (bash-completion-join words)
(bash-completion-quote 
function-name)))
   (bash-completion-join args)
diff --git a/bash-completion_test.el b/bash-completion_test.el
index 046368853c..4c33ea003e 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -195,13 +195,13 @@ garbage
   (let ((bash-completion-alist '(("zorg" . ("-F" "__zorg"
(default-directory "/test"))
(bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1))
-  "cd /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; 
COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper -- worl")
+  "cd /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; 
COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg 
\"${COMP_WORDS[@]}\"' compgen -F __bash_complete_wrapper -- worl")
 
  ("bash-completion-generate-line custom completion command"
   (let ((bash-completion-alist '(("zorg" . ("-C" "__zorg"
(default-directory "/test"))
(bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1))
-  "cd /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; 
COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg \"$@\"' compgen -F 
__bash_complete_wrapper -- worl")
+  "cd /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg worl'\\''; 
COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg 
\"${COMP_WORDS[@]}\"' compgen -F __bash_complete_wrapper -- worl")
 
  ("bash-completion-line-beginning-position start"
   (sz-testutils-with-buffer



[nongnu] elpa/bash-completion 9ac7f58758 059/313: Gone through compgen

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 9ac7f58758b9edd61e2915600b8fc36928129ab2
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Gone through compgen
---
 bash-completion.el | 230 ++---
 1 file changed, 131 insertions(+), 99 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 630af61d26..84ceb18e7f 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1,12 +1,24 @@
+;;; bash-completion.el --- BASH completion for the shell buffer
 
-(require 'comint)
 
+;;; Commentary:
+;; 
 ;;if [[ ( -z "$INSIDE_EMACS" || "$EMACS_BASH_COMPLETE" = "t" ) && -f 
/etc/bash_c;;ompletion ]]; then
 ;;  echo -n "BASH completion..."
 ;;  . /etc/bash_completion
 ;;  echo "ON"
 ;;fi
 
+
+;;; History:
+;;
+
+(require 'comint)
+
+;;; Code:
+
+
+;;; -- Customization 
 (defgroup bash-completion nil
   "BASH configurable command-line completion "
   :group 'shell
@@ -21,8 +33,7 @@ once it's been installed.
 Setting this variable to t is NOT enough to enable BASH completion.
 BASH completion is only available in the environment for which
 `bash-completion-dynamic-complete' has been registered. See
-`bash-completion-setup' for that.
-"
+`bash-completion-setup' for that."
   :type '(boolean)
   :group 'bash-completion)
 
@@ -36,9 +47,9 @@ for command-line completion."
   :group 'bash-completion)
 
 (defcustom bash-completion-process-timeout 2.5
-  "Timeout value to apply when waiting from an answer from the
-bash process. If bash takes longer than that to answer, the answer
-will be ignored."
+  "Timeout value to apply when waiting from an answer from bash.
+If bash takes longer than that to answer, the answer will be
+ignored."
   :type '(float)
   :group 'bash-completion)
 
@@ -49,8 +60,10 @@ which typically takes a long time."
   :type '(float)
   :group 'bash-completion)
 
+;;; -- Internal variables and constants 
+
 (defvar bash-completion-process nil
-  "Bash process object")
+  "Bash process object.")
 (defvar bash-completion-alist nil
   "Maps from command name to the 'complete' arguments.
 
@@ -59,20 +72,34 @@ For example if the following completion is defined in bash:
 the following entry is added to `bash-completion-alist':
  (\"cdb\" . (\"-F\" \"_cdargs\"))
 
-See `bash-completion-add-to-alist'.
-")
+See `bash-completion-add-to-alist'.")
 
 (defconst bash-completion-wordbreaks-str "\"'@><=;|&(:"
-  "The equivalent of COMP_WORDBREAKS: special characters that are
-considered word breaks in some cases when doing completion.  This
-was introduced initially to support file completion in
-colon-separated values.")
+  "String of word break characters.
+This is the equivalent of COMP_WORDBREAKS: special characters
+that are considered word breaks in some cases when doing
+completion.  This was introduced initially to support file
+completion in colon-separated values.")
 
 (defconst bash-completion-wordbreaks
   (append bash-completion-wordbreaks-str nil)
-  "`bash-completion-wordbreaks-str' as a list of characters")
+  "`bash-completion-wordbreaks-str' as a list of characters.")
+
+;;; -- Functions: completion
 
+;;;###autoload
 (defun bash-completion-setup ()
+  "Register bash completion for the shell buffer and shell command line.
+
+This function adds `bash-completion-dynamic-complete' to the completion
+function list of shell mode, `shell-dynamic-complete-functions' and to the
+completion function list of shell-command, `shell-command-complete-functions'.
+
+This function is convenient, but it might not be the best way of enabling
+bash completion in your .emacs file because it forces you to load the module
+before it is needed. For an autoload version, add:
+
+TODO"
   (add-hook 'shell-dynamic-complete-functions
'bash-completion-dynamic-complete)
   (add-hook 'shell-command-complete-functions
@@ -84,7 +111,7 @@ colon-separated values.")
 
 This function is meant to be added into
 `shell-dynamic-complete-functions' or
-`shell-command-complete-functions'. It uses `comint' to figure
+`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.
 
@@ -116,7 +143,7 @@ completion.  Return nil if no match was found."
   "Try wordbreak completion on STUB if the complete completion failed.
 
 Split STUB using the wordbreak list and apply compgen default
-completion on the last part. Return non-nil if a match was found.
+completion on the last part.  Return non-nil if a match was found.
 
 This function is not meant to be called outside of
 `bash-completion-dynamic-complete'."
@@ -132,6 +159,8 @@ This function is not meant to be called outside of
after-wordbreak
(bash-completion-extract-candidates after-wordbreak)
 
+;;; -- Functions: parsing and tokenizing
+
 (defun bash-completion-join (words)
   "Join WORDS into a shell command line.
 
@@ -150,7 +179,7 @@ Return one string containing WORDS."
 

[nongnu] elpa/bash-completion 0dcf43f91e 041/313: don't run integration tests by default

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 0dcf43f91ed7ab8a377c49f74422abd5ac114c0a
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

don't run integration tests by default
---
 bash-completion_test.el | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bash-completion_test.el b/bash-completion_test.el
index 11a8de0161..fa869c55a3 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -18,8 +18,11 @@
   (require 'sz-testutils)
   (require 'cl)
 
-  (defvar bash-completion-run-integration-tests t
-"Run integration tests. Set to nil to disable them.")
+  (defvar bash-completion-run-integration-tests nil
+"Run integration tests. Integration start subprocess (bash
+shells) and as a result are too slow to be run in many
+cases. That's why they need to be enabled manually.")
+
   ;; This code will not appear in the compiled (.elc) file
 
   ;; -- unit tests



[nongnu] elpa/bash-completion 7697f1a87c 063/313: comments about tried systems

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 7697f1a87c9260c12fcaa3915f66d631853d4227
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

comments about tried systems
---
 bash-completion.el  | 18 ++
 bash-completion_test.el |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index fe92ce7363..3419ffb127 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -21,6 +21,24 @@
 ;;
 ;; Interactive command:
 ;; 'bash-completion-reset`
+;;
+;; Tried on:
+;;
+;; Emacs:
+;;
+;; GNU Emacs 22.3.1 (Aquamacs 1.7)
+;; GNU Emacs 22.1.1 (OSX 10.5)
+;; GNU Emacs 22.1.1 (Ubuntu Dapper)
+;; GNU Emacs 23.0.94.1 (custom build)
+;;Workaround for this version: Disable minibuffer messages.
+;;(defun minibuffer-message (message &rest args))
+;;
+;;
+;; Environments:
+;; OSX 10.5
+;; Ubuntu 8.04
+;; Ubuntu 8.10
+;;
 
 ;;; History:
 ;;
diff --git a/bash-completion_test.el b/bash-completion_test.el
index 91f0a97ea8..b00251e906 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -573,7 +573,7 @@ garbage
("bash-completion execute wordbreak completion"
(bash-completion_test-with-shell
 (let ((start (point)))
-  (insert "export PATH=/sbin:/b")
+  (insert "export PATH=/sbin:/bi")
   (bash-completion-dynamic-complete)))
"export PATH=/sbin:/bin/")
 



[nongnu] elpa/bash-completion b4fc1a73cb 092/313: removed unnecessary elisp directory

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit b4fc1a73cbec156add49a9ef9689f29cd6f0a23f
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

removed unnecessary elisp directory
---
 elisp/bash-completion.el => bash-completion.el   | 0
 elisp/bash-completion_test.el => bash-completion_test.el | 0
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/elisp/bash-completion.el b/bash-completion.el
similarity index 100%
rename from elisp/bash-completion.el
rename to bash-completion.el
diff --git a/elisp/bash-completion_test.el b/bash-completion_test.el
similarity index 100%
rename from elisp/bash-completion_test.el
rename to bash-completion_test.el



[nongnu] elpa/bash-completion 2390d5cdf3 061/313: more commends and documentation; still need a commentary section

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 2390d5cdf373f19460c90edf414df21daa70b546
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

more commends and documentation; still need a commentary section
---
 bash-completion.el | 38 --
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 84ceb18e7f..140f288c85 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -2,13 +2,25 @@
 
 
 ;;; Commentary:
-;; 
-;;if [[ ( -z "$INSIDE_EMACS" || "$EMACS_BASH_COMPLETE" = "t" ) && -f 
/etc/bash_c;;ompletion ]]; then
-;;  echo -n "BASH completion..."
-;;  . /etc/bash_completion
-;;  echo "ON"
-;;fi
-
+;;
+;; TODO(szermatt)
+;;
+;; .bashrc:
+;; if [[ ( -z "$INSIDE_EMACS" || "$EMACS_BASH_COMPLETE" = "t" ) &&\
+;;  -f /etc/bash_completion ]]; then
+;;   . /etc/bash_completion
+;; fi
+;;
+;; .emacs:
+;; (autoload 'bash-completion-dynamic-complete \"bash-completion\"
+;;   \"BASH completion hook\")
+;; (add-hook 'shell-dynamic-complete-functions
+;;   'bash-completion-dynamic-complete)
+;; (add-hook 'shell-command-complete-functions
+;;   'bash-completion-dynamic-complete))
+;;
+;; Interactive command:
+;; 'bash-completion-reset`
 
 ;;; History:
 ;;
@@ -18,7 +30,7 @@
 ;;; Code:
 
 
-;;; -- Customization 
+;;; -- Customization
 (defgroup bash-completion nil
   "BASH configurable command-line completion "
   :group 'shell
@@ -60,7 +72,7 @@ which typically takes a long time."
   :type '(float)
   :group 'bash-completion)
 
-;;; -- Internal variables and constants 
+;;; -- Internal variables and constants
 
 (defvar bash-completion-process nil
   "Bash process object.")
@@ -99,7 +111,13 @@ This function is convenient, but it might not be the best 
way of enabling
 bash completion in your .emacs file because it forces you to load the module
 before it is needed. For an autoload version, add:
 
-TODO"
+(autoload 'bash-completion-dynamic-complete \"bash-completion\"
+  \"BASH completion hook\")
+(add-hook 'shell-dynamic-complete-functions
+ 'bash-completion-dynamic-complete)
+(add-hook 'shell-command-complete-functions
+ 'bash-completion-dynamic-complete))
+"
   (add-hook 'shell-dynamic-complete-functions
'bash-completion-dynamic-complete)
   (add-hook 'shell-command-complete-functions



[nongnu] elpa/bash-completion aadb2e20b2 070/313: simplified bash-completion-parse-line

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit aadb2e20b2d47c23882438d67f40dff7a9d85d59
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

simplified bash-completion-parse-line
---
 bash-completion.el  | 136 +---
 bash-completion_test.el |  78 +--
 2 files changed, 99 insertions(+), 115 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index eb9b48d7b4..247e248853 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -156,10 +156,8 @@ completion.  Return nil if no match was found."
   (when bash-completion-enabled
 (when (not (window-minibuffer-p))
   (message "Bash completion..."))
-(let* ( (pos (point))
-   (start (comint-line-beginning-position))
-   (end (point))
-   (parsed (bash-completion-parse-line start end pos))
+(let* ( (start (comint-line-beginning-position))
+   (parsed (bash-completion-parse-line start (point)))
(line (cdr (assq 'line parsed)))
(point (cdr (assq 'point parsed)))
(cword (cdr (assq 'cword parsed)))
@@ -222,24 +220,24 @@ functions adds single quotes around it and return the 
result."
(replace-regexp-in-string "'" "'\\''" word :literal t)
"'")))
 
-(defun bash-completion-parse-line (start end pos)
-  "Parse a command line between START and END with POS as the cursor position.
+(defun bash-completion-parse-line (start pos)
+  "Parse a command line between START and POS, the cursor position.
 
 This function parse the portion of the current buffer between
-START and END as a BASH command-line and returns the variables
+START and POS as a BASH command-line and returns the variables
 compgen function expect in an association list.
 
 POS specifies the current cursor position and marks the word to
 be completed.
 
 Return an association list with the current symbol as keys:
- line - the relevant command between START and END (string)
+ line - the relevant command between START and POS (string)
  point - position of the cursor in line (number)
  words - line split into words, unescaped (list of strings)
  cword - 0-based index of the word to be completed in words (number)"
   (bash-completion-parse-line-postprocess
(bash-completion-parse-current-command
-(bash-completion-tokenize start end) pos) pos))
+(bash-completion-tokenize start pos)) pos))
 
 (defun bash-completion-parse-line-postprocess (tokens pos)
   "Extract from TOKENS the data needed by compgen functions.
@@ -247,84 +245,70 @@ Return an association list with the current symbol as 
keys:
 This function takes a list of TOKENS created by `bash-completion-tokenize'
 for the current buffer and generate the data needed by compgen functions
 as returned by `bash-completion-parse-line' given the current position POS."
-  (let ((index 0) (strings nil) (token nil) (tokens-rest tokens) (cword nil)
-   (start (min pos
-   (car (bash-completion-tokenize-get-range (car tokens))
-(while tokens-rest
-  (setq token (car tokens-rest))
-  (setq tokens-rest (cdr tokens-rest))
-  (unless cword
-   (let ((range (bash-completion-tokenize-get-range token)))
- (cond
-  ((and (>= pos (car range))
-(<= pos (cdr range)))
-   (setq cword index))
-  ((< pos (car range))
-   (setq cword index)
-   (push "" strings)
-  (push (bash-completion-tokenize-get-str token) strings)
-  (setq index (1+ index)))
-(unless cword
-  (setq cword index)
-  (push "" strings))
+  (let* ((first-token (car tokens))
+(last-token (car (last tokens)))
+(start (or (car (bash-completion-tokenize-get-range first-token)) pos))
+(end (or (cdr (bash-completion-tokenize-get-range last-token)) pos))
+(words (bash-completion-strings-from-tokens tokens)))
+(when (or (> pos end) (= start end))
+  (setq words (append words '(""
 (list
- (cons 'line (buffer-substring-no-properties
- start
- (cdr (bash-completion-tokenize-get-range token
+ (cons 'line (buffer-substring-no-properties start pos))
  (cons 'point (- pos start))
- (cons 'cword cword)
- (cons 'words (nreverse strings)
+ (cons 'cword (- (length words) 1))
+ (cons 'words words
 
-(defun bash-completion-parse-current-command (tokens pos)
-  "Extract from TOKENS the tokens forming the current command at POS.
+(defun bash-completion-parse-current-command (tokens)
+  "Extract from TOKENS the tokens forming the current command.
 
 This function takes a list of TOKENS created by
 `bash-completion-tokenize' for the current buffer and select the
-tokens on this list that form the current command given that to
-be completed is at POS.
+tokens on this list that form the current command given that the
+word to be completed is the last token.
 
 For example, given this stream of tokens:

[nongnu] elpa/bash-completion 3036ef0394 028/313: disable quote_readline to get good whitespace handling for bash 3.2 at least

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 3036ef039474335dc5ed98fa8d202edf76bc250c
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

disable quote_readline to get good whitespace handling for bash 3.2 at least
---
 bash-completion.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/bash-completion.el b/bash-completion.el
index 910d11205e..c174ac925b 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -227,6 +227,11 @@ The result is a list of candidates, which might be empty."
(process-send-string process (concat ". " startfile2 "\n")
(bash-completion-send "PS1='\v'" process 
bash-completion-initial-timeout)
(bash-completion-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER; }" process)
+   ;; some bash completion functions use quote_readline to double-quote
+   ;; strings - which compgen understands but only in some environment.
+   ;; disable this dreadful business to get a saner way of handling
+   ;; spaces.
+   (bash-completion-send "function quote_readline { echo \"$1\"; }")
(bash-completion-send "complete -p" process)
(bash-completion-build-alist (process-buffer process))
(setq bash-completion-process process)



[nongnu] elpa/bash-completion 7f4bcd03a8 110/313: Avoid cluttering .bash_history with commands from

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 7f4bcd03a8066a9758edd55b08a4094ccb3c2548
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Avoid cluttering .bash_history with commands from
bash-completion.
---
 bash-completion.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bash-completion.el b/bash-completion.el
index 3894da3f5f..0f148e7213 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -889,6 +889,7 @@ is set to t."
(bash-completion-send "export MAILCHECK=-1" process)
(bash-completion-send "export -n MAIL" process)
(bash-completion-send "export -n MAILPATH" process)
+   (bash-completion-send "unset HISTFILE" process)
;; some bash completion functions use quote_readline to double-quote
;; strings - which compgen understands but only in some environment.
;; disable this dreadful business to get a saner way of handling



[nongnu] elpa/bash-completion 53f2c5d30e 009/313: parse complete -p output

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 53f2c5d30ee1426bc537deba58749d92981abb4c
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

parse complete -p output
---
 bash-complete.el  | 18 +-
 bash-complete_test.el | 18 ++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/bash-complete.el b/bash-complete.el
index 83c22ccd49..0a2567d88d 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -62,7 +62,7 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
 (defun bash-complete-split-0 (start end pos accum straccum)
   (let ( (char-start (char-after))
 (quote nil) )
-(when (or (= char-start ?') (= char-start ?\"))
+(when (and char-start (or (= char-start ?') (= char-start ?\")))
   (forward-char)
   (setq quote char-start))
 (bash-complete-split-1 start end pos quote accum straccum)))
@@ -119,6 +119,22 @@ The result is a list of candidates, which might be empty."
 
   )
 
+(defun bash-complete-build-alist (buffer)
+  "Build `bash-complete-alist' with the content of BUFFER.
+
+BUFFER should contains the output of:
+  complete -p
+
+Return `bash-complete-alist'."
+  (with-current-buffer buffer
+(save-excursion
+  (setq bash-complete-alist nil)
+  (end-of-buffer)
+  (while (= 0 (forward-line -1))
+   (bash-complete-add-to-alist
+(cdr (bash-complete-split (line-beginning-position) 
(line-end-position) 0))
+  bash-complete-alist)
+
 (defun bash-complete-add-to-alist (words)
   "Add split 'complete' line WORDS to `bash-complete-add-to-alist'.
 
diff --git a/bash-complete_test.el b/bash-complete_test.el
index ec4844c732..31b17544db 100644
--- a/bash-complete_test.el
+++ b/bash-complete_test.el
@@ -133,6 +133,24 @@
(bash-complete-add-to-alist '("complete" "-e" "-F" "_cdargs_aliases" 
"cdb")))
   '(("cdb" . ("-e" "-F" "_cdargs_aliases"
 
+ ("bash-complete-build-alist"
+  (sz-testutils-with-buffer
+   "
+complete -F _cdargs_aliases cdb
+complete -F complete_projects project
+complete -F complete_projects pro
+complete -F _cdargs_aliases cv
+complete -F _cdargs_aliases cb
+garbage
+"
+   (let ((bash-complete-alist '(garbage)))
+(bash-complete-build-alist (current-buffer
+  '(("cdb" "-F" "_cdargs_aliases")
+   ("project" "-F" "complete_projects")
+   ("pro" "-F" "complete_projects")
+   ("cv" "-F" "_cdargs_aliases")
+   ("cb" "-F" "_cdargs_aliases")))
+
   )))
 
 



[nongnu] elpa/bash-completion 2c4cb6edd2 186/313: Replace bash-completion-integration-test with a higher-level test for

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 2c4cb6edd2ad59ebc4aea57204adad11401baeb0
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Replace bash-completion-integration-test with a higher-level test for
builtin completion.
---
 test/bash-completion-integration-test.el | 23 +++
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/test/bash-completion-integration-test.el 
b/test/bash-completion-integration-test.el
index 452eb387cc..ee59c6fa02 100644
--- a/test/bash-completion-integration-test.el
+++ b/test/bash-completion-integration-test.el
@@ -111,26 +111,6 @@ for testing completion."
 (delete-directory test-env-dir 'recursive)
   (dired-delete-file test-env-dir 'always
 
-(ert-deftest bash-completion-integration-test ()
-  (bash-completion_test-harness
-   (should-not (bash-completion-is-running))
-   (should (buffer-live-p (bash-completion-buffer)))
-   (should (bash-completion-is-running))
-   (should-not (null (member
-  "help "
-  (bash-completion-comm
-   (bash-completion--make
-:line "hel"
-:point 4
-:words '("hel")
-:cword 0
-:stub "hel"
-:unparsed-stub "hel"
-:wordbreaks "@><=;|&(:")
-   (bash-completion-require-process)
-   (bash-completion-reset)
-   (should-not (bash-completion-is-running
-
 (ert-deftest bash-completion-integration-setenv-test ()
   (bash-completion_test-harness
(bash-completion-send "echo $EMACS_BASH_COMPLETE")
@@ -142,6 +122,9 @@ for testing completion."
(bash-completion-integration-test-complete)))
 
 (defun bash-completion-integration-test-complete ()
+   ;; complete bash builtin
+   (should (equal "readonly "
+  (bash-completion_test-complete "reado")))
;; complete command
(should (equal "somefunction "
   (bash-completion_test-complete "somef")))



[nongnu] elpa/bash-completion 8713edbb92 269/313: Mention that completion works with bash 5

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 8713edbb927d3023c7677bd9549bfd013859b60e
Author: Stephane Zermatten 
Commit: GitHub 

Mention that completion works with bash 5

Tested with 5.0.11 on macOS
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index b66e6068bf..9d61249578 100644
--- a/README.md
+++ b/README.md
@@ -136,6 +136,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
 
 ## COMPATIBILITY
 
-bash-completion.el is known to work with Bash 3 and 4, on Emacs,
+bash-completion.el is known to work with Bash 3, 4 and 5, on Emacs,
 starting with version 24.1, under Linux and OSX. It does not work on
 XEmacs.



[nongnu] elpa/bash-completion 42441e36b0 055/313: more documentation, a little refactoring

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 42441e36b0cb1d85699345661086e1e6388689c4
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

more documentation, a little refactoring
---
 bash-completion.el | 49 -
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 40d3c004c4..783c07a232 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -80,9 +80,16 @@ colon-separated values.")
 
 ;;;###autoload
 (defun bash-completion-dynamic-complete ()
-  "Bash completion function for `comint-complete-dynamic-functions'.
+  "Complete word at cursor using BASH completion.
 
-Call bash to do the completion."
+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.
+
+If a match was found, it is displayed as is usual for comint
+completion.  Return nil if no match was found."
   (when bash-completion-enabled
 (when (not (window-minibuffer-p))
   (message "Bash completion..."))
@@ -106,6 +113,13 @@ Call bash to do the completion."
(bash-completion-dynamic-try-wordbreak-complete stub)
 
 (defun bash-completion-dynamic-try-wordbreak-complete (stub)
+  "Try wordbreak completion on STUB if the complete completion failed.
+
+Split STUB using the wordbreak list and apply compgen default
+completion on the last part. Return non-nil if a match was found.
+
+This function is not meant to be called outside of
+`bash-completion-dynamic-complete'."
   (let* ((wordbreak-split (bash-completion-last-wordbreak-split stub))
 (before-wordbreak (car wordbreak-split))
 (after-wordbreak (cdr wordbreak-split)))
@@ -119,7 +133,13 @@ Call bash to do the completion."
(bash-completion-extract after-wordbreak)
 
 (defun bash-completion-join (words)
-  "Join WORDS into a shell line, escaped all words with single quotes"
+  "Join WORDS into a shell command line.
+
+All words that contain even mildly suspicious characters are
+quoted using single quotes to avoid the shell interpreting them
+when it shouldn't.
+
+Return one string containing WORDS."
   (if words
   (mapconcat
'bash-completion-quote
@@ -127,17 +147,16 @@ Call bash to do the completion."
 ""))
 
 (defun bash-completion-quote (word)
+  "Put single quotes around WORD unless it's crearly unnecessary.
+
+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 :literal t)
"'")))
 
-(defun bash-completion-escape (word)
-  (if (string-match "^['\"]" word)
-  word
-(replace-regexp-in-string "\\([ '\"]\\)" "\\1" word)))
-
 (defun bash-completion-parse-line (start end pos)
   (bash-completion-parse-line-postprocess
(bash-completion-parse-current-command
@@ -341,7 +360,19 @@ The result is a list of candidates, which might be empty."
(when (bash-completion-ends-with rest " ")
 (setq rest (substring rest 0 -1))
 (setq suffix " "))
-   (concat prefix (bash-completion-escape rest) suffix)
+   (concat prefix (bash-completion-escape-candidate rest) suffix)
+
+(defun bash-completion-escape-candidate (completion-candidate)
+  "Escapes COMPLETION-CANDIDATE.
+
+This function escapes all special characters in the result of
+bash completion. It does nothing if COMPLETION-CANDIDATE looks
+like a quoted string.
+
+Return a possibly escaped version of COMPLETION-CANDIDATE."
+  (if (string-match "^['\"]" completion-candidate)
+  completion-candidate
+(replace-regexp-in-string "\\([ '\"]\\)" "\\1" completion-candidate)))
 
 (defun bash-completion-before-last-wordbreak (str)
   (car (bash-completion-last-wordbreak-split str)))



[nongnu] elpa/bash-completion 3eb77ec9c4 086/313: Moved shell configuration into config. Got rid of */init.el, going

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 3eb77ec9c495a25188eff3e35d8b20ebb1a7ddc6
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Moved shell configuration into config. Got rid of */init.el, going
back to */subdirs.el
---
 bash-completion.el => elisp/bash-completion.el   | 0
 bash-completion_test.el => elisp/bash-completion_test.el | 0
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/bash-completion.el b/elisp/bash-completion.el
similarity index 100%
rename from bash-completion.el
rename to elisp/bash-completion.el
diff --git a/bash-completion_test.el b/elisp/bash-completion_test.el
similarity index 100%
rename from bash-completion_test.el
rename to elisp/bash-completion_test.el



[nongnu] elpa/bash-completion 2010d8bf9e 210/313: Fix history uncluttering

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 2010d8bf9eb1d34b3b92151930b9791498264fd4
Author: montag451 
Commit: montag451 

Fix history uncluttering

The use of negative offsets with "history -d" is only available in
Bash 5 and newer. The new way of removing the completion command from
the history works with almost all versions of Bash.
---
 bash-completion.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index 99603530cd..098ef3995f 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1365,7 +1365,7 @@ Return the status code of the command, as a number."
(concat
 commandline
 (when (not bash-completion-use-separate-processes)
-  "; echo -e \"\v$?\"; history -d -1")
+  "; echo -e \"\v$?\"; history -d $((HISTCMD - 1))")
 "\n"))
   (unless (bash-completion--wait-for-prompt process prompt-regexp timeout)
 (error (concat



[nongnu] elpa/bash-completion 583d1dde61 151/313: Remove usage of seq-position with a custom implementation.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 583d1dde611c513aa81a0165e809e8d5bafb915a
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Remove usage of seq-position with a custom implementation.

seq.el isn't available in older emacs versions.
---
 bash-completion-test.el |  6 ++
 bash-completion.el  | 20 +---
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/bash-completion-test.el b/bash-completion-test.el
old mode 100644
new mode 100755
index cde751e50b..1ef90ac66c
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -361,6 +361,12 @@ garbage
 (default-directory "/test"))
 (bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1 
nil)
 
+(ert-deftest bash-completion--find-last-test ()
+  (should (equal nil (bash-completion--find-last ?a "x")))
+  (should (equal 3 (bash-completion--find-last ?d "abcdef")))
+  (should (equal 5 (bash-completion--find-last ?f "abcdef")))
+  (should (equal 9 (bash-completion--find-last ?d "abcdefabcdef"
+
 (ert-deftest bash-completion-generate-list-test ()
   ;; empty str
   (should (equal nil
diff --git a/bash-completion.el b/bash-completion.el
index ca15281907..da211ed8fb 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -373,22 +373,28 @@ This function is not meant to be called outside of
 (after-wordbreak (nth 1 wordbreak-split))
  (separator (nth 2 wordbreak-split))
  (unparsed-stub (buffer-substring-no-properties stub-start pos))
- ;; separator-pos-in-unparsed finds the same separator that
- ;; was used for the split in unparsed-stub.
- (separator-pos-in-unparsed
-  (- (length unparsed-stub)
- (or (seq-position (reverse unparsed-stub) separator) 0)))
+ (after-wordbreak-in-unparsed-pos
+  (1+ (or (bash-completion--find-last separator unparsed-stub) -1)))
  (unparsed-after-wordbreak
   (substring unparsed-stub
- separator-pos-in-unparsed
+ after-wordbreak-in-unparsed-pos
  (length unparsed-stub
 (when (> (length before-wordbreak) 0)
-  (list (+ stub-start separator-pos-in-unparsed)
+  (list (+ stub-start after-wordbreak-in-unparsed-pos)
 pos
 (bash-completion--default-completion
  after-wordbreak unparsed-after-wordbreak
  open-quote 'wordbreak)
 
+(defun bash-completion--find-last (elt array)
+  "Return the position of the last intance of ELT in array or nil."
+  (catch 'bash-completion-return
+(let ((array-len (length array)))
+  (dotimes (index array-len)
+(if (eq elt (aref array (- array-len index 1)))
+(throw 'bash-completion-return (- array-len index 1)
+nil))
+
 (defun bash-completion--default-completion
 (stub unparsed-stub open-quote completion-type)
   "Do default completion on the given STUB.



[nongnu] elpa/bash-completion db0545f469 093/313: Add a markdown README file

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit db0545f4692790165acd4c6a4c3bbf33bae2b6fd
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Add a markdown README file
---
 README.md  | 117 +
 bash-completion.el |   2 +-
 2 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
new file mode 100644
index 00..6fca099524
--- /dev/null
+++ b/README.md
@@ -0,0 +1,117 @@
+bash-completion.el defines dynamic completion hooks for shell-mode and
+shell-command prompts that are based on bash completion.
+
+You will need shell-command.el to get tab completion in the
+minibuffer. See 
[http://www.namazu.org/~tsuchiya/elisp/shell-command.el](http://www.namazu.org/~tsuchiya/elisp/shell-command.el)
+
+Bash completion for emacs:
+
+- is aware of bash builtins, aliases and functions
+- does file expansion inside of colon-separated variables
+  and after redirections (> or <)
+- escapes special characters when expanding file names
+- is configurable through programmable bash completion
+
+When the first completion is requested in shell model or a shell
+command, bash-completion.el starts a separate bash
+process.  Bash-completion.el then uses this process to do the actual
+completion and includes it into Emacs completion suggestions.
+
+A simpler and more complete alternative to bash-completion.el is to
+run a bash shell in a buffer in term mode(M-x `ansi-term').
+Unfortunately, many Emacs editing features are not available when
+running in term mode.  Also, term mode is not available in
+shell-command prompts.
+
+## INSTALLATION
+
+1. copy bash-completion.el into a directory that's on Emacs load-path
+2. add this into your .emacs file:
+
+(autoload 'bash-completion-dynamic-complete 
+  \"bash-completion\"
+  \"BASH completion hook\")
+(add-hook 'shell-dynamic-complete-functions
+  'bash-completion-dynamic-complete)
+(add-hook 'shell-command-complete-functions
+  'bash-completion-dynamic-complete)
+
+  or simpler, but forces you to load this file at startup:
+
+(require 'bash-completion)
+(bash-completion-setup)
+
+3. reload your .emacs (M-x `eval-buffer') or restart
+
+Once this is done, use  as usual to do dynamic completion from
+shell mode or a shell command minibuffer, such as the one started
+for M-x `compile'. Note that the first completion is slow, as emacs
+launches a new bash process.
+
+You'll get better results if you turn on programmable bash completion.
+On Ubuntu, this means running:
+
+sudo apt-get install bash-completion
+
+and then adding this to your .bashrc:
+
+. /etc/bash_completion
+
+Right after enabling programmable bash completion, and whenever you
+make changes to you .bashrc, call `bash-completion-reset' to make
+sure bash completion takes your new settings into account.
+
+Loading /etc/bash_completion often takes time, and is not necessary
+in shell mode, since completion is done by a separate process, not
+the process shell-mode process.
+
+To turn off bash completion when running from emacs but keep it on
+for processes started by bash-completion.el, add this to your .bashrc:
+
+if [[ ( -z "$INSIDE_EMACS" || "$EMACS_BASH_COMPLETE" = "t" ) &&\
+ -f /etc/bash_completion ]]; then
+  . /etc/bash_completion
+fi
+
+Emacs sets the environment variable INSIDE_EMACS to the processes
+started from it. Processes started by bash-completion.el have
+the environment variable EMACS_BASH_COMPLETE set to t.
+
+## CAVEATS
+
+Using a separate process for doing the completion has several
+important disadvantages:
+
+- bash completion is slower than standard emacs completion
+- the first completion can take a long time, since a new bash process
+  needs to be started and initialized
+- the separate process is not aware of any changes made to bash
+  in the current buffer.
+  In a standard terminal, you could do:
+
+  $ alias myalias=ls
+  $ myal
+
+  and bash would propose the new alias.
+  Bash-completion.el cannot do that, as it is not aware of anything
+  configured in the current shell. To make bash-completion.el aware
+  of a new alias, you need to add it to .bashrc and restart the
+  completion process using `bash-completion-reset'.
+
+## COMPATIBILITY
+
+bash-completion.el is quite sensitive to the OS and BASH version.
+This package is known to work on the following environment:
+
+- GNU Emacs 22.3.1 (Aquamacs 1.7)
+- GNU Emacs 22.1.1 (OSX 10.5)
+- GNU Emacs 22.1.1 (Ubuntu 8.04)
+- GNU Emacs 23.0.94.1 (Ubuntu 8.10)
+
+and using the following bash versions:
+
+- BASH 3.2.17
+- BASH 3.2.32
+- BASH 3.2.39
+
+bash-completion.el does not works on XEmacs.
diff --git a/bash-completion.el b/bash-completion.el
index 5f4b1e9fe2..438ea2716d 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1,6 +1,6 @@
 ;;; bash-completion.el --- BASH completion for the shell buffer
 
-;; Author: Stephane Zermatten 
+;; Author:

[nongnu] elpa/bash-completion a78fd6b587 044/313: turn off mailwarn and checkjobs, continue if this failed

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit a78fd6b587d1ee4d7799f058d81cecf0dd5515b0
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

turn off mailwarn and checkjobs, continue if this failed
---
 bash-completion.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bash-completion.el b/bash-completion.el
index d1f30559fd..a3c4fc7bdb 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -274,6 +274,9 @@ The result is a list of candidates, which might be empty."
(process-send-string process (concat ". " startfile2 "\n")
(bash-completion-send "PS1='\v'" process 
bash-completion-initial-timeout)
(bash-completion-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER; }" process)
+   ;; attempt to turn off unexpected status messages from bash
+   ;; if the current version of bash does not support these options,
+   ;; the command will fail silently and be ignored
(bash-completion-send "shopt -u mailwarn; shopt -u checkjobs" 
process)
;; some bash completion functions use quote_readline to double-quote
;; strings - which compgen understands but only in some environment.



[nongnu] elpa/bash-completion 3bd30eea3f 208/313: Use the correct function to send string to completion process

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 3bd30eea3f4bd3dd5183712ca2cb553467faf498
Author: montag451 
Commit: montag451 

Use the correct function to send string to completion process
---
 bash-completion.el | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 6c294a95da..2b46b63cd2 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1355,14 +1355,18 @@ Return the status code of the command, as a number."
 (comint-preoutput-filter-functions
  (if bash-completion-use-separate-processes
  comint-preoutput-filter-functions
-   '(bash-completion--output-filter
+   '(bash-completion--output-filter)))
+(send-string (if bash-completion-use-separate-processes
+ #'process-send-string
+   #'comint-send-string)))
 (with-current-buffer (bash-completion--get-buffer process)
   (erase-buffer)
-  (comint-send-string process (concat
-   commandline
-   (when (not 
bash-completion-use-separate-processes)
- "; echo -e \"\v$?\"; history -d -1")
-   "\n"))
+  (funcall send-string process
+   (concat
+commandline
+(when (not bash-completion-use-separate-processes)
+  "; echo -e \"\v$?\"; history -d -1")
+"\n"))
   (unless (bash-completion--wait-for-prompt process prompt-regexp timeout)
 (error (concat
 "Timeout while waiting for an answer from "



[nongnu] elpa/bash-completion 9f02a62609 049/313: re-enabled parse-line cursor at the beginning/in the middle tests

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 9f02a62609c3647c33af720984312f8257da9626
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

re-enabled parse-line cursor at the beginning/in the middle tests
---
 bash-completion.el  | 14 +++
 bash-completion_test.el | 63 -
 2 files changed, 18 insertions(+), 59 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 7466c859bd..3a08e0e11a 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -46,7 +46,7 @@ Call bash to do the completion."
   (when (not (window-minibuffer-p))
 (message "Bash completion..."))
   (let* ( (pos (point))
- (start (bash-completion-line-beginning-position))
+ (start (comint-line-beginning-position))
  (end (line-end-position))
  (parsed (bash-completion-parse-line start end pos))
  (line (cdr (assq 'line parsed)))
@@ -65,15 +65,6 @@ Call bash to do the completion."
(bash-completion-send (concat (bash-completion-cd-command-prefix) 
"compgen -o default -- " after-wordbreak))
(comint-dynamic-simple-complete after-wordbreak 
(bash-completion-extract after-wordbreak
 
-(defun bash-completion-line-beginning-position (&optional start)
-  (save-excursion
-(let ((start (or start (comint-line-beginning-position)))
- (end (line-end-position)))
-  (goto-char end)
-  (if (search-backward-regexp "\\(;\\|\\(&&\\)\\|\\(||\\)\\)[ \t\n]" start 
t)
- (match-end 0)
-   start
-
 (defun bash-completion-join (words)
   "Join WORDS into a shell line, escaped all words with single quotes"
   (if words
@@ -104,7 +95,8 @@ Call bash to do the completion."
 
 (defun bash-completion-parse-line-postprocess (accum pos)
   (let ((index 0) (strings nil) (current nil) (accum-rest accum) (cword nil)
-   (start (car (bash-completion-tokenize-get-range (car accum)
+   (start (min pos
+   (car (bash-completion-tokenize-get-range (car accum))
 (while accum-rest
   (setq current (car accum-rest))
   (setq accum-rest (cdr accum-rest))
diff --git a/bash-completion_test.el b/bash-completion_test.el
index edc28eff1c..a96fcd6219 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -148,17 +148,21 @@ cases. That's why they need to be enabled manually.")
(cword . 2)
(words . ("a" "hello" "world" "b" "c"
 
-;;  ("bash-completion-split cursor at the beginning"
-;;   (sz-testutils-with-buffer
-;;'(" " cursor " a hello world b c")
-;;(bash-completion-split 1 (line-end-position) (point)))
-;;   '(0 . ("" "a" "hello" "world" "b" "c")))
-
-;;  ("bash-completion-split cursor in the middle"
-;;   (sz-testutils-with-buffer
-;;'("a hello " cursor " world b c")
-;;(bash-completion-split 1 (line-end-position) (point)))
-;;   '(2 . ("a" "hello" "" "world" "b" "c")))
+ ("bash-completion-parse-line cursor at the beginning"
+  (sz-testutils-with-buffer
+   '(" " cursor " a hello world b c")
+   (bash-completion-parse-line 1 (line-end-position) (point)))
+  '((line . " a hello world b c")
+   (cword . 0)
+   (words . ("" "a" "hello" "world" "b" "c"
+
+ ("bash-completion-parse-line cursor in the middle"
+  (sz-testutils-with-buffer
+   '("a hello " cursor " world b c")
+   (bash-completion-parse-line 1 (line-end-position) (point)))
+  '((line . "a hello  world b c")
+   (cword . 2)
+   (words . ("a" "hello" "" "world" "b" "c"
 
  ("bash-completion-parse-line cursor at end"
   (sz-testutils-with-buffer
@@ -263,43 +267,6 @@ garbage
(bash-completion-generate-line "zorg worl" 7 '("zorg" "worl") 1))
   "cd 2>/dev/null /test ; __BASH_COMPLETE_WRAPPER='COMP_LINE='\\''zorg 
worl'\\''; COMP_POINT=7; COMP_CWORD=1; COMP_WORDS=( zorg worl ); __zorg 
\"${COMP_WORDS[@]}\"' compgen -F __bash_complete_wrapper -- worl")
 
- ("bash-completion-line-beginning-position start"
-  (sz-testutils-with-buffer
-   "cd /home/x"
-   (bash-completion-line-beginning-position 1))
-  1)
-
- ("bash-completion-line-beginning-position semicolon"
-  (sz-testutils-with-buffer
-   '("cd /home/x ; " cursor "echo hello")
-   (list
-   (point)
-   (bash-completion-line-beginning-position 1)))
-  '(14 14))
-
- ("bash-completion-line-beginning-position 2 semicolon"
-  (sz-testutils-with-buffer
-   '("cd /home/x ; blah; " cursor "echo hello")
-   (list
-   (point)
-   (bash-completion-line-beginning-position 1)))
-  '(20 20))
-
- ("bash-completion-line-beginning-position &&"
-  (sz-testutils-with-buffer
-   '("cd /home/x && " cursor "echo hello")
-   (list
-   (point)
-   (bash-completion-line-beginning-position 1)))
-  '(15 15))
-
- ("bash-completion-line-beginning-position ||"
-  (sz-testutils-with-buffer
-   '("cd /home

[nongnu] elpa/bash-completion 1c2153d287 159/313: Call make-obsolete with three arguments

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 1c2153d2871a1e0600e5f0e54c17118779aa64be
Author: Jonas Bernoulli 
Commit: Jonas Bernoulli 

Call make-obsolete with three arguments

Calling it with two arguments, while still supported, is discouraged
and the byte-compiler complains about it.  If you plan to or end up
releasing v2.0.N before v2.1, then you should probably adjust this.
---
 bash-completion.el | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 2d0c589620..269230afbc 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1238,7 +1238,8 @@ Call `bash-completion-dynamic' or 
`bash-completion-nocomint'."
   result)))
 (make-obsolete
  'bash-completion-dynamic-complete-0
- "call bash-completion-dynamic or bash-completion-dynamic-nocomint")
+ "call bash-completion-dynamic or bash-completion-dynamic-nocomint"
+ "2.1")
 
 (defun bash-completion-dynamic-try-wordbreak-complete (stub stub-start pos 
open-quote)
   "Obsolete function, kept for backward compatibility.
@@ -1252,7 +1253,8 @@ be called from outside bash-completion.
 (cons (buffer-substring-no-properties (car result) pos) result)))
 (make-obsolete
  'bash-completion-dynamic-try-wordbreak-complete
- 'bash-completion--try-wordbreak-complete)
+ 'bash-completion--try-wordbreak-complete
+ "2.1")
 
 (provide 'bash-completion)
 ;;; bash-completion.el ends here



[nongnu] elpa/bash-completion 8a246f40da 088/313: bash-completion-generate-line: add missing compgen option to

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 8a246f40daadbcb0c4ddb3192705475f94340dc4
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

bash-completion-generate-line: add missing compgen option to
complete command (duh!).
---
 elisp/bash-completion.el | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/elisp/bash-completion.el b/elisp/bash-completion.el
index e911fdc838..4478fbf5c5 100644
--- a/elisp/bash-completion.el
+++ b/elisp/bash-completion.el
@@ -113,6 +113,11 @@
 
 ;;; History:
 ;;
+;; 2009-08-01   Stephane Zermatten 
+;;
+;; * bash-completion-generate-line: add missing compgen 
+;; option to complete commands (duh!).
+;;
 ;; Current version:
 ;; $Id$
 ;;
@@ -917,7 +922,7 @@ candidates."
   ((= cword 0)
;; a command. let emacs expand executable, let bash
;; expand builtins, aliases and functions
-   (concat "compgen -S ' ' -b -a -A function " stub))
+   (concat "compgen -S ' ' -b -c -a -A function " stub))
 
   ((not compgen-args)
;; no completion configured for this command



[nongnu] elpa/bash-completion 482383dcd7 021/313: handle slash for directory, usable completion

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 482383dcd79a1527a0ef10d72c8a3ed017a84846
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

handle slash for directory, usable completion
---
 bash-completion.el  | 47 ---
 bash-completion_test.el | 44 
 2 files changed, 64 insertions(+), 27 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index dc9e40a177..43fe828745 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -40,7 +40,7 @@ See `bash-completion-add-to-alist'.
   "Bash completion function for `comint-complete-dynamic-functions'.
 
 Call bash to do the completion."
-  (when (window-minibuffer-p)
+  (when (not (window-minibuffer-p))
 (message "Bash completion..."))
   (let* ( (pos (point))
  (start (bash-completion-line-beginning-position))
@@ -49,7 +49,10 @@ Call bash to do the completion."
  (wordsplit)
  (cword)
  (words)
- (stub) )
+ (stub)
+ ;; Override configuration for comint-dynamic-simple-complete.
+ ;; Bash adds a space suffix automatically.
+ (comint-completion-addsuffix nil) )
 (save-excursion
   (setq wordsplit (bash-completion-split start end pos))
   (setq cword (car wordsplit))
@@ -57,15 +60,14 @@ Call bash to do the completion."
   (setq stub (nth cword words)))
 (comint-dynamic-simple-complete
  stub
- (bash-completion-comm default-directory
-line (- pos start) words cword
+ (bash-completion-comm line (- pos start) words cword
 
 (defun bash-completion-line-beginning-position (&optional start)
   (save-excursion
 (let ((start (or start (comint-line-beginning-position)))
  (end (line-end-position)))
-  (goto-char start)
-  (if (search-forward-regexp "\\(;\\|\\(&&\\)\\|\\(||\\)\\)[ \t\n]" end t)
+  (goto-char end)
+  (if (search-backward-regexp "\\(;\\|\\(&&\\)\\|\\(||\\)\\|\\(=[^ 
\t]*\\)\\)[ \t\n]" start t)
  (match-end 0)
start
 
@@ -144,22 +146,25 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
   (concat "^ \t\n\r" (char-to-string quote))
 "^ \t\n\r'\""))
 
-(defun bash-completion-comm (dir line pos words cword)
-  "Set DIR, LINE, POS, WORDS and CWORD, call bash completion, return the 
result.
+(defun bash-completion-comm (line pos words cword)
+  "Set LINE, POS, WORDS and CWORD, call bash completion, 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.
 
 The result is a list of candidates, which might be empty."
-  (bash-completion-send (concat (bash-completion-generate-line dir line pos 
words cword) " 2>/dev/null"))
+  (bash-completion-send (concat (bash-completion-generate-line line pos words 
cword) " 2>/dev/null"))
   (with-current-buffer (bash-completion-buffer)
-(mapcar 'bash-completion-trim (split-string (buffer-string) "\n" t
+(mapcar 'bash-completion-addsuffix (split-string (buffer-string) "\n" t
 
-(defun bash-completion-trim (str)
-  (if (string-match "^ *\\(.*[^ ]\\) *$" str)
-  (match-string 1 str)
-str))
+(defun bash-completion-addsuffix (str)
+  (let ((end (substring str -1)))
+(if (and (not (eq end " "))
+(not (eq end "/"))
+(file-accessible-directory-p str))
+   (concat str "/")
+str)))
 
 (defun bash-completion-require-process ()
   (if (bash-completion-is-running)
@@ -201,14 +206,18 @@ The result is a list of candidates, which might be empty."
(kill-process process)
  (error nil
 
-(defun bash-completion-generate-line (dir line pos words cword)
+(defun bash-completion-generate-line (line pos words cword)
   (concat
-   (if default-directory (concat "cd " (bash-completion-quote 
(expand-file-name dir)) " ; ") "")
-   (let* ( (command (file-name-nondirectory (car words)))
-  (compgen-args (cdr (assoc command bash-completion-alist))) )
+   (if default-directory (concat "cd " (bash-completion-quote 
(expand-file-name default-directory)) " ; ") "")
+   (let* ( (command-name (file-name-nondirectory (car words)))
+  (compgen-args (cdr (assoc command-name bash-completion-alist))) )
  (if (not compgen-args)
 ;; no custom completion. use default completion
-(bash-completion-join (list "compgen" "-o" "default" (nth cword 
words)))
+(if (= cword 0)
+;; a command. let emacs expand executable, let bash expand 
builtins, aliases and functions
+(concat (bash-completion-join (list "compgen" "-S" " " "-b" "-a" 
"-A" "function" (car words
+  ;; argument
+  (bash-completion-join (list "compgen" "-o" "default" (nth cword 
words
;; custom completion
(let* ( (args (copy-tree compgen-args))
   (function (or (member "-F" ar

[nongnu] elpa/bash-completion f5885ec87a 002/313: test case for bash-complete

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit f5885ec87a3ad595fca7fa40e4a6535e5bee5707
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

test case for bash-complete
---
 bash-complete.el  | 22 +---
 bash-complete_test.el | 72 +++
 2 files changed, 85 insertions(+), 9 deletions(-)

diff --git a/bash-complete.el b/bash-complete.el
index b15daea8d9..3ea39611fb 100644
--- a/bash-complete.el
+++ b/bash-complete.el
@@ -1,4 +1,6 @@
 
+(require 'comint)
+
 (defun bash-complete-dynamic-complete ()
   "Bash completion function for `comint-complete-dynamic-functions'.
 
@@ -22,6 +24,13 @@ Call bash to do the completion."
  (bash-complete-comm
   line pos words cword)
 
+;; "hell o" wor\ ld 'baa b'a"hell o"world a
+
+;; (progn
+;;   (load-library "~/.emacs.d/bash-complete.el")
+;;   (let ((start 64) (end 108))
+;; (bash-complete-split start end 80)))
+
 (defun bash-complete-split (start end pos)
   "Split LINE like bash would do, keep track of current word at POS.
 
@@ -39,22 +48,15 @@ at POS, the current word: ( (word1 word2 ...) . wordnum )"
   (setq quote char-start))
 (bash-complete-split-1 start end pos quote accum)))
 
-;; "hell o" wor\ ld 'baa b'a"hell o"world a
-
-;; (progn
-;;   (load-library "~/.emacs.d/bash-complete.el")
-;;   (let ((start 64) (end 108))
-;; (bash-complete-split start end 80)))
-
 (defun bash-complete-split-1 (start end pos quote accum)
   (skip-chars-forward (bash-complete-nonsep quote) end)
   (cond
;; an escaped char, skip, whatever it is
-   ((= ?\\ (char-before))
+   ((and (char-before) (= ?\\ (char-before)))
 (forward-char)
 (bash-complete-split-1 start end pos (if (and quote (= quote 
(char-before))) nil quote) accum))
;; opening quote
-   ((and (not quote) (or (= ?' (char-after)) (= ?\" (char-after
+   ((and (not quote) (char-after) (or (= ?' (char-after)) (= ?\" 
(char-after
 (bash-complete-split-0 start end pos accum))
;; closing quote
((and quote (= quote (char-after)))
@@ -89,3 +91,5 @@ calls compgen.
 The result is a list of candidates, which might be empty."
 
   )
+
+(provide 'bash-complete)
\ No newline at end of file
diff --git a/bash-complete_test.el b/bash-complete_test.el
new file mode 100644
index 00..55789ef11a
--- /dev/null
+++ b/bash-complete_test.el
@@ -0,0 +1,72 @@
+;;; bash-complete_test.el --- Tests jbtn-complete.el
+
+
+;;; Commentary:
+;;
+;; This file defines `bash-complete-regress' and run the
+;; regression tests if and only if regress is already imported.
+;;
+
+;;; History:
+;;
+
+;;; Code:
+(eval-when-compile
+  ;; force reload
+  (load-library "~/.emacs.d/bash-complete.el")
+
+  (require 'sz-testutils)
+
+  ;; This code will not appear in the compiled (.elc) file
+  (put 'bash-complete-regress 'regression-suite t)
+  (setq bash-complete-regress
+   '("bash-complete-regress"
+ ;; Each test in the suite is of the form:
+ ;;   ([description] probe grader)
+ ;;   DESCRIPTION - string
+ ;;   PROBE -  a sexp which runs the actual test
+ ;;   GRADER - the desired result or a sexp which determines
+ ;;   how we did
+
+ ("bash-complete-split simple"
+  (sz-testutils-with-buffer
+   '("a hello world b c")
+   (bash-complete-split 1 (line-end-position) 0))
+  '("a" "hello" "world" "b" "c"))
+
+ ("bash-complete-split escaped space"
+  (sz-testutils-with-buffer
+   '("a hello\\ world b c")
+   (bash-complete-split 1 (line-end-position) 0))
+  '("a" "hello\\ world" "b" "c"))
+
+ ("bash-complete-split double quotes"
+  (sz-testutils-with-buffer
+   '("a \"hello world\" b c")
+   (bash-complete-split 1 (line-end-position) 0))
+  '("a" "\"hello world\"" "b" "c"))
+
+ ("bash-complete-split single quotes"
+  (sz-testutils-with-buffer
+   '("a \"hello world\" b c")
+   (bash-complete-split 1 (line-end-position) 0))
+  '("a" "\"hello world\"" "b" "c"))
+
+ ("bash-complete-split complex quote mix"
+  (sz-testutils-with-buffer
+   '("a hel\"lo w\"o'rld b'c d")
+   (bash-complete-split 1 (line-end-position) 0))
+  '("a" "hel\"lo w\"o'rld b'c" "d"))
+
+  )))
+
+
+;; Run diagnostics when this module is evaluated or compiled
+;; if and only if the "regress" package is already loaded.
+;; This code will not appear in the compiled (.elc) file
+(eval-when-compile
+  (autoload 'regress "regress" "run regression test suites" t)
+  (if (featurep 'regress)
+  (regress bash-complete-regress)))
+
+;;; bash-complete_test.el ends here



[nongnu] elpa/bash-completion 8c771b10d1 082/313: fix typo

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 8c771b10d1d85dbc63c4ad4152a37ad64d3665c1
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

fix typo
---
 bash-completion.el | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index cdaff62a07..be0de56472 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -19,10 +19,11 @@
 ;; process.  Bash-completion.el then uses this process to do the actual
 ;; completion and includes it into Emacs completion suggestions.
 ;;
-;; A simpler alternative to bash-completion.el is to run a bash shell
-;; in a buffer in term mode(M-x `ansi-term').  Unfortunately, many
-;; Emacs editing features are not available when running in term mode.
-;; Also, term mode is not available in shell-command prompts.
+;; A simpler and more complete alternative to bash-completion.el is to
+;; run a bash shell in a buffer in term mode(M-x `ansi-term').
+;; Unfortunately, many Emacs editing features are not available when
+;; running in term mode.  Also, term mode is not available in
+;; shell-command prompts.
 ;;
 ;; INSTALLATION
 ;;
@@ -36,7 +37,7 @@
 ;; 'bash-completion-dynamic-complete))
 ;; 3. reload your .emacs (M-x `eval-buffer') or restart
 ;;
-;; Once this is done, use  as usual do dynamic completion from
+;; Once this is done, use  as usual to do dynamic completion from
 ;; shell mode or a shell command minibuffer, such as the one started
 ;; for M-x `compile'. Note that the first completion is slow, as emacs
 ;; launches a new bash process.
@@ -53,7 +54,7 @@
 ;;
 ;; Loading /etc/bash_completion often takes time, and is not necessary
 ;; in shell mode, since completion is done by a separate process, not
-;; the process shel-mode process.
+;; the process shell-mode process.
 ;;
 ;; To turn off bash completion when running from emacs but keep it on
 ;; for processes started by bash-completion.el, add this to your .bashrc:



[nongnu] elpa/bash-completion d65f7e018d 118/313: Skip integration tests if /bin/bash is not executable.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit d65f7e018df7e83068f742a52440a69961597152
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Skip integration tests if /bin/bash is not executable.
---
 bash-completion-test.el | 4 
 1 file changed, 4 insertions(+)

diff --git a/bash-completion-test.el b/bash-completion-test.el
index f4f68ad1df..5f6d0707a3 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -632,6 +632,7 @@ garbage
  (kill-buffer shell-buffer))
 
 (ert-deftest bash-completion-interaction-test ()
+  (skip-unless (file-executable-p bash-completion-prog))
   (should (equal
   '(nil t t ("help ") "t\n" nil nil)
   (bash-completion_test-harness
@@ -651,6 +652,7 @@ garbage
 (bash-completion-is-running))
 
 (ert-deftest bash-completion-setenv-test ()
+  (skip-unless (file-executable-p bash-completion-prog))
   (should (equal
   "t\n"
   (bash-completion_test-harness
@@ -659,12 +661,14 @@ garbage
  (buffer-string))
 
 (ert-deftest bash-completion-one-completion-test ()
+  (skip-unless (file-executable-p bash-completion-prog))
   (should (equal '(16 ("__bash_complete_wrapper "
   ;; TODO: again, why is this duplicated?
   "__bash_complete_wrapper "))
 (bash-completion_test-with-shell "__bash_complete_"
 
 (ert-deftest bash-completion-wordbreak-completion-test ()
+  (skip-unless (file-executable-p bash-completion-prog))
   (should (equal '(3 ("/bin/"))
 (bash-completion_test-with-shell "export PATH=/sbin:/bi"
 



[nongnu] elpa/bash-completion ce59fb017a 202/313: Fallback to the use of a separate process if an error occurs

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit ce59fb017affb0ab18c8ecb861b73b61e72dc088
Author: montag451 
Commit: montag451 

Fallback to the use of a separate process if an error occurs
---
 bash-completion.el | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 79d4b62c7f..295c067d9e 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -150,8 +150,11 @@ BASH completion is only available in the environment for 
which
 
 When set to a non-nil value, separate processes will be used to
 perform completion. If nil, the process associated with the
-current buffer is used to perform completion. If no process is
-associated with the current buffer, a separate process is used."
+current buffer is used to perform completion. Even when this
+variable is set to nil, a separate process can be used to perform
+completion when:
+- no process is associated with the current buffer
+- an error occurred while trying to get completions"
   :type 'boolean
   :group 'bash-completion)
 
@@ -480,6 +483,17 @@ When doing completion outside of a comint buffer, call
   (if (fboundp 'completion-table-with-cache)
   'completion-table-with-cache 'completion-table-dynamic))
 
+(defun bash-completion--complete (comp process)
+  (condition-case err
+  (bash-completion-comm comp process)
+(error (if (not bash-completion-use-separate-processes)
+   ;; try again with a separate process
+   (let* ((bash-completion-use-separate-processes t)
+  (process (bash-completion-require-process)))
+ (bash-completion-comm comp process))
+ ;; re-throw the error
+ (signal (car err) (cdr err))
+
 ;;;###autoload
 (defun bash-completion-dynamic-complete-nocomint
 (comp-start comp-pos &optional dynamic-table)
@@ -522,8 +536,8 @@ Returns (list stub-start stub-end completions) with
   (lambda (_)
 (let ((bash-completion-use-separate-processes
use-separate-processes))
-  (bash-completion-comm comp process
-   (bash-completion-comm comp process)))
+  (bash-completion--complete comp process
+   (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."



[nongnu] elpa/bash-completion 062acfab3e 052/313: updated documentation

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 062acfab3e9b6e91ee0363cf76435ac0b0958658
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

updated documentation
---
 bash-completion.el | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 4b2440ec9b..1ecfecc816 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -297,13 +297,16 @@ The result is a list of candidates, which might be empty."
 (bash-completion-starts-with str (expand-file-name 
"~")))
(substring (concat "~" (substring str (length 
(expand-file-name "~"
   (length prefix)))
-  ;; bash sometimes just prints whatever needs to be expanded,
-  ;; for example: "export PATH=". Prepend the old
-  ;; prefix to avoid confusing comint-dynamic-simple-complete
+  ;; completion sometimes only applies to the last word, as
+  ;; defined by COMP_WORDBREAKS. This detects and works around
+  ;; this feature.
   ((bash-completion-starts-with
 (setq rebuilt (concat 
(bash-completion-before-last-wordbreak prefix) str))
 prefix)
(substring rebuilt (length prefix)))
+  ;; there is no meaningful link between the prefix and
+  ;; the string. just append the string to the prefix and
+  ;; hope for the best.
   (t str
(when (bash-completion-ends-with rest " ")
 (setq rest (substring rest 0 -1))
@@ -375,12 +378,12 @@ The result is a list of candidates, which might be empty."
(bash-completion-send "function __bash_complete_wrapper { eval 
$__BASH_COMPLETE_WRAPPER; }" process)
;; attempt to turn off unexpected status messages from bash
;; if the current version of bash does not support these options,
-   ;; the command will fail silently and be ignored
+   ;; the command will fail silently and be ignored.
(bash-completion-send "shopt -u mailwarn; shopt -u checkjobs" 
process)
;; some bash completion functions use quote_readline to double-quote
;; strings - which compgen understands but only in some environment.
;; disable this dreadful business to get a saner way of handling
-   ;; spaces.
+   ;; spaces. Noticed in bash_completion v1.872.
(bash-completion-send "function quote_readline { echo \"$1\"; }" 
process)
(bash-completion-send "complete -p" process)
(bash-completion-build-alist (process-buffer process))
@@ -408,7 +411,8 @@ The result is a list of candidates, which might be empty."
  (if (not compgen-args)
 ;; no custom completion. use default completion
 (if (= cword 0)
-;; a command. let emacs expand executable, let bash expand 
builtins, aliases and functions
+;; a command. let emacs expand executable, let bash
+;; expand builtins, aliases and functions
 (concat (bash-completion-join (list "compgen" "-S" " " "-b" "-a" 
"-A" "function" (car words
   ;; argument
   (bash-completion-join (list "compgen" "-o" "default" (nth cword 
words



[nongnu] elpa/bash-completion 1b7ec87915 233/313: Fix byte-compilation error under Emacs 24 and 25.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 1b7ec8791553ef17c87bc777f8c06cb3cde11bf2
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Fix byte-compilation error under Emacs 24 and 25.

comint-last-prompt is only available starting with Emacs 26.
---
 bash-completion.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/bash-completion.el b/bash-completion.el
index f16e26a32d..f50dd7fdc4 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1345,6 +1345,11 @@ and would like bash completion in Emacs to take these 
changes into account."
   (setq no-timeout (accept-process-output process timeout nil t)))
 no-timeout))
 
+(when (< emacs-major-version 26)
+  ;; comint-last-prompt was not available prior to Emacs 26.1, so we
+  ;; always fallback to comint-prompt-regexp.
+  (defvar comint-last-prompt nil))
+
 (defun bash-completion--get-prompt-regexp ()
   (if comint-last-prompt
   (let ((start (car comint-last-prompt))



[nongnu] elpa/bash-completion cad904abfd 247/313: Redefine quote_readline from setup-bash-common.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit cad904abfd51ea637cfb28ebe71aeaee12487d4f
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Redefine quote_readline from setup-bash-common.

quote_readline isn't specific to multi-process situation, so should be
redefined in all cases.
---
 bash-completion.el | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 20a8abc7c0..156e97ebf5 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -425,6 +425,14 @@ returned."
   " return $ret; "
   "}")
  process))
+
+;; some bash completion functions use quote_readline
+;; to double-quote strings - which compgen understands
+;; but only in some environment. disable this dreadful
+;; business to get a saner way of handling spaces.
+;; Noticed in bash_completion v1.872.
+(bash-completion-send "function quote_readline { echo \"$1\"; }" process)
+
 (bash-completion-send "echo -n ${COMP_WORDBREAKS}" process)
 (process-put process 'wordbreaks
  (with-current-buffer (bash-completion--get-buffer process)
@@ -1167,12 +1175,6 @@ is set to t."
 "export -n MAIL\n"
 "export -n MAILPATH\n"
 "unset HISTFILE\n"
-;; some bash completion functions use quote_readline
-;; to double-quote strings - which compgen understands
-;; 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"
 ;; User's profiles can turn line editing back on,
 ;; so make sure it's off
 "set +o emacs\n"



[nongnu] elpa/bash-completion fbdc78b877 198/313: Support compopt when using Bash 4.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit fbdc78b8770833752ac4bda28e2c3ea764bf8e76
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Support compopt when using Bash 4.

This commit allows bash 4 completion functions to manipulate -o
nospace option using compopt. This is done by generalizing the
approach taken for supporting 124 status: introducing extra "side
channel" information into the output, captured later by
emacs-bash-completion.

This seems the only compot option that's useful to intercept for
bash-completion, so this commit fixes #32
---
 bash-completion.el   | 126 +++
 test/bash-completion-integration-test.el |  45 +++
 test/bash-completion-test.el |  61 ++-
 3 files changed, 198 insertions(+), 34 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index ba4895a5b4..eb93f99876 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -226,13 +226,6 @@ Bash processes")
 (defconst bash-completion-special-chars "[^-0-9a-zA-Z_./\n=]"
   "Regexp of characters that must be escaped or quoted.")
 
-(defconst bash-completion-wrapped-status
-  "\e\ebash-completion-wrapped-status=124\e\e"
-  "String output by __bash_complete_wrapper when the wrapped
-function returns status code 124, meaning that the completion
-should be retried. This should be a string that's unlikely
-to be included into a completion output.")
-
 (eval-when-compile
   (unless (or (and (= emacs-major-version 24) (>= emacs-minor-version 1))
   (>= emacs-major-version 25))
@@ -261,6 +254,7 @@ to be included into a completion output.")
   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) 
 )
 
 (defun bash-completion--type (comp)
@@ -283,10 +277,13 @@ The option can be:
  - set globally, by setting `bash-completion-nospace' to t
  - set for a customized completion, in bash, with
'-o' 'nospace'."
-  (if bash-completion-nospace
-  t ; set globally
-(bash-completion--has-compgen-option
- (bash-completion--compgen-args comp) "nospace")))
+  (let ((cell))
+(cond
+ (bash-completion-nospace t) ; set globally
+ ((setq cell (assq 'nospace (bash-completion--compopt comp)))
+  (cdr cell))
+ (t (bash-completion--has-compgen-option
+ (bash-completion--compgen-args comp) "nospace")
 
 (defun bash-completion--command (comp)
   "Return the current command for the completion, if there is one."
@@ -726,15 +723,23 @@ for directory name detection to work.
 Post-processing includes escaping special characters, adding a /
 to directory names, replacing STUB with UNPARSED-STUB in the
 result. See `bash-completion-fix' for more details."
-  (let ((candidates) (result (list)))
-(setq candidates (delete-dups
-  (with-current-buffer buffer
-(split-string (buffer-string) "\n" t
+  (let ((output) (candidates))
+(with-current-buffer buffer
+  (let ((compopt (bash-completion--parse-side-channel-data "compopt")))
+(cond
+ ((string= "-o nospace" compopt)
+  (setf (bash-completion--compopt comp) '((nospace . t
+ ((string= "+o nospace" compopt)
+  (setf (bash-completion--compopt comp) '((nospace . nil))
+  (setq output (buffer-string)))
+(setq candidates (delete-dups (split-string output "\n" t)))
 (if (eq 1 (length candidates))
 (list (bash-completion-fix (car candidates) comp t))
-  (dolist (completion candidates)
-(push (bash-completion-fix completion comp nil) result))
-  (delete-dups (nreverse result)
+  ;; multiple candidates
+  (let ((result (list)))
+(dolist (completion candidates)
+  (push (bash-completion-fix completion comp nil) result))
+(delete-dups (nreverse result))
 
 (defun bash-completion-fix (str comp single)
   "Fix completion candidate in STR for COMP
@@ -989,15 +994,43 @@ is set to t."
 (with-current-buffer (process-buffer process)
   (string-to-number (buffer-substring-no-properties
  (point-min) (point-max)
-  (bash-completion-send (concat "function __bash_complete_wrapper 
{"
-(if (>= bash-major-version 4)
-" COMP_TYPE=9; COMP_KEY=9;" "")
-" eval $__BASH_COMPLETE_WRAPPER;"
-" n=$?; if [[ $n = 124 ]]; then"
-"  echo -n \""
-bash-completion-wrapped-status
-

[nongnu] elpa/bash-completion f3b11e1221 139/313: Preserve original, quoted version of the string being completed when

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit f3b11e12214f65967282deab586436d91256c96f
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Preserve original, quoted version of the string being completed when
returning results.

One of the first things that bash-completion-dynamic-complete-nocomint
does is parse and tokenize the current line, with
bash-completion-process-tokens. compgen then gets the parsed result and
returns matches for that parsed result.

In some cases, running compgen on the parsed result resulted in
completed words not starting with the word to be completed, as found in
the buffer. Such results were ignored by the shell completion.

Example:
 ls ~/Documents/Modes\ d\'emplois/M

compgen would see "~/Documents/Modes d'emplois" without backslashes and
return, for example "~/Documents/Modes d'emplois/MXX.pdf" - but this
doesn't match ~/Documents/Modes\ d\'emplois/

With this fix, the original, unparsed version of the string is passed
down to bash-completion-fix, so that it can postprocess the completion
candidates returned by compgen and guarantee that they match exactly
with the buffer content.
---
 bash-completion-test.el |  32 ++-
 bash-completion.el  | 140 ++--
 2 files changed, 106 insertions(+), 66 deletions(-)

diff --git a/bash-completion-test.el b/bash-completion-test.el
index ac2241535b..0bb63c73b3 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -442,15 +442,15 @@ garbage
   (should (equal t (bash-completion-ends-with "hello" ""
 
 (ert-deftest bash-completion-last-wordbreak-test ()
-  (should (equal '("a:b:c:d:" . "e")
+  (should (equal '("a:b:c:d:" "e" ?:)
 (bash-completion-last-wordbreak-split "a:b:c:d:e")))
-  (should (equal '("hello=" . "world")
+  (should (equal '("hello=" "world" ?=)
 (bash-completion-last-wordbreak-split "hello=world")))
-  (should (equal '("hello>" . "world")
+  (should (equal '("hello>" "world" ?>)
 (bash-completion-last-wordbreak-split "hello>world")))
-  (should (equal '(">" . "world")
+  (should (equal '(">" "world" ?>)
 (bash-completion-last-wordbreak-split ">world")))
-  (should (equal '("" . "hello")
+  (should (equal '("" "hello" ?\0)
 (bash-completion-last-wordbreak-split "hello"
 
 (ert-deftest bash-completion-before-last-wordbreak-test ()
@@ -475,34 +475,38 @@ garbage
 (ert-deftest bash-completion-fix-test ()
   ;; escape rest
   (should (equal "a\\ bc\\ d\\ e"
-(bash-completion-fix "a\\ bc d e" "a\\ b")))
+(bash-completion-fix "a\\ bc d e" "a\\ b" "a\\ b")))
+
+  ;; recover original escaping
+  (should (equal "a' 'bc\\ d\\ e"
+(bash-completion-fix "a\\ bc d e" "a\\ b" "a' 'b")))
 
   ;; do not escape final space
   (should (equal "ab "
 (let ((bash-completion-nospace nil))
-  (bash-completion-fix "ab " "a"
+  (bash-completion-fix "ab " "a" "a"
   
   ;; remove final space
   (should (equal "ab"
 (let ((bash-completion-nospace t))
-  (bash-completion-fix "ab " "a"
+  (bash-completion-fix "ab " "a" "a"
 
   ;; unexpand home and escape
   (should (equal "~/a/hello\\ world"
 (bash-completion-fix (expand-file-name "~/a/hello world")
- "~/a/he")))
+ "~/a/he" "~/a/he")))
 
   ;; match after wordbreak and escape
   (should (equal "a:b:c:hello\\ world"
-(bash-completion-fix "hello world" "a:b:c:he")))
+(bash-completion-fix "hello world" "a:b:c:he" "a:b:c:he")))
 
   ;; just append
   (should (equal "hello\\ world"
-(bash-completion-fix " world" "hello")))
+(bash-completion-fix " world" "hello" "hello")))
 
   ;; subset of the prefix"
   (should (equal "Dexter"
-(bash-completion-fix "Dexter" "Dexter'"
+(bash-completion-fix "Dexter" "Dexter'" "Dexter'"
 
 (ert-deftest bash-completion-extract-candidates-test ()
   (should (equal 
@@ -512,7 +516,7 @@ garbage
(cl-letf (((symbol-function 'bash-completion-buffer)
   (lambda () (current-buffer)))
  (bash-completion-nospace nil))
- (bash-completion-extract-candidates "hello" nil))
+ (bash-completion-extract-candidates "hello" "hello" nil))
 
 (ert-deftest bash-completion-nonsep-test ()
   (should (equal "^ \t\n\r;&|'\"#"
@@ -643,7 +647,7 @@ garbage
(should-not (null (member
  "help "
  (let ((bash-completion-nospace nil))
-   (bash-completion-comm "hel" 4 '("hel") 0 nil)
+   (bash-completion-comm "hel" 4 '("hel") 0 nil "hel")
(bash-completi

[nongnu] elpa/bash-completion 1144ae69a9 056/313: documented the tokenizer

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 1144ae69a90415e5c43e95617d49eb52c5902032
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

documented the tokenizer
---
 bash-completion.el | 221 ++---
 1 file changed, 175 insertions(+), 46 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 783c07a232..cdc0722b58 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -158,22 +158,40 @@ functions adds single quotes around it and return the 
result. "
"'")))
 
 (defun bash-completion-parse-line (start end pos)
+  "Parse a command line between START and END with POS as the cursor position.
+
+This function parse the portion of the current buffer between
+START and END as a BASH command-line and returns the variables
+compgen function expect in an association list.
+
+POS specifies the current cursor position and marks the word to
+be completed.
+
+Return an association list with the current symbol as keys:
+ line - the relevant command between START and END (string)
+ point - position of the cursor in line (number)
+ words - line split into words, unescaped (list of strings)
+ cword - 0-based index of the word to be completed in words (number)
+"
   (bash-completion-parse-line-postprocess
(bash-completion-parse-current-command
 (bash-completion-tokenize start end) pos) pos))
 
-(defun bash-completion-strings-from-tokens (accum)
-  (mapcar 'bash-completion-tokenize-get-str accum))
+(defun bash-completion-parse-line-postprocess (tokens pos)
+  "Extract from TOKENS the data needed by compgen functions.
 
-(defun bash-completion-parse-line-postprocess (accum pos)
-  (let ((index 0) (strings nil) (current nil) (accum-rest accum) (cword nil)
+This function takes a list of TOKENS created by `bash-completion-tokenize'
+for the current buffer and generate the data needed by compgen functions
+as returned by `bash-completion-parse-line'.
+"
+  (let ((index 0) (strings nil) (token nil) (tokens-rest tokens) (cword nil)
(start (min pos
-   (car (bash-completion-tokenize-get-range (car accum))
-(while accum-rest
-  (setq current (car accum-rest))
-  (setq accum-rest (cdr accum-rest))
+   (car (bash-completion-tokenize-get-range (car tokens))
+(while tokens-rest
+  (setq token (car tokens-rest))
+  (setq tokens-rest (cdr tokens-rest))
   (unless cword
-   (let ((range (bash-completion-tokenize-get-range current)))
+   (let ((range (bash-completion-tokenize-get-range token)))
  (cond
   ((and (>= pos (car range))
 (<= pos (cdr range)))
@@ -181,26 +199,41 @@ functions adds single quotes around it and return the 
result. "
   ((< pos (car range))
(setq cword index)
(push "" strings)
-  (push (bash-completion-tokenize-get-str current) strings)
+  (push (bash-completion-tokenize-get-str token) strings)
   (setq index (1+ index)))
 (unless cword
   (setq cword index)
   (push "" strings))
 (list
- (cons 'line (buffer-substring-no-properties start (cdr 
(bash-completion-tokenize-get-range current
+ (cons 'line (buffer-substring-no-properties start (cdr 
(bash-completion-tokenize-get-range token
  (cons 'point (- pos start))
  (cons 'cword cword)
  (cons 'words (nreverse strings)
 
-(defun bash-completion-parse-current-command (accum pos)
+(defun bash-completion-parse-current-command (tokens pos)
+  "Extract from TOKENS the tokens forming the current command at POS.
+
+This function takes a list of TOKENS created by
+`bash-completion-tokenize' for the current buffer and select the
+tokens on this list that form the current command given that to
+be completed is at POS.
+
+For example, given this stream of tokens:
+  cd /var/tmp && ls -l *.txt | sort -u
+if POS is on -l, it will select:
+  ls -l *.txt
+if POS is on /var/tmp, it will select:
+  cd /var/tmp
+
+Return a sublist of TOKENS."
   (nreverse (catch 'bash-completion-return
 (let ((command nil) (state 'initial))
-  (dolist (current accum)
-   (let* ((position (bash-completion-tokenize-range-check current pos))
-  (string (bash-completion-tokenize-get-str current))
+  (dolist (token tokens)
+   (let* ((position (bash-completion-tokenize-range-check pos token))
+  (string (bash-completion-tokenize-get-str token))
   (is-terminal
(and (member string '(";" "&" "|" "&&" "||"))
-(let ((range (bash-completion-tokenize-get-range current)))
+(let ((range (bash-completion-tokenize-get-range token)))
   (= (- (cdr range) (car range))
  (length string))
  (cond
@@ -215,21 +248,35 @@ functions adds single quotes around it and return the 
result. "
   ((and (eq state 'initial)
 (null (string-match "=" st

[nongnu] elpa/bash-completion 29b5fc860a 312/313: Shorten overly long docstring (#53)

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 29b5fc860a5b0db9828acfceca09b773fbdb8e8a
Author: Jonas Bernoulli 
Commit: GitHub 

Shorten overly long docstring (#53)
---
 bash-completion.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index 554ef56c78..d77139073d 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -236,7 +236,9 @@ to remove the extra space bash adds after a completion."
 
 (defvar bash-completion-start-files
   '("~/.emacs_bash.sh" "~/.emacs.d/init_bash.sh")
-  "Shell files that, if they exist, will be sourced at the beginning of a bash 
completion subprocess.
+  "Shell files that sourced at the beginning of a bash completion subprocess.
+
+If a listed file does not exist that is silently ignored.
 
 This variable is only used when creating separate processes for
 performing completion. See



[nongnu] elpa/bash-completion 62c6567af6 158/313: Complete argument rename

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 62c6567af6a7293348e83b7e290a4f7264b3dd86
Author: Jonas Bernoulli 
Commit: Jonas Bernoulli 

Complete argument rename

This fixes f3b11e12214f65967282deab586436d91256c96f.
---
 bash-completion.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index 79fd1aa473..2d0c589620 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -373,7 +373,7 @@ passed to the parameter OPEN-QUOTE.
 
 This function is not meant to be called outside of
 `bash-completion-dynamic-complete'."
-  (let* ((wordbreak-split (bash-completion-last-wordbreak-split stub))
+  (let* ((wordbreak-split (bash-completion-last-wordbreak-split parsed-stub))
  (before-wordbreak (nth 0 wordbreak-split))
 (after-wordbreak (nth 1 wordbreak-split))
  (separator (nth 2 wordbreak-split))



[nongnu] elpa/bash-completion 9eb026ae0b 025/313: fixed current directory for adding slash, workaround for bash ~ expansion

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 9eb026ae0b84b3c2d21c61559fcf0d513c26751d
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

fixed current directory for adding slash, workaround for bash ~ expansion
---
 bash-completion.el | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index d649d6c1d7..0686c015b7 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -160,15 +160,26 @@ 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"))
-  (with-current-buffer (bash-completion-buffer)
-(let ((bash-completion-prefix (nth cword words)))
-  (mapcar 'bash-completion-fix (split-string (buffer-string) "\n" t)
+  (let ((bash-completion-prefix (nth cword words)))
+(mapcar 'bash-completion-fix 
+   (with-current-buffer (bash-completion-buffer)
+ (split-string (buffer-string) "\n" t)
 
 (defun bash-completion-fix (str)
   (bash-completion-addsuffix 
-   (if (bash-completion-starts-with str bash-completion-prefix)
-   str
- (concat bash-completion-prefix str
+   (cond
+((bash-completion-starts-with str bash-completion-prefix)
+ str)
+;; bash expands the home directory automatic. this is confusing
+;; for comint-dynamic-simple-complete
+((and (bash-completion-starts-with bash-completion-prefix "~")
+ (bash-completion-starts-with str (expand-file-name "~")))
+ (concat "~" (substring str (length (expand-file-name "~")
+;; bash sometimes just prints whatever needs to be expanded,
+;; for example: "export PATH=". Prepend the old
+;; prefix to avoid confusing comint-dynamic-simple-complete
+(t
+ (concat bash-completion-prefix str)
 
 (defun bash-completion-starts-with (str prefix)
   (let ((prefix-len (length prefix))
@@ -178,10 +189,12 @@ The result is a list of candidates, which might be empty."
  (equal (substring str 0 prefix-len) prefix
 
 (defun bash-completion-addsuffix (str)
+  (message "file=%s, accessible=%s" (expand-file-name str default-directory)
+  (file-accessible-directory-p (expand-file-name str 
default-directory)))
   (let ((end (substring str -1)))
 (if (and (not (eq end " "))
 (not (eq end "/"))
-(file-accessible-directory-p str))
+(file-accessible-directory-p (expand-file-name str 
default-directory)))
(concat str "/")
 str)))
 



[nongnu] elpa/bash-completion ca4fbce016 305/313: Turn off bash completion when non-bash prompts are detected.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit ca4fbce016f51150d84f50a459f720d0c8ac7ed3
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Turn off bash completion when non-bash prompts are detected.

In single-process mode, the comint version of
bash-completion-dynamic-complete automatically turns off bash completion
when it thinks it's not talking to a BASH command-line.

This is controlled by bash-completion-nonbash-prompts and
bash-completion-bash-prompts.

This is a way of avoiding issue #44.
---
 bash-completion.el | 58 +++---
 1 file changed, 51 insertions(+), 7 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index cb81729914..4b888e658f 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -234,6 +234,30 @@ to remove the extra space bash adds after a completion."
   :type '(boolean)
   :group 'bash-completion)
 
+(defcustom bash-completion-bash-prompts nil
+  "Regexps that match BASH prompts (PS1).
+
+If a prompt matches one of the regular expression on this list,
+it'll be considered a bash prompt even if it matches one of the
+regular expressions in `bash-completion-nonbash-prompts'.
+
+See `bash-completion-nonbash-prompts' for more details."
+  :type '(repeat string)
+  :group 'bash-completion)
+
+(defcustom bash-completion-nonbash-prompts '("[>+] +$")
+  "Regexps that match non-BASH prompts and BASH PS2 prompts.
+
+If a prompt matches one of the regular expressions on this list, 
+`bash-completion-dynamic-complete' doesn't attempt to communicate
+with the current BASH process to do completion.
+
+If your BASH prompt matches one of the regexps on this list, you
+might want to put a regexp for it in
+`bash-completion-bash-prompts'."
+  :type '(repeat string)
+  :group 'bash-completion)
+
 (defvar bash-completion-start-files
   '("~/.emacs_bash.sh" "~/.emacs.d/init_bash.sh")
   "Shell files that, if they exist, will be sourced at the beginning of a bash 
completion subprocess.
@@ -480,13 +504,27 @@ When doing completion outside of a comint buffer, call
(if (and (not (window-minibuffer-p))
 (not (null bash-completion-message-delay)))
(run-at-time
-bash-completion-message-delay nil
-(lambda () (message "Bash completion..."))
+ bash-completion-message-delay nil
+ (lambda () (message "Bash completion..."))
   (unwind-protect
-  (bash-completion-dynamic-complete-nocomint
-   (comint-line-beginning-position)
-   (point)
-   'dynamic-table)
+  (let ((prompt-end (comint-line-beginning-position)))
+(if (or bash-completion-use-separate-processes
+(let* ((prompt-start (save-excursion
+   (goto-char prompt-end)
+   (line-end-position -1)))
+   (prompt (buffer-substring-no-properties
+prompt-start prompt-end)))
+  (or
+   (bash-completion--match-any
+prompt bash-completion-bash-prompts)
+   (not (bash-completion--match-any
+ prompt bash-completion-nonbash-prompts)
+(bash-completion-dynamic-complete-nocomint
+ prompt-end (point) 'dynamic-table)
+  
+  (error (concat "Bash completion not available. "
+ "Call M-x customize-option 
bash-completion-nonbash-prompts "
+ "if this is incorrect."
 ;; cleanup
 (if message-timer
 (cancel-timer message-timer)
@@ -1526,7 +1564,7 @@ Return the status code of the command, as a number."
 (push (cons 'error "non-bash") bash-completion--debug-info)
 (push (cons 'buffer-string (buffer-substring-no-properties (point-min) 
(point-max)))
   bash-completion--debug-info)
-(error "Bash completion failed; not a bash process."))
+(error "Not a bash process. Fix using M-x customize-option 
bash-completion-nonbash-prompts"))
   (delete-region (point-min) (1+ (match-end 0)))
   (goto-char (point-max))
   ;; Now wait for the real to be executed within timeout. This can
@@ -1679,6 +1717,12 @@ Return the parsed value, as a string or nil."
 (prog1 (match-string 1)
   (delete-region (match-beginning 0) (match-end 0)))
 
+(defun bash-completion--match-any (text regexp-list)
+  (catch 'bash-completion-return
+(dolist (regexp regexp-list) 
+  (when (string-match-p regexp text)
+(throw 'bash-completion-return t)
+
 (defun bash-completion--completion-table-with-cache (comp process)
   "Build a dynamic completion table for COMP using PROCESS.
 



[nongnu] elpa/bash-completion c0f7c20a6b 094/313: added license and missing test dependency

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit c0f7c20a6bdc2f504ec7e84f4ae569015727c182
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

added license and missing test dependency
---
 bash-completion.el  |  16 +++
 bash-completion_test.el |  21 ++-
 license | 339 
 sz-testutils.el | 170 
 4 files changed, 543 insertions(+), 3 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 438ea2716d..fa636a837d 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -1,7 +1,23 @@
 ;;; bash-completion.el --- BASH completion for the shell buffer
 
+;; Copyright (C) 2009 Stephane Zermatten
+
 ;; Author: Stephane Zermatten 
 
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see
+;; `http://www.gnu.org/licenses/'.
+
 ;;; Commentary:
 ;;
 ;; This file defines dynamic completion hooks for shell-mode and
diff --git a/bash-completion_test.el b/bash-completion_test.el
index a554e3517c..0bd53191b1 100644
--- a/bash-completion_test.el
+++ b/bash-completion_test.el
@@ -1,5 +1,23 @@
 ;;; bash-completion_test.el --- Tests bash-completion.el
 
+;; Copyright (C) 2009 Stephane Zermatten
+
+;; Author: Stephane Zermatten 
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see
+;; `http://www.gnu.org/licenses/'.
+
 
 :;;; Commentary:
 ;;
@@ -12,9 +30,6 @@
 
 ;;; Code:
 (eval-when-compile
-  ;; force reload
-  (load-library "~/.emacs.d/bash-completion.el")
-
   (require 'sz-testutils)
   (require 'cl)
 
diff --git a/license b/license
new file mode 100644
index 00..d159169d10
--- /dev/null
+++ b/license
@@ -0,0 +1,339 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone under

[nongnu] elpa/bash-completion c5f2b2756f 129/313: Define sz-testutils as a global variable.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit c5f2b2756f09a7e59dcd0b121e15c614aa4b1380
Author: Jonas Bernoulli 
Commit: Jonas Bernoulli 

Define sz-testutils as a global variable.

To keep the byte-compiler from complaining.
---
 sz-testutils.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sz-testutils.el b/sz-testutils.el
index fbc2b84bd6..dc2cad6cc2 100644
--- a/sz-testutils.el
+++ b/sz-testutils.el
@@ -108,7 +108,7 @@ is: '(\"Here >>\" cursor \"<<.\")"
 (eval-when-compile
   ;; This code will not appear in the compiled (.elc) file
   (put 'sz-testutils-regress 'regression-suite t)
-  (setq sz-testutils-regress
+  (defvar sz-testutils-regress
'("sz-testutils-regress"
  ;; Each test in the suite is of the form:
  ;;   ([description] probe grader)
@@ -167,4 +167,4 @@ is: '(\"Here >>\" cursor \"<<.\")"
   (if (featurep 'regress)
   (regress sz-testutils-regress)))
 
-(provide 'sz-testutils)
\ No newline at end of file
+(provide 'sz-testutils)



[nongnu] elpa/bash-completion d47edb9d41 294/313: Bump version to 3.1, a bugfix release.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit d47edb9d4142a22746009c1f680df93a4fefd107
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Bump version to 3.1, a bugfix release.
---
 bash-completion.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bash-completion.el b/bash-completion.el
index 802cfa0219..89132bb683 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -4,7 +4,7 @@
 
 ;; Author: Stephane Zermatten 
 ;; Maintainer: Stephane Zermatten 
-;; Version: 3.0.0
+;; Version: 3.1.0
 ;; Keywords: shell bash bash-completion
 ;; URL: http://github.com/szermatt/emacs-bash-completion
 ;; Package-Requires: ((emacs "24.3"))



[nongnu] elpa/bash-completion 24088ede85 196/313: Explicitly mention compatibility with Bash 3 and 4.

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 24088ede85742a94f8e239ba063e8587e553d844
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Explicitly mention compatibility with Bash 3 and 4.
---
 README.md  |  9 +++--
 bash-completion.el | 11 ++-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index d8d506abb9..1d8ee49772 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,10 @@ Unfortunately, many Emacs editing features are not available 
when
 running in term mode.  Also, term mode is not available in
 shell-command prompts.
 
+Bash completion can also be run programatically, outside of a
+shell-mode command, by calling
+`bash-completion-dynamic-complete-nocomint'
+
 ## INSTALLATION
 
 1. copy bash-completion.el into a directory that's on Emacs load-path
@@ -95,5 +99,6 @@ important disadvantages:
 
 ## COMPATIBILITY
 
-bash-completion.el is known to work on Emacs, starting with version
-24.1, under Linux and OSX. It does not work on XEmacs.
+bash-completion.el is known to work with Bash 3 and 4, on Emacs,
+starting with version 24.1, under Linux and OSX. It does not work on
+XEmacs.
diff --git a/bash-completion.el b/bash-completion.el
index 5876b1e488..ba4895a5b4 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -111,8 +111,9 @@
 ;;
 ;; COMPATIBILITY
 ;;
-;; bash-completion.el is known to work on Emacs 22 and later under
-;; Linux and OSX. It does not works on XEmacs.
+;; bash-completion.el is known to work with Bash 3 and 4, on Emacs,
+;; starting with version 24.1, under Linux and OSX. It does not work
+;; on XEmacs.
 ;;
 
 ;;; History:
@@ -147,9 +148,9 @@ BASH completion is only available in the environment for 
which
 (defcustom bash-completion-prog (executable-find "bash")
   "Name or path of the BASH executable to run for command-line completion.
 This should be either an absolute path to the BASH executable or
-the name of the bash command if it is on Emacs' PATH.  This
-should point to a recent version of BASH (BASH 3) with support
-for command-line completion."
+the name of the bash command if it is on Emacs' PATH. This should
+point to a recent version of BASH, 3 or 4, with support for
+command-line completion."
   :type '(file :must-match t)
   :group 'bash-completion)
 



[nongnu] elpa/bash-completion 75e5de1494 066/313: fix initial completion

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 75e5de14942b137a8400c574fe68d56994d63cf3
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

fix initial completion
---
 bash-completion.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bash-completion.el b/bash-completion.el
index 8490821400..5e19bc327d 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -520,6 +520,9 @@ 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."
+  ;; start process now, to make sure bash-completion-alist is
+  ;; set before we run bash-completion-generate-line
+  (bash-completion-require-process)
   (bash-completion-send
(concat
 (bash-completion-generate-line line pos words cword)



[nongnu] elpa/bash-completion 9ca7e3a77f 085/313: Fixed errors in documentation

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit 9ca7e3a77fac72688183b198986c5a4c22cf5e10
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Fixed errors in documentation
---
 bash-completion.el | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index cf37ceeb95..3401c08aed 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -37,7 +37,13 @@
 ;;   (add-hook 'shell-dynamic-complete-functions
 ;; 'bash-completion-dynamic-complete)
 ;;   (add-hook 'shell-command-complete-functions
-;; 'bash-completion-dynamic-complete))
+;; 'bash-completion-dynamic-complete)
+;;
+;;   or simpler, but forces you to load this file at startup:
+;; 
+;;   (require 'bash-completion)
+;;   (bash-completion-setup)
+;;
 ;; 3. reload your .emacs (M-x `eval-buffer') or restart
 ;;
 ;; Once this is done, use  as usual to do dynamic completion from
@@ -52,7 +58,7 @@
 ;;   . /etc/bash_completion
 ;;
 ;; Right after enabling programmable bash completion, and whenever you
-;; make changes to you .bashrc, call `bash-completion-restart' to make
+;; make changes to you .bashrc, call `bash-completion-reset' to make
 ;; sure bash completion takes your new settings into account.
 ;;
 ;; Loading /etc/bash_completion often takes time, and is not necessary
@@ -86,7 +92,7 @@
 ;;   Bash-completion.el cannot do that, as it is not aware of anything
 ;;   configured in the current shell. To make bash-completion.el aware
 ;;   of a new alias, you need to add it to .bashrc and restart the
-;;   completion process using `bash-completion-restart'.
+;;   completion process using `bash-completion-reset'.
 ;;
 ;; COMPATIBILITY
 ;;



[nongnu] elpa/bash-completion a2d322fb79 054/313: Added customization group

2022-12-03 Thread ELPA Syncer
branch: elpa/bash-completion
commit a2d322fb7975b72f02f0af132266e60d4aef0467
Author: Stephane Zermatten 
Commit: Stephane Zermatten 

Added customization group
---
 bash-completion.el | 84 --
 1 file changed, 57 insertions(+), 27 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 4649607009..40d3c004c4 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -7,18 +7,47 @@
 ;;  echo "ON"
 ;;fi
 
-(defvar bash-completion-prog "bash"
-  "Command-line to execute bash")
-
-(defvar bash-completion-process-timeout 2.5
+(defgroup bash-completion nil
+  "BASH configurable command-line completion "
+  :group 'shell
+  :group 'shell-command)
+
+(defcustom bash-completion-enabled t
+  "Enable/Disable BASH configurable command-line completion globally.
+
+This flag is useful for temporarily disabling bash completion
+once it's been installed.
+
+Setting this variable to t is NOT enough to enable BASH completion.
+BASH completion is only available in the environment for which
+`bash-completion-dynamic-complete' has been registered. See
+`bash-completion-setup' for that.
+"
+  :type '(boolean)
+  :group 'bash-completion)
+
+(defcustom bash-completion-prog "/bin/bash"
+  "Name or path of the BASH executable to run for command-line completion.
+This should be either an absolute path to the BASH executable or
+the name of the bash command if it is on Emacs' PATH.  This
+should point to a recent version of BASH (BASH 3) with support
+for command-line completion."
+  :type '(file :must-match t)
+  :group 'bash-completion)
+
+(defcustom bash-completion-process-timeout 2.5
   "Timeout value to apply when waiting from an answer from the
 bash process. If bash takes longer than that to answer, the answer
-will be ignored.")
+will be ignored."
+  :type '(float)
+  :group 'bash-completion)
 
-(defvar bash-completion-initial-timeout 30
+(defcustom bash-completion-initial-timeout 30
   "Timeout value to apply when talking to bash for the first time.
 The first thing bash is supposed to do is process /etc/bash_complete,
-which typically takes a long time.")
+which typically takes a long time."
+  :type '(float)
+  :group 'bash-completion)
 
 (defvar bash-completion-process nil
   "Bash process object")
@@ -54,26 +83,27 @@ colon-separated values.")
   "Bash completion function for `comint-complete-dynamic-functions'.
 
 Call bash to do the completion."
-  (when (not (window-minibuffer-p))
-(message "Bash completion..."))
-  (let* ( (pos (point))
- (start (comint-line-beginning-position))
- (end (line-end-position))
- (parsed (bash-completion-parse-line start end pos))
- (line (cdr (assq 'line parsed)))
- (point (cdr (assq 'point parsed)))
- (cword (cdr (assq 'cword parsed)))
- (words (cdr (assq 'words parsed)))
- (stub (nth cword words))
- (completions (bash-completion-comm line point words cword))
- ;; Override configuration for comint-dynamic-simple-complete.
- ;; Bash adds a space suffix automatically.
- (comint-completion-addsuffix nil) )
-(if completions
-   (comint-dynamic-simple-complete stub completions)
-  ;; no standard completion
-  ;; try default (file) completion after a wordbreak
-  (bash-completion-dynamic-try-wordbreak-complete stub
+  (when bash-completion-enabled
+(when (not (window-minibuffer-p))
+  (message "Bash completion..."))
+(let* ( (pos (point))
+   (start (comint-line-beginning-position))
+   (end (line-end-position))
+   (parsed (bash-completion-parse-line start end pos))
+   (line (cdr (assq 'line parsed)))
+   (point (cdr (assq 'point parsed)))
+   (cword (cdr (assq 'cword parsed)))
+   (words (cdr (assq 'words parsed)))
+   (stub (nth cword words))
+   (completions (bash-completion-comm line point words cword))
+   ;; Override configuration for comint-dynamic-simple-complete.
+   ;; Bash adds a space suffix automatically.
+   (comint-completion-addsuffix nil) )
+  (if completions
+ (comint-dynamic-simple-complete stub completions)
+   ;; no standard completion
+   ;; try default (file) completion after a wordbreak
+   (bash-completion-dynamic-try-wordbreak-complete stub)
 
 (defun bash-completion-dynamic-try-wordbreak-complete (stub)
   (let* ((wordbreak-split (bash-completion-last-wordbreak-split stub))



  1   2   3   4   >