zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] completion: Unison uses the $UNISON variable
@ 2020-03-29  4:15 Henri Menke
  2020-03-29 20:29 ` Daniel Shahaf
  0 siblings, 1 reply; 2+ messages in thread
From: Henri Menke @ 2020-03-29  4:15 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

Dear zsh maintainers,

Please find attached my improvement for the Unison completion file.
Details as to why this patch is necessary are in the commit message.

If you need clarification or want me to improve the patch, please reply
to me directly, as I am not subscribed to the list.

Kind regards,
Henri


[-- Attachment #2: 0001-completion-Unison-uses-the-UNISON-variable.patch --]
[-- Type: text/plain, Size: 1335 bytes --]

From ba2b421f957a42378ac180827c07a27d0946630a Mon Sep 17 00:00:00 2001
From: Henri Menke <henri@icp.uni-stuttgart.de>
Date: Sun, 29 Mar 2020 17:07:31 +1300
Subject: [PATCH] completion: Unison uses the $UNISON variable

By default Unison uses the ~/.unison directory to store its cache and
profiles.  However, this location is configurable through the $UNISON
environment variable.  Quoting from the manual [1]:

> If the environment variable UNISON is defined, then its value will be
> used as the name of this directory.

This patch enables users to move the .unison directory and still enjoy
zsh completion for profiles.

[1] https://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#unisondir
---
 Completion/Unix/Command/_unison | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_unison b/Completion/Unix/Command/_unison
index 2a3333742..d8cf7458f 100644
--- a/Completion/Unix/Command/_unison
+++ b/Completion/Unix/Command/_unison
@@ -86,7 +86,7 @@ _arguments \
 if [[ $state == profile ]]; then
     local -a profiles
 
-    profiles=( ~/.unison/*.prf(N) )
+    profiles=( ${UNISON:-~/.unison}/*.prf(N) )
     (( $#profiles )) && \
-	compadd "$@" - ${${profiles#~/.unison/}%.prf}
+	compadd "$@" - ${${profiles#${UNISON:-~/.unison}/}%.prf}
 fi
-- 
2.26.0


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

* Re: [PATCH] completion: Unison uses the $UNISON variable
  2020-03-29  4:15 [PATCH] completion: Unison uses the $UNISON variable Henri Menke
@ 2020-03-29 20:29 ` Daniel Shahaf
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2020-03-29 20:29 UTC (permalink / raw)
  To: Henri Menke; +Cc: zsh-workers

Henri Menke wrote on Sun, 29 Mar 2020 17:15 +1300:
> Please find attached my improvement for the Unison completion file.
> Details as to why this patch is necessary are in the commit message.
> 
> If you need clarification or want me to improve the patch, please reply
> to me directly, as I am not subscribed to the list.

Thanks, applied.

Note that it will honour $UNISON even if that variable isn't exported.

I also have a further tweak:

8<--8<--
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Sun, 29 Mar 2020 20:20:49 +0000
Subject: [PATCH] completion: Simplify Unison completion.  No functional
 change.

---
 Completion/Unix/Command/_unison | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/Completion/Unix/Command/_unison b/Completion/Unix/Command/_unison
index d8cf7458f..5963d66c6 100644
--- a/Completion/Unix/Command/_unison
+++ b/Completion/Unix/Command/_unison
@@ -84,9 +84,6 @@ _arguments \
     '*:profile:->profile'
 
 if [[ $state == profile ]]; then
-    local -a profiles
-
-    profiles=( ${UNISON:-~/.unison}/*.prf(N) )
-    (( $#profiles )) && \
-	compadd "$@" - ${${profiles#${UNISON:-~/.unison}/}%.prf}
+    local -a profiles=( ${UNISON:-~/.unison}/*.prf(N:t:r) )
+    compadd "$@" -a profiles
 fi

(Not trying to golf it, but to improve readability.)

Cheers,

Daniel

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

end of thread, other threads:[~2020-03-29 20:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-29  4:15 [PATCH] completion: Unison uses the $UNISON variable Henri Menke
2020-03-29 20:29 ` Daniel Shahaf

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).