shithub: choc

Download patch

ref: fb7a43cb4d183137ca6107a9bd65f528bd775990
parent: 9a257cdf78ee4fa7d3de5bbb5be3ca733b06077f
parent: bc87379f59c957ebc1b88fce2516433d8bc3e3a2
author: Jonathan Dowland <jon+github@alcopop.org>
date: Fri Mar 17 18:21:06 EDT 2017

Merge pull request #879 from chungy/autoconf_bashcompletion

bash-completion: Use autoconf substitutions for the chocolate name

--- a/configure.ac
+++ b/configure.ac
@@ -141,15 +141,16 @@
 
 WINDOWS_RC_VERSION=`echo $PACKAGE_VERSION | sed 's/-.*//; s/\./, /g; s/$/, 0/'`
 
-# This controls the prefix added to the start of program names.  For example,
-# if this is changed to "lemon-", the programs generated will be named
-# lemon-doom, lemon-heretic, etc.
+dnl Without a hyphen. This is used for the bash-completion scripts.
+PROGRAM_SPREFIX=$(echo $PACKAGE_SHORTNAME | tr A-Z a-z)
 
-PROGRAM_PREFIX=chocolate-
+dnl With a hyphen, used almost everywhere else.
+PROGRAM_PREFIX=${PROGRAM_SPREFIX}-
 
 AC_SUBST(PROGRAM_PREFIX)
 AC_DEFINE_UNQUOTED(PROGRAM_PREFIX, "$PROGRAM_PREFIX",
                    Change this when you create your awesome forked version)
+AC_SUBST(PROGRAM_SPREFIX)
 
 AM_CONFIG_HEADER(config.h:config.hin)
 
@@ -179,6 +180,10 @@
 Makefile
 man/Makefile
 man/bash-completion/Makefile
+man/bash-completion/doom.template
+man/bash-completion/heretic.template
+man/bash-completion/hexen.template
+man/bash-completion/strife.template
 opl/Makefile
 opl/examples/Makefile
 pcsound/Makefile
--- a/man/bash-completion/.gitignore
+++ b/man/bash-completion/.gitignore
@@ -2,3 +2,4 @@
 *heretic
 *hexen
 *strife
