zsh-workers
 help / color / mirror / code / Atom feed
From: Karel Balej <balejk@matfyz.cz>
To: zsh-workers@zsh.org
Cc: balejk@matfyz.cz
Subject: [RFC PATCH 1/2] complete absolute paths for mpc add
Date: Fri, 27 Sep 2024 18:31:34 +0200	[thread overview]
Message-ID: <20240927163300.25833-1-balejk@matfyz.cz> (raw)

When connecting via Unix socket, mpc can queue files from outside the
music directory as well when given the absolute path.
---
mpc also supports explicitly prefixing the path with file:// which is
not covered here, however according to my testing this only works for
absolute paths too so there doesn't seem to be any benefit.

This implementation doesn't work with environment variables, such as
mpc add $HOME/somethi<tab>, I will appreciate tips on whether there is a
simple way to make this more robust to include situations such as this
instead of just checking for these two specific starting characters.

Thank you and kind regards,
K. B.

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

diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc
index c3f93878ca28..93100de09ca8 100644
--- a/Completion/Unix/Command/_mpc
+++ b/Completion/Unix/Command/_mpc
@@ -178,6 +178,14 @@ _mpc_helper_files() {
   fi
 }
 
+(( $+functions[_mpc_helper_all_files] )) ||
+_mpc_helper_all_files() {
+  if [[ $words[CURRENT] == [/~]* ]]; then
+	  _files
+  fi
+  _mpc_helper_files
+}
+
 (( $+functions[_mpc_helper_directories] )) ||
 _mpc_helper_directories() {
   if [[ -n $MPD_MUSIC_DIR ]]; then
@@ -204,7 +212,7 @@ _mpc_helper_outputs() {
 }
 
 _mpc_add() {
-  _mpc_helper_files
+  _mpc_helper_all_files
 }
 
 _mpc_albumart() {
-- 
2.46.0



             reply	other threads:[~2024-09-27 16:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27 16:31 Karel Balej [this message]
2024-09-27 16:31 ` [RFC PATCH 2/2] enable completion for mpc insert Karel Balej
2024-11-09 15:21 ` [RFC PATCH 1/2] complete absolute paths for mpc add Karel Balej
2024-11-09 19:44 ` Bart Schaefer
2024-11-10 18:56   ` Karel Balej
2024-11-10 23:10     ` Bart Schaefer
2024-11-11 19:26       ` Karel Balej
2024-11-12  2:52         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240927163300.25833-1-balejk@matfyz.cz \
    --to=balejk@matfyz.cz \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).