zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH v2 1/2] complete absolute paths for mpc add
@ 2024-11-12 18:54 Karel Balej
  2024-11-12 18:54 ` [PATCH v2 2/2] enable completion for mpc insert Karel Balej
  0 siblings, 1 reply; 2+ messages in thread
From: Karel Balej @ 2024-11-12 18:54 UTC (permalink / raw)
  To: zsh-workers; +Cc: balejk

When connecting via Unix socket, mpc can queue files from outside the
music directory as well when given the absolute path.
---

Notes:
    v2:
    - Fix indentation.
    - Do not exit non-zero if either completion succeeds.
    - RFC v1: https://www.zsh.org/mla/workers/2024/msg00694.html

 Completion/Unix/Command/_mpc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc
index c3f93878ca28..d1036ccfab37 100644
--- a/Completion/Unix/Command/_mpc
+++ b/Completion/Unix/Command/_mpc
@@ -178,6 +178,16 @@ _mpc_helper_files() {
   fi
 }
 
+(( $+functions[_mpc_helper_all_files] )) ||
+_mpc_helper_all_files() {
+  local ret=1
+  if [[ $words[CURRENT] == [/~]* ]]; then
+    _files
+    ret=$?
+  fi
+  _mpc_helper_files || return $ret
+}
+
 (( $+functions[_mpc_helper_directories] )) ||
 _mpc_helper_directories() {
   if [[ -n $MPD_MUSIC_DIR ]]; then
@@ -204,7 +214,7 @@ _mpc_helper_outputs() {
 }
 
 _mpc_add() {
-  _mpc_helper_files
+  _mpc_helper_all_files
 }
 
 _mpc_albumart() {
-- 
2.47.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2 2/2] enable completion for mpc insert
  2024-11-12 18:54 [PATCH v2 1/2] complete absolute paths for mpc add Karel Balej
@ 2024-11-12 18:54 ` Karel Balej
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Balej @ 2024-11-12 18:54 UTC (permalink / raw)
  To: zsh-workers; +Cc: balejk

---
 Completion/Unix/Command/_mpc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc
index d1036ccfab37..e3383e56dd3d 100644
--- a/Completion/Unix/Command/_mpc
+++ b/Completion/Unix/Command/_mpc
@@ -217,6 +217,10 @@ _mpc_add() {
   _mpc_helper_all_files
 }
 
+_mpc_insert() {
+  _mpc_helper_all_files
+}
+
 _mpc_albumart() {
   _mpc_helper_files
 }
-- 
2.47.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-12 18:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12 18:54 [PATCH v2 1/2] complete absolute paths for mpc add Karel Balej
2024-11-12 18:54 ` [PATCH v2 2/2] enable completion for mpc insert Karel Balej

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).