Subject: [bug#30495] [PATCH] bash completion: Complete files names after 'guix package -m'.

From: Oleg Pykhalov <[email-masked]>
Date: Sat, 17 Feb 2018 19:03:11 +0300

Marius Bakke <[email-masked]> writes:

> Oleg Pykhalov <[email-masked]> writes:
>
>> * etc/completion/bash/guix (_guix_is_dash_L): Replace with
>> ‘_guix_is_dash_L_or_m’.
>> (_guix_complete): Add this.
>
> [...]
>
>> diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
>> index 6b84193db..286c4f1c5 100644
>> --- a/etc/completion/bash/guix
>> +++ b/etc/completion/bash/guix
>> @@ -97,9 +97,10 @@ _guix_is_removing ()
>>      $result
>>  }
>>  
>> -_guix_is_dash_L ()
>> +_guix_is_dash_L_or_m ()
>>  {
>> -    [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-L" ] \
>> +    comp_words_minus_1="${COMP_WORDS[$COMP_CWORD - 1]}"
>> +    [ "$comp_words_minus_1" = "-L" ] || [ "$comp_words_minus_1" = "-m" ] \
>>  	|| { case "${COMP_WORDS[$COMP_CWORD]}" in
>>  		 --load-path=*) true;;
>>  		 *)             false;;
>
> I think this fails to account for the long form "--manifest".  Perhaps
> it's better to add a new "_guix_is_dash_m" and use
>
> "if _guix_is_dash_L || _guix_is_dash_m"
>
> below.  WDYT?

Nice catch!  Thanks.

But I don't know how to implement a file completion for ‘--manifest=’.
‘--load-path=’ doesn't have a file completion too.  Only completion for
equal sign before.

Oleg.

From b6d104ec1b3df46a409c989bf12e19c30a920c00 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <[email-masked]>
Date: Sat, 17 Feb 2018 12:05:26 +0300
Subject: [PATCH] bash completion: Complete files names after 'guix package
 -m'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* etc/completion/bash/guix (_guix_is_dash_L): Replace with
‘_guix_is_dash_L_or_m’.
(_guix_complete): Add this.
---
 etc/completion/bash/guix | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
index 6b84193db..70430c5c9 100644
--- a/etc/completion/bash/guix
+++ b/etc/completion/bash/guix
@@ -106,6 +106,15 @@ _guix_is_dash_L ()
 	     esac }
 }
 
+_guix_is_dash_m ()
+{
+    [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-m" ] \
+	|| { case "${COMP_WORDS[$COMP_CWORD]}" in
+		 --manifest=*) true;;
+		 *)            false;;
+	     esac }
+}
+
 _guix_complete_file ()
 {
     # Let Readline complete file names.
@@ -149,7 +158,7 @@ _guix_complete ()
 	*)
 	    if _guix_is_command "package"
 	    then
-		if _guix_is_dash_L
+		if _guix_is_dash_L || _guix_is_dash_m
 		then
 		    _guix_complete_file
 		elif _guix_is_removing
-- 
2.16.1