aboutsummaryrefslogtreecommitdiffstats
path: root/emacs/.emacs.d/scripts/find-php-class
diff options
context:
space:
mode:
authorGravatar Tom Willemse2026-09-17 10:03:35 -0700
committerGravatar Tom Willemse2026-09-17 10:03:35 -0700
commit5d77c407db4c5abfce6c83d4618f4b2389e18fe2 (patch)
treeafa7cc957ee2e48ea99e368030422a2e028ba17a /emacs/.emacs.d/scripts/find-php-class
parent8c27a31fd9e67f198c8867380ba38ad33775f0c5 (diff)
downloadnew-dotfiles-5d77c407db4c5abfce6c83d4618f4b2389e18fe2.tar.gz
new-dotfiles-5d77c407db4c5abfce6c83d4618f4b2389e18fe2.zip
emacs: Copy PHP configuration
Diffstat (limited to 'emacs/.emacs.d/scripts/find-php-class')
-rwxr-xr-xemacs/.emacs.d/scripts/find-php-class74
1 files changed, 29 insertions, 45 deletions
diff --git a/emacs/.emacs.d/scripts/find-php-class b/emacs/.emacs.d/scripts/find-php-class
index 4268dcf..3564f00 100755
--- a/emacs/.emacs.d/scripts/find-php-class
+++ b/emacs/.emacs.d/scripts/find-php-class
@@ -1,48 +1,32 @@
-#!/usr/bin/env bash
-# ;; #!/usr/bin/env -S scsh -e main -o srfi-1 -s
-# ;; !#
+#!/usr/bin/env -S scsh -e main -o srfi-1 -s
+;; -*- mode: scheme; -*-
+!#
-# ;; (define (main args)
-# ;; (let* ((class-name (cadr args))
-# ;; (file-names
-# ;; (run/strings (find "."
-# ;; -path "./cdk.out" -prune -o
-# ;; -type f
-# ;; -name ,(string-append class-name ".php")
-# ;; -exec grep "^namespace" "{}" ";")
-# ;; (> 2 "/dev/null"))))
-# ;; (format #t "~s"
-# ;; (delete-duplicates
-# ;; (map (lambda (n)
-# ;; (string-append
-# ;; (match:substring
-# ;; (regexp-search (rx "namespace " (submatch (+ any)) ";") n)
-# ;; 1)
-# ;; "\\"
-# ;; class-name))
-# ;; file-names)))))
+(define (find-class class-name)
+ (run/strings (find "." "("
+ -path "./cdk.out"
+ -o -path "./*/tmp"
+ -o -path "./*/node_modules"
+ -o -path "./*/.phpunit.cache"
+ -o -path "./*/storage"
+ -o -path "./.git"
+ -o -path "./data"
+ ")" -prune
+ -o -type f -name ,(string-append class-name ".php")
+ -exec grep "^namespace" "{}" ";")
+ (> 2 "/dev/null")))
-main() {
- local classname=$1
- find . \( \
- -path "./cdk.out" \
- -o -path "./punt/tmp" \
- -o -path "./punt/vendor" \
- -o -path "./filament/storage/larastan/cache" \
- -o -path "./filament/vendor" \
- -o -path "./chanced/tmp" \
- -o -path "./chanced/node_modules" \
- -o -path "./chanced/.phpunit.cache" \
- -o -path "./.git" \
- -o -path "./chanced/storage" \
- \) -prune \
- -o -type f -name "${classname}.php" \
- -exec grep '^namespace' '{}' \; \
- | awk "{ print substr(\$0, 11, length(\$0) - 11) \"\\\\${classname}\" }"
- # for f in "$(git ls-files | grep "${classname}.php")"; do
- # grep '^namespace' "$f" | awk '{ print substr($0, 11, length($0) - 11) }'
- # done
-}
-
-main "$@"
+(define (main args)
+ (let* ((class-name (cadr args))
+ (file-names (find-class class-name)))
+ (format #t "~s"
+ (delete-duplicates
+ (map (lambda (n)
+ (string-append
+ (match:substring
+ (regexp-search (rx "namespace " (submatch (+ any)) ";") n)
+ 1)
+ "\\"
+ class-name))
+ file-names)))))