Skip to content

Commit

Permalink
install: add --with-zshcompletiondir configure opt
Browse files Browse the repository at this point in the history
Add the --with-zshcompletiondir option to the configure installation
script to define a particular installation directory for the zsh
completion script.

If option is not defined, zsh completion script is installed by default
in initdir and the FPATH environment variable is set in zsh init script.
If option is set, completion script is installed in designated directory
and zsh init script does not set the FPATH environment variable.

Fixes #428
  • Loading branch information
xdelaruelle committed Nov 24, 2021
1 parent 0d18362 commit b483dbf
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Makefile.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ variantshortcut := @variantshortcut@
# editor
editor := @editor@

# shell completion location
zshcompletiondir := @zshcompletiondir@

# command location
TCLSH := @TCLSH@
PYTHON := @PYTHON@
Expand Down
7 changes: 6 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ darkbgcolors lightbgcolors termbg lockedconfigs icase unloadmatchorder \
searchmatch modulepath loadedmodules quarantinevars wa277 advversspec ml \
windowssupport nearlyforbiddendays implicitrequirement tagabbrev \
tagcolorname mcookieversioncheck availoutput availterseoutput listoutput \
listterseoutput editor variantshortcut"
listterseoutput editor variantshortcut zshcompletiondir"
libarglist=

# flags to know if argument has been specified on command-line
Expand Down Expand Up @@ -123,6 +123,7 @@ listoutput='header:idx:variant:sym:tag:key'
listterseoutput='header'
editor='vi'
variantshortcut=
zshcompletiondir=


# check if output/error channels are attached to terminal
Expand Down Expand Up @@ -408,6 +409,8 @@ Optional Packages:
--with-tclinclude directory containing the Tcl header files.
--with-python=BIN name or full path of Python interpreter command to
use as shebang for helper scripts [$PYTHON]
--with-zshcompletiondir=DIR
Zsh completions directory []
Depending on the above configuration options the files are approximately
placed in the following directory structure:
Expand Down Expand Up @@ -756,6 +759,8 @@ for arg in "$@"; do
loadedmodules=$(get_package_value "$arg") ;;
--with-quarantine-vars=*|--without-quarantine-vars)
quarantinevars=$(get_package_value "$arg") ;;
--with-zshcompletiondir=*|--without-zshcompletiondir)
zshcompletiondir=$(get_package_value "$arg" "") ;;
--with-tcl=*|--without-tcl|--with-tclinclude=*|--without-tclinclude)
libarglist+="$arg " ;;
--with-python=*|--without-python)
Expand Down
17 changes: 13 additions & 4 deletions init/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ else
initrc := $(initdir)/modulerc
endif

# define shell completion location
ifeq ($(zshcompletiondir),)
zshcompletiondir := $(initdir)/zsh-functions
setzshfpathre := s|@setzshfpath@||g
else
setzshfpathre := /@setzshfpath@/d
endif

# if enabled translate to keep text after markup elsewhere remove the
# entire line
ifeq ($(setmanpath),y)
Expand Down Expand Up @@ -178,6 +186,7 @@ sed -e 's|@prefix@|$(prefix)|g' \
-e '$(prependbinpathre)' \
-e '$(usemanpathre)' \
-e '$(notusemanpathre)' \
-e '$(setzshfpathre)' \
-e $$'s|@modulerc@|$(modulerc)|g' \
-e 's|@modulepath@|$(modulepath)|g' \
-e '$(setquarvarsre)' $(quarvarsre) \
Expand Down Expand Up @@ -243,14 +252,14 @@ uninstall-testconfig:
install: all
mkdir -p $(DESTDIR)$(initdir)
mkdir -p $(DESTDIR)$(initdir)/ksh-functions
mkdir -p $(DESTDIR)$(initdir)/zsh-functions
mkdir -p $(DESTDIR)$(zshcompletiondir)
mkdir -p $(DESTDIR)$(modulefilesdir)
cp $(ALL_SHELLS) $(DESTDIR)$(initdir)/
ifeq ($(windowssupport),y)
cp cmd.cmd $(DESTDIR)$(initdir)/
endif
cp fish_completion $(DESTDIR)$(initdir)/
cp zsh-functions/_module $(DESTDIR)$(initdir)/zsh-functions/
cp zsh-functions/_module $(DESTDIR)$(zshcompletiondir)/
cp ksh $(DESTDIR)$(initdir)/ksh-functions/module
cp ksh $(DESTDIR)$(initdir)/ksh-functions/ml
rm -f $(DESTDIR)$(modulespath) $(DESTDIR)$(initrc)
Expand All @@ -273,12 +282,12 @@ ifeq ($(windowssupport),y)
endif
rm -f $(DESTDIR)$(initdir)/ksh-functions/module
rm -f $(DESTDIR)$(initdir)/ksh-functions/ml
rm -f $(DESTDIR)$(initdir)/zsh-functions/_module
rm -f $(DESTDIR)$(zshcompletiondir)/_module
rm -f $(DESTDIR)$(modulespath) $(DESTDIR)$(initrc)
$(RMDIR_IGN_NON_EMPTY) $(DESTDIR)$(modulefilesdir) || true
@if [ -d $(DESTDIR)$(modulefilesdir) ]; then echo; echo "WARNING: $(DESTDIR)$(modulefilesdir) is not empty so skip removal" >&2; echo; fi
rmdir $(DESTDIR)$(initdir)/ksh-functions
rmdir $(DESTDIR)$(initdir)/zsh-functions
$(RMDIR_IGN_NON_EMPTY) $(DESTDIR)$(zshcompletiondir) || true
$(RMDIR_IGN_NON_EMPTY) $(DESTDIR)$(initdir) || true
@if [ -d $(DESTDIR)$(initdir) ]; then echo; echo "WARNING: $(DESTDIR)$(initdir) is not empty so skip removal" >&2; echo; fi
ifeq ($(versioning),y)
Expand Down
12 changes: 6 additions & 6 deletions init/zsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ unset _mlre _mlv _mlrv
# no environment alteration if the above autoinit command failed
if [ $_mlret -eq 0 ]; then
eval "$_mlcode"

# setup FPATH to put module completion at hand in case zsh completion enabled
if [[ ! ":$FPATH:" =~ ':@initdir@/zsh-functions:' ]]; then
FPATH=@initdir@/zsh-functions${FPATH:+:}$FPATH
export FPATH
fi
@setzshfpath@
@setzshfpath@ # setup FPATH to put module completion at hand in case zsh completion enabled
@setzshfpath@ if [[ ! ":$FPATH:" =~ ':@initdir@/zsh-functions:' ]]; then
@setzshfpath@ FPATH=@initdir@/zsh-functions${FPATH:+:}$FPATH
@setzshfpath@ export FPATH
@setzshfpath@ fi
@setbinpath@
@setbinpath@ if [[ ! ":$PATH:" =~ ':@bindir@:' ]]; then
@setbinpath@@prependbinpath@ PATH=@bindir@${PATH:+:}$PATH
Expand Down
2 changes: 2 additions & 0 deletions site.exp.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ set install_variantshortcut "@variantshortcut@"

set install_editor "@editor@"

set install_zshcompletiondir "@zshcompletiondir@"

# command location
set install_tclsh "@TCLSH@"
set install_python "@PYTHON@"

0 comments on commit b483dbf

Please sign in to comment.