Skip to content

Instantly share code, notes, and snippets.

@fipar
Created April 29, 2020 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fipar/618f12c996dd87d876d14f858254d9f2 to your computer and use it in GitHub Desktop.
Save fipar/618f12c996dd87d876d14f858254d9f2 to your computer and use it in GitHub Desktop.
Generate a pdf documenting my hyper and F keys emacs shortcuts
#!/bin/bash
target=hyper-shortcuts.tex
cat <<EOF>$target
\documentclass{article}
\pagestyle{empty}
\usepackage{longtable} % Because our table will spawn more than one page
\usepackage[dvipsnames]{xcolor} % To use commands like \textcolor{red}{]}
\title{Emacs Hyper and F key shortcuts}
\begin{document}
\maketitle
\begin{longtable}{ c c }
EOF
cat<<EOF>sedscr.$$
s/.*H-//g
s/")//
s/)$//g
s/ '/|/g
s/ (/|(/
EOF
grep 'global-set-key (kbd "H-' emacs_init_stage_0.el|grep -v '^ *;' | \
sed -f sedscr.$$ | while read l; do
key=$(echo $l|awk -F'|' '{print $1}'|sed 's/\\/\\textbackslash/'|sed 's/]/\\textcolor{red}{]}/'|sed 's/\[/\\textcolor{ForestGreen}{\[}/')
target=$(echo $l|awk -F'|' '{print $2}')
third_arg=$(echo $l|awk -F'|' '{print $3}')
[ -n "$third_arg" ] && target=$target$third_arg
echo $target|grep '(kbd'>/dev/null && {
target=$(echo $target|sed 's/;;*/;/g'|awk -F';' '{print $2}')
}
echo "\textbf{$key} & $target \\\\"
done>>$target
rm -f sedscr.$$
grep 'global-set-key \[f' emacs_init_stage_0.el|grep -v '^ *;' | sed 's/(global-set-key \[//'|tr -d "')" | while read l; do
key=$(echo $l|awk -F] '{print $1}'|sed 's/f/\\textcolor{blue}{f}/')
target=$(echo $l|awk -F] '{print $2}')
echo "\textbf{$key} & $target \\\\"
done>>$target
cat <<EOF>>$target
\end{longtable}
\end{document}
EOF
texi2pdf $target
auxn=$(echo $target|awk -F. '{print $1}')
rm -f ${auxn}.tex ${auxn}.log ${auxn}.aux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment