;;; -*- lexical-binding: t -*- ;; ;; -------------------------------------------------------------------------------- (require 'luki-lisp) ;; -------------------------------------------------------------------------------- (-> 'll-file-write-to) (-> 'll-search-string) (-> 'll-window) (-> 'simple) ;; -------------------------------------------------------------------------------- (defun shell-command-silent (cmd) (process-file shell-file-name nil nil nil shell-command-switch cmd)) ;; -------------------------------------------------------------------------------- (defun find-command-zsh (&optional cmd) (i) "Find the source for a zsh cmd. This requires an external zsh script to work, see https://dataswamp.org/~incal/conf/.zsh/find-command" (or cmd (setq cmd (get-search-string "zsh"))) (let* ((search-cmd (@f "find-zsh-command %s" cmd)) (file-data-path (getenv "CMD_FILE")) (erase-data-cmd (@f "echo -n > %s" file-data-path))) (shell-command-silent erase-data-cmd) (shell-command-silent search-cmd) (let ((file (file-to-string file-data-path)) (cmd-search-str (@f "%s ()" cmd)) (als-search-str (@f "alias .*%s" cmd)) (case-fold-search nil)) (unless (s= file "") (find-file file) (goto-beg) (when (or (search-forward-regexp cmd-search-str nil 'noerror) (search-forward-regexp als-search-str nil 'noerror)) (beginning-of-line-at-top)))))) ;; -------------------------------------------------------------------------------- (defun find-zsh-command-file-file () (i) "`find-file' the file in the shell env CMD_FILE. It is set in ~/.zshenv." (let* ((file (file-to-string (getenv "CMD_FILE"))) (search-string (file-to-string (getenv "CMD_STR"))) (search-string-fun-syntax (@f "%s ()" search-string))) (when (file-exists-p file) (find-file file) (let ((beg (point))) (goto-beg) (if (search-forward search-string-fun-syntax nil 'noerror) (beginning-of-line-at-top) (goto-char beg)))))) ;; -------------------------------------------------------------------------------- (<- 'll-zsh)