shithub: choc

Download patch

ref: 7f4e1ae12414c0a753052df59270f9a867f0766e
parent: 9a257cdf78ee4fa7d3de5bbb5be3ca733b06077f
author: Mike Swanson <[email protected]>
date: Sun Mar 5 13:43:22 EST 2017

bash-completion: Use autoconf substitutions for the chocolate name

Introduce a new PROGRAM_SPREFIX variable in configure.ac, which is
basically identical to PROGRAM_PREFIX but without the trailing hyphen.
PROGRAM_PREFIX was also redefined so that it bases its name from
PACKAGE_SHORTNAME, reducing the number of hardcoded chocolates in the
source.

--- a/configure.ac
+++ b/configure.ac
@@ -141,15 +141,15 @@
 
 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.
+PROGRAM_PREFIX=${PACKAGE_SHORTNAME,}-
 
-PROGRAM_PREFIX=chocolate-
+dnl Without a hyphen. This is used for the bash-completion scripts.
+PROGRAM_SPREFIX=${PACKAGE_SHORTNAME,}
 
 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 +179,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