Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defpackage #:lw-config.editor-commands
- (:use #:cl #:editor)
- (:add-use-defaults t))
- (in-package lw-config.editor-commands)
- (defun file-present-p (dirname filename)
- "Detect if the file FILENAME present in the directory DIRNAME"
- (not (null
- (fast-directory-files
- dirname
- (lambda (name fdf-hndl)
- (declare (ignore fdf-hndl))
- (string= name filename))))))
- (defun get-current-buffer-filename ()
- (buffer-pathname (current-buffer)))
- (defun get-project-root (&optional (filename (get-current-buffer-filename)))
- "By give absolute file name, search for the .git directory
- traversing up the directory tree."
- (loop for dir = (pathname-directory filename) then (butlast dir)
- for pdir = (make-pathname :directory dir)
- for found = (file-present-p pdir ".git")
- until (or found
- (= (length dir) 1)) ;; always include :absolute in list
- finally (return (and found pdir))))
- (defcommand "Search In Project" (p &optional (string
- (symbol-name (buffer-symbol-at-point
- (current-buffer)))))
- "Search for STRING in current project"
- "Start a Search tool"
- (let ((root (get-project-root)))
- (editor::call-make-directory-search :root-directory root
- :string string
- :patterns "**/*.lisp"
- :start-p (if p nil t))))
Advertisement
Add Comment
Please, Sign In to add comment