Skip to content

Commit

Permalink
Merge remote-tracking branch 'lenormf/rc-misc-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
mawww committed May 19, 2017
2 parents 5753be5 + d59bafa commit 55d1d10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion rc/base/x11.kak
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ decl str termcmd %sh{
'gnome-terminal -e ' \
'xfce4-terminal -e ' ; do
terminal=${termcmd%% *}
if which $terminal > /dev/null 2>&1; then
if command -v $terminal >/dev/null 2>&1; then
printf %s\\n "'$termcmd'"
exit
fi
Expand Down
29 changes: 15 additions & 14 deletions rc/core/c-family.kak
Original file line number Diff line number Diff line change
Expand Up @@ -283,40 +283,41 @@ def -hidden c-family-insert-include-guards %{

hook global BufNewFile .*\.(h|hh|hpp|hxx|H) c-family-insert-include-guards

decl str-list alt_dirs ".;.."
decl str-list alt_dirs ".:.."

def c-family-alternative-file -docstring "Jump to the alternate file (header/implementation)" %{ %sh{
alt_dirs=$(printf %s\\n "${kak_opt_alt_dirs}" | sed -e 's/;/ /g')
file=$(basename "${kak_buffile}")
alt_dirs=$(printf %s\\n "${kak_opt_alt_dirs}" | tr ':' '\n')
file="${kak_buffile##*/}"
file_noext="${file%.*}"
dir=$(dirname "${kak_buffile}")
case ${file} in
*.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m)
for alt_dir in ${alt_dirs}; do
for ext in h hh hpp hxx H; do
altname="${dir}/${alt_dir}/${file%.*}.${ext}"
[ -f ${altname} ] && break
altname="${dir}/${alt_dir}/${file_noext}.${ext}"
if [ -f ${altname} ]; then
printf 'edit %%{%s}\n' "${altname}"
exit
fi
done
[ -f ${altname} ] && break
done
;;
*.h|*.hh|*.hpp|*.hxx|*.H)
for alt_dir in ${alt_dirs}; do
for ext in c cc cpp cxx C m; do
altname="${dir}/${alt_dir}/${file%.*}.${ext}"
[ -f ${altname} ] && break
altname="${dir}/${alt_dir}/${file_noext}.${ext}"
if [ -f ${altname} ]; then
printf 'edit %%{%s}\n' "${altname}"
exit
fi
done
[ -f ${altname} ] && break
done
;;
*)
echo "echo -color Error 'extension not recognized'"
exit
;;
esac
if [ -f ${altname} ]; then
printf %s\\n "edit '${altname}'"
else
echo "echo -color Error 'alternative file not found'"
fi
echo "echo -color Error 'alternative file not found'"
}}
13 changes: 2 additions & 11 deletions share/kak/kakrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,8 @@ def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \

%sh{
autoload_directory() {
dir=$1
for rcfile in ${dir}/*.kak; do
if [ -f "$rcfile" ]; then
echo "try %{ source '${rcfile}' } catch %{ echo -debug Autoload: could not load '${rcfile}' }";
fi
done
for subdir in ${dir}/*; do
if [ -d "$subdir" ]; then
autoload_directory $subdir
fi
done
find -L "$1" -type f -name '*\.kak' \
-exec printf 'try %%{ source "%s" } catch %%{ echo -debug Autoload: could not load "%s" }\n' '{}' '{}' \;
}
localconfdir=${XDG_CONFIG_HOME:-${HOME}/.config}/kak
Expand Down

0 comments on commit 55d1d10

Please sign in to comment.