diff options
| author | 2026-06-15 17:04:07 -0700 | |
|---|---|---|
| committer | 2026-06-15 17:04:07 -0700 | |
| commit | a9e3ff34d7fca54ebb1a7f815210ac3659a0440e (patch) | |
| tree | 27e69df59233a43a17ebaf60ed1a5c4e0e7c6ef7 | |
| parent | e1ce86bb94add543880c0f6eeea86fe805e8cd58 (diff) | |
| download | new-dotfiles-a9e3ff34d7fca54ebb1a7f815210ac3659a0440e.tar.gz new-dotfiles-a9e3ff34d7fca54ebb1a7f815210ac3659a0440e.zip | |
oni-php: Add scripts directory
| -rw-r--r-- | GNUmakefile | 8 | ||||
| -rw-r--r-- | emacs/.emacs.d/oni-php.el | 2 | ||||
| -rwxr-xr-x | emacs/.emacs.d/scripts/find-php-class | 48 |
3 files changed, 56 insertions, 2 deletions
diff --git a/GNUmakefile b/GNUmakefile index d6d5225..5d7b856 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -176,7 +176,9 @@ $(HOME)/.ssh/id_ed25519.pub: brew-install: _mbsetupuser/Brewfile brew bundle --quiet --file $^ -before-_mbsetupuser-install: _mbsetupuser/.emacs.d/init.elc +before-_mbsetupuser-install: \ + _mbsetupuser/.emacs.d/init.elc \ + _mbsetupuser/.emacs.d/scripts/find-php-class before-wezterm-install: wezterm/.config/wezterm/wezterm.lua @@ -203,6 +205,10 @@ _mbsetupuser/.emacs.d/init.el: \ mkdir -p $$(dirname $@) cat $^ > $@ +_mbsetupuser/.emacs.d/scripts/%: emacs/.emacs.d/scripts/% + mkdir -p $$(dirname $@) + cp $^ $@ + project-directories: \ $(HOME)/code/personal/ \ $(HOME)/code/diamond-interactive/ \ diff --git a/emacs/.emacs.d/oni-php.el b/emacs/.emacs.d/oni-php.el index 3d87dca..53e3304 100644 --- a/emacs/.emacs.d/oni-php.el +++ b/emacs/.emacs.d/oni-php.el @@ -49,7 +49,7 @@ nil for some reason." "Try to add a use statement for CLASS under point." (interactive (list (thing-at-point 'symbol))) (let* ((default-directory (project-root (project-current))) - (classes (read (shell-command-to-string (concat (expand-file-name "find-php-class" oni-php-scripts-dir) " " class)))) + (classes (string-split (string-trim-right (shell-command-to-string (concat (expand-file-name "find-php-class" oni-php-scripts-dir) " " class))) "\n")) (class (cond ((null classes) (user-error "Class ā%sā not found" class)) diff --git a/emacs/.emacs.d/scripts/find-php-class b/emacs/.emacs.d/scripts/find-php-class new file mode 100755 index 0000000..4268dcf --- /dev/null +++ b/emacs/.emacs.d/scripts/find-php-class @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# ;; #!/usr/bin/env -S scsh -e main -o srfi-1 -s +# ;; !# + +# ;; (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))))) + +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 "$@" |
