#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/emacs etags-update () { etags -R --exclude='*.txt' --languages=EmacsLisp ~/.emacs.d ~/src/emacs } alias etu=etags-update byte-compile () { emacs -Q --batch --eval '(push "." load-path)' -f batch-byte-compile $@ } emacs-age () { time-from 1985-03-20 } all-defuns () { awk '/\(defun /{print $2}' **/*.el | sort -u } clp () { cd ~/src/emacs local re='pcase|pcase-[a-z0-9*]+' grep -E -h -o -w $re **/*.el | sort | uniq -c | sort -b -n -r echo 'Total:' $(grep -E -h -o -w $re **/*.el | wc -l) } elpa () { cd ~/elpa local re='Maintainer: .*' grep -E -h -o -w $re **/* | sort | uniq -c | sort -b -n -r | tr -s " " | cut -d ' ' -f 2,4- } elint () { local fs=($@) local elpa=~/.emacs.d/elpa local elint=${elpa}/elisp-lint-20220419.252/elisp-lint.el emacs -Q \ --batch \ --eval "(push \"$elpa/compat-29.1.4.2\" load-path)" \ --eval "(push \"$elpa/dash-20230714.723\" load-path)" \ --eval "(push \"$elpa/package-lint-20231103.1810\" load-path)" \ -l $elint \ -f elisp-lint-files-batch \ --no-byte-compile \ --no-check-declare \ --no-checkdoc \ --no-indent \ --no-indent-character \ --no-package-lint \ $fs } elisp-sloc () { local dir=~/.emacs.d/emacs-init local files=$(ls -1 $dir/**/*.el | wc -l) local sloc=$(wc -l $dir/**/*.el | awk 'END { print $1 }') local cmts=$(grep -h -o '^;; ' $dir/**/*.el | wc -l) local packs=$(grep -h -o '(require .*)' $dir/**/*.el | wc -l) local packs_u=$(grep -h -o '(require .*)' $dir/**/*.el | sort -u | wc -l) local ppf=$(( 1.0 * $packs / $files)) echo " files: $files" echo " SLoC: $sloc" echo " comments: $cmts" echo "packages required: $packs" printf " - per file: %.2f\n" $ppf echo " unique packages: $packs_u" }