;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/ide/find-command.el (require 'file-write-to) (require 'get-search-string) (require 'simple) (require 'window-incal) (defun shell-command-silent (cmd) (process-file shell-file-name nil nil nil shell-command-switch cmd) ) (defun find-command-zsh (&optional cmd) "Find the source for a zsh cmd. This requires an external zsh script to work, see https://dataswamp.org/~incal/conf/.zsh/find-command" (interactive) (or cmd (setq cmd (get-search-string "zsh"))) (let*((search-command (format "find-zsh-command %s" cmd)) (file-data-path (getenv "COMMAND_FILE")) (erase-data-command (format "echo -n > %s" file-data-path)) ) (shell-command-silent erase-data-command) (shell-command-silent search-command) (let ((file (file-to-string file-data-path)) (case-fold-search nil) (cmd-search-string (format "%s ()" cmd)) ) (unless (string= file "") (find-file file) (goto-char (point-min)) (when (search-forward-regexp cmd-search-string nil t) (beginning-of-line-at-top) ))))) ;; (find-command-zsh "find-zsh-command") ;; (find-command-zsh "no-command") (provide 'find-command)