+*.template
--- a/man/bash-completion/doom.template
+++ /dev/null
@@ -1,51 +1,0 @@
-# bash completion for Chocolate Doom                       -*- shell-script -*-
-
-_chocolate_doom()
-{
-    local cur prev words cword
-    _init_completion || return
-
-    # Save the previous switch on the command line in the prevsw variable
-    local i prevsw=""
-    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
-        if [[ ${words[i]} == -* ]]; then
-            prevsw=${words[i]}
-        fi
-    done
-
-    # Allow adding more than one file with the same extension to the same switch
-    case $prevsw in
-        -config|-extraconfig)
-            _filedir cfg
-            ;;
-        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
-            _filedir wad
-            ;;
-        -playdemo|-timedemo)
-            _filedir lmp
-            ;;
-        -deh)
-            _filedir '@(bex|deh)'
-            ;;
-    esac
-
-    case $prev in
-        -pack)
-            COMPREPLY=(doom2 tnt plutonia)
-            ;;
-        -gameversion)
-            COMPREPLY=(1.9 ultimate final final2 hacx chex)
-            ;;
-        -setmem)
-            COMPREPLY=(dos622 dos71 dosbox)
-            ;;
-    esac
-
-    if [[ $cur == -* ]]; then
-        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
-    fi
-} &&
-
-complete -F _chocolate_doom chocolate-doom
-
-# ex: ts=4 sw=4 et filetype=sh
--- /dev/null
+++ b/man/bash-completion/doom.template.in
@@ -1,0 +1,51 @@
+# bash completion for @PACKAGE_SHORTNAME@ Doom               -*- shell-script -*-
+
+_@PROGRAM_SPREFIX@_doom()
+{
+    local cur prev words cword
+    _init_completion || return
+
+    # Save the previous switch on the command line in the prevsw variable
+    local i prevsw=""
+    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
+        if [[ ${words[i]} == -* ]]; then
+            prevsw=${words[i]}
+        fi
+    done
+
+    # Allow adding more than one file with the same extension to the same switch
+    case $prevsw in
+        -config|-extraconfig)
+            _filedir cfg
+            ;;
+        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
+            _filedir wad
+            ;;
+        -playdemo|-timedemo)
+            _filedir lmp
+            ;;
+        -deh)
+            _filedir '@(bex|deh)'
+            ;;
+    esac
+
+    case $prev in
+        -pack)
+            COMPREPLY=(doom2 tnt plutonia)
+            ;;
+        -gameversion)
+            COMPREPLY=(1.9 ultimate final final2 hacx chex)
+            ;;
+        -setmem)
+            COMPREPLY=(dos622 dos71 dosbox)
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
+    fi
+} &&
+
+complete -F _@PROGRAM_SPREFIX@_doom @PROGRAM_PREFIX@doom
+
+# ex: ts=4 sw=4 et filetype=sh
--- a/man/bash-completion/heretic.template
+++ /dev/null
@@ -1,48 +1,0 @@
-# bash completion for Chocolate Heretic                    -*- shell-script -*-
-
-_chocolate_heretic()
-{
-    local cur prev words cword
-    _init_completion || return
-
-    # Save the previous switch on the command line in the prevsw variable
-    local i prevsw=""
-    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
-        if [[ ${words[i]} == -* ]]; then
-            prevsw=${words[i]}
-        fi
-    done
-
-    # Allow adding more than one file with the same extension to the same switch
-    case $prevsw in
-        -config|-extraconfig)
-            _filedir cfg
-            ;;
-        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
-            _filedir wad
-            ;;
-        -playdemo|-timedemo)
-            _filedir lmp
-            ;;
-        -deh)
-            _filedir hhe
-            ;;
-    esac
-
-    case $prev in
-        -hhever)
-            COMPREPLY=(1.0 1.2 1.3)
-            ;;
-        -setmem)
-            COMPREPLY=(dos622 dos71 dosbox)
-            ;;
-    esac
-
-    if [[ $cur == -* ]]; then
-        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
-    fi
-} &&
-
-complete -F _chocolate_heretic chocolate-heretic
-
-# ex: ts=4 sw=4 et filetype=sh
--- /dev/null
+++ b/man/bash-completion/heretic.template.in
@@ -1,0 +1,48 @@
+# bash completion for @PACKAGE_SHORTNAME@ Heretic            -*- shell-script -*-
+
+_@PROGRAM_SPREFIX@_heretic()
+{
+    local cur prev words cword
+    _init_completion || return
+
+    # Save the previous switch on the command line in the prevsw variable
+    local i prevsw=""
+    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
+        if [[ ${words[i]} == -* ]]; then
+            prevsw=${words[i]}
+        fi
+    done
+
+    # Allow adding more than one file with the same extension to the same switch
+    case $prevsw in
+        -config|-extraconfig)
+            _filedir cfg
+            ;;
+        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
+            _filedir wad
+            ;;
+        -playdemo|-timedemo)
+            _filedir lmp
+            ;;
+        -deh)
+            _filedir hhe
+            ;;
+    esac
+
+    case $prev in
+        -hhever)
+            COMPREPLY=(1.0 1.2 1.3)
+            ;;
+        -setmem)
+            COMPREPLY=(dos622 dos71 dosbox)
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
+    fi
+} &&
+
+complete -F _@PROGRAM_SPREFIX@_heretic @PROGRAM_PREFIX@heretic
+
+# ex: ts=4 sw=4 et filetype=sh
--- a/man/bash-completion/hexen.template
+++ /dev/null
@@ -1,42 +1,0 @@
-# bash completion for Chocolate Hexen                     -*- shell-script -*-
-
-_chocolate_hexen()
-{
-    local cur prev words cword
-    _init_completion || return
-
-    # Save the previous switch on the command line in the prevsw variable
-    local i prevsw=""
-    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
-        if [[ ${words[i]} == -* ]]; then
-            prevsw=${words[i]}
-        fi
-    done
-
-    # Allow adding more than one file with the same extension to the same switch
-    case $prevsw in
-        -config|-extraconfig)
-            _filedir cfg
-            ;;
-        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
-            _filedir wad
-            ;;
-        -playdemo|-timedemo)
-            _filedir lmp
-            ;;
-    esac
-
-    case $prev in
-        -setmem)
-            COMPREPLY=(dos622 dos71 dosbox)
-            ;;
-    esac
-
-    if [[ $cur == -* ]]; then
-        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
-    fi
-} &&
-
-complete -F _chocolate_hexen chocolate-hexen
-
-# ex: ts=4 sw=4 et filetype=sh
--- /dev/null
+++ b/man/bash-completion/hexen.template.in
@@ -1,0 +1,42 @@
+# bash completion for @PACKAGE_SHORTNAME@ Hexen              -*- shell-script -*-
+
+_@PROGRAM_SPREFIX@_hexen()
+{
+    local cur prev words cword
+    _init_completion || return
+
+    # Save the previous switch on the command line in the prevsw variable
+    local i prevsw=""
+    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
+        if [[ ${words[i]} == -* ]]; then
+            prevsw=${words[i]}
+        fi
+    done
+
+    # Allow adding more than one file with the same extension to the same switch
+    case $prevsw in
+        -config|-extraconfig)
+            _filedir cfg
+            ;;
+        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
+            _filedir wad
+            ;;
+        -playdemo|-timedemo)
+            _filedir lmp
+            ;;
+    esac
+
+    case $prev in
+        -setmem)
+            COMPREPLY=(dos622 dos71 dosbox)
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
+    fi
+} &&
+
+complete -F _@PROGRAM_SPREFIX@_hexen @PROGRAM_PREFIX@hexen
+
+# ex: ts=4 sw=4 et filetype=sh
--- a/man/bash-completion/strife.template
+++ /dev/null
@@ -1,48 +1,0 @@
-# bash completion for Chocolate Strife                     -*- shell-script -*-
-
-_chocolate_strife()
-{
-    local cur prev words cword
-    _init_completion || return
-
-    # Save the previous switch on the command line in the prevsw variable
-    local i prevsw=""
-    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
-        if [[ ${words[i]} == -* ]]; then
-            prevsw=${words[i]}
-        fi
-    done
-
-    # Allow adding more than one file with the same extension to the same switch
-    case $prevsw in
-        -config|-extraconfig)
-            _filedir cfg
-            ;;
-        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
-            _filedir wad
-            ;;
-        -playdemo|-timedemo)
-            _filedir lmp
-            ;;
-        -deh)
-            _filedir seh
-            ;;
-    esac
-
-    case $prev in
-        -gameversion)
-            COMPREPLY=(1.2 1.31)
-            ;;
-        -setmem)
-            COMPREPLY=(dos622 dos71 dosbox)
-            ;;
-    esac
-
-    if [[ $cur == -* ]]; then
-        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
-    fi
-} &&
-
-complete -F _chocolate_strife chocolate-strife
-
-# ex: ts=4 sw=4 et filetype=sh
--- /dev/null
+++ b/man/bash-completion/strife.template.in
@@ -1,0 +1,48 @@
+# bash completion for @PACKAGE_SHORTNAME@ Strife             -*- shell-script -*-
+
+_@PROGRAM_SPREFIX@_strife()
+{
+    local cur prev words cword
+    _init_completion || return
+
+    # Save the previous switch on the command line in the prevsw variable
+    local i prevsw=""
+    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
+        if [[ ${words[i]} == -* ]]; then
+            prevsw=${words[i]}
+        fi
+    done
+
+    # Allow adding more than one file with the same extension to the same switch
+    case $prevsw in
+        -config|-extraconfig)
+            _filedir cfg
+            ;;
+        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
+            _filedir wad
+            ;;
+        -playdemo|-timedemo)
+            _filedir lmp
+            ;;
+        -deh)
+            _filedir seh
+            ;;
+    esac
+
+    case $prev in
+        -gameversion)
+            COMPREPLY=(1.2 1.31)
+            ;;
+        -setmem)
+            COMPREPLY=(dos622 dos71 dosbox)
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '@content' -- "$cur" ) )
+    fi
+} &&
+
+complete -F _@PROGRAM_SPREFIX@_strife @PROGRAM_PREFIX@strife
+
+# ex: ts=4 sw=4 et filetype=sh