diff options
Diffstat (limited to 'tag-emacs')
-rw-r--r-- | tag-emacs/emacs.d/init.org | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index a41c341e..b0babcc5 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -205,6 +205,57 @@ By default, Emacs displays page breaks as ^L. Lines look much nicer. :config (setq ag-project-root-function #'projectile-project-root)) #+END_SRC +** The Platinum Searcher + +[[https://github.com/monochromegane/the_platinum_searcher][The Platinum Searcher]] is a code search tool similar to ack and +the_silver_searcher(ag). It supports multi platforms and multi +encodings. + +#+BEGIN_SRC sh :tangle no +brew install pt +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (use-package pt + :pin melpa-stable + :bind* ("C-c p s" . ap/projectile-pt) + :config (progn + (defun pt (string directory &optional args) + (interactive (list (read-from-minibuffer "Pt search for: " (thing-at-point 'symbol)) + (read-directory-name "Directory: "))) + (let ((default-directory directory)) + (compilation-start + (mapconcat 'identity + (append (list pt-executable) + pt-arguments + args + '("--nogroup" "--nocolor" "--") + (list (shell-quote-argument string) ".")) " ")))) + + (defun ap/projectile-pt (search-term &optional arg) + "Run a pt search with SEARCH-TERM in the project. + + With an optional prefix argument ARG SEARCH-TERM is interpreted as a + regular expression." + (interactive + (list (read-from-minibuffer + (projectile-prepend-project-name (format "Pt %ssearch for: " (if current-prefix-arg "regexp " ""))) + (projectile-symbol-or-selection-at-point)) + current-prefix-arg)) + (if (require 'pt nil 'noerror) + (let ((pt-command (if arg 'pt-regexp 'pt)) + (ignore-list (-map #'shell-quote-argument + (ag/format-ignore + (-union ag-ignore-list + (append + (projectile-ignored-files-rel) (projectile-ignored-directories-rel) + grep-find-ignored-files grep-find-ignored-directories))))) + ;; reset the prefix arg, otherwise it will affect the pt-command + (current-prefix-arg nil)) + (funcall pt-command search-term (projectile-project-root) ignore-list)) + (error "Package 'pt' is not available"))))) +#+END_SRC + ** Projectile Projectile is awesome for working in projects, especially VCS-backed |