Guest User

Untitled

a guest
Dec 10th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. (setq lexical-binding t)
  2.  
  3. (defun projectize-1 (cmd f &rest args)
  4. (if (eq cmd real-this-command)
  5. (let* ((proot
  6. (and (= 0
  7. (prefix-numeric-value current-prefix-arg))
  8. (locate-dominating-file "." ".git")))
  9. (default-directory (or proot default-directory)))
  10. (when proot
  11. (setq current-prefix-arg nil))
  12. (apply #'funcall-interactively f
  13. (advice-eval-interactive-spec
  14. (cadr (interactive-form f)))))
  15. (apply f args)))
  16.  
  17.  
  18. (defun projectize (&rest cmds)
  19. (dolist (cmd cmds)
  20. (advice-add cmd :around
  21. (lambda (f &rest args)
  22. (interactive "P")
  23. (apply #'projectize-1 cmd f args)))))
  24.  
  25.  
  26. (projectize #'rgrep)
Add Comment
Please, Sign In to add comment