Commit 2ee562585a08

Vincent Demeester <vincent@sbr.pm>
2017-07-12 21:31:46
Add ripgrep and pt support
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 09faf47
.emacs.d/elpa/pt-20161226.1159/pt-autoloads.el
@@ -0,0 +1,35 @@
+;;; pt-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
+
+;;;### (autoloads nil "pt" "pt.el" (22886 28978 490302 184000))
+;;; Generated autoloads from pt.el
+
+(autoload 'pt-regexp "pt" "\
+Run a pt search with REGEXP rooted at DIRECTORY.
+
+\(fn REGEXP DIRECTORY &optional ARGS)" t nil)
+
+(autoload 'pt-regexp-file-pattern "pt" "\
+Run a pt search with REGEXP rooted at DIRECTORY with FILE-FILTER.
+
+\(fn REGEXP DIRECTORY PATTERN)" t nil)
+
+(autoload 'projectile-pt "pt" "\
+Run a pt search with REGEXP rooted at the current projectile project root.
+
+\(fn REGEXP)" t nil)
+
+;;;***
+
+;;;### (autoloads nil nil ("pt-pkg.el") (22886 28324 893672 747000))
+
+;;;***
+
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; End:
+;;; pt-autoloads.el ends here
.emacs.d/elpa/pt-20161226.1159/pt-pkg.el
@@ -0,0 +1,2 @@
+;;; -*- no-byte-compile: t -*-
+(define-package "pt" "20161226.1159" "A front-end for pt, The Platinum Searcher." 'nil :commit "6d99b2aaded3ece3db19a20f4b8f1d4abe382622" :url "https://github.com/bling/pt.el" :keywords '("pt" "ack" "ag" "grep" "search"))
.emacs.d/elpa/pt-20161226.1159/pt.el
@@ -0,0 +1,148 @@
+;;; pt.el --- A front-end for pt, The Platinum Searcher.
+;;
+;; Copyright (C) 2014 by Bailey Ling
+;; Author: Bailey Ling
+;; URL: https://github.com/bling/pt.el
+;; Package-Version: 20161226.1159
+;; Filename: pt.el
+;; Description: A front-end for pt, the Platinum Searcher
+;; Created: 2014-04-27
+;; Version: 0.0.3
+;; Keywords: pt ack ag grep search
+;;
+;; This file is not part of GNU Emacs.
+;;
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 3, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Install:
+;;
+;; Autoloads will be set up automatically if you use package.el.
+;;
+;; Usage:
+;;
+;; M-x pt-regexp
+;; M-x pt-regexp-file-pattern
+;; M-x projectile-pt
+;;
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'compile)
+(require 'grep)
+(require 'thingatpt)
+
+(defcustom pt-executable
+  "pt"
+  "Name of the pt executable to use."
+  :type 'string
+  :group 'pt)
+
+(defcustom pt-arguments
+  (list "--smart-case")
+  "Default arguments passed to pt."
+  :type '(repeat (string))
+  :group 'pt)
+
+(defvar pt-search-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map compilation-minor-mode-map)
+    (define-key map "n" 'next-error-no-select)
+    (define-key map "j" 'next-error-no-select)
+    (define-key map "p" 'previous-error-no-select)
+    (define-key map "k" 'previous-error-no-select)
+    (define-key map "{" 'compilation-previous-file)
+    (define-key map "}" 'compilation-next-file)
+    map)
+  "Keymap for pt-search buffers.
+`compilation-minor-mode-map' is a cdr of this.")
+
+(define-compilation-mode pt-search-mode "Pt"
+  "Platinum searcher results compilation mode"
+  (set (make-local-variable 'truncate-lines) t)
+  (set (make-local-variable 'compilation-disable-input) t)
+  (set (make-local-variable 'tool-bar-map) grep-mode-tool-bar-map)
+  (let ((symbol 'compilation-pt)
+        (pattern '("^\\([^:\n]+?\\):\\([0-9]+\\):[^0-9]" 1 2)))
+    (set (make-local-variable 'compilation-error-regexp-alist) (list symbol))
+    (set (make-local-variable 'compilation-error-regexp-alist-alist) (list (cons symbol pattern))))
+  (set (make-local-variable 'compilation-error-face) grep-hit-face)
+  (add-hook 'compilation-filter-hook 'pt-filter nil t))
+
+;; Based on grep-filter
+(defun pt-filter ()
+  "Handle match highlighting escape sequences inserted by the process.
+This function is called from `compilation-filter-hook'."
+  (save-excursion
+    (forward-line 0)
+    (let ((end (point)) beg)
+      (goto-char compilation-filter-start)
+      (forward-line 0)
+      (setq beg (point))
+      ;; Only operate on whole lines so we don't get caught with part of an
+      ;; escape sequence in one chunk and the rest in another.
+      (when (< (point) end)
+        (setq end (copy-marker end))
+        ;; Highlight matches and delete marking sequences.
+        (while (re-search-forward "\033\\[30;43m\\(.*?\\)\033\\[0m" end 1)
+          (replace-match (propertize (match-string 1)
+                                     'face nil 'font-lock-face grep-match-face)
+                         t t))
+        ;; Delete all remaining escape sequences
+        (goto-char beg)
+        (while (re-search-forward "\033\\[[0-9;]*[mK]" end 1)
+          (replace-match "" t t))))))
+
+;;;###autoload
+(defun pt-regexp (regexp directory &optional args)
+  "Run a pt search with REGEXP rooted at DIRECTORY."
+  (interactive (list (read-from-minibuffer "Pt search for: " (thing-at-point 'symbol))
+                     (read-directory-name "Directory: ")))
+  (let ((default-directory (file-name-as-directory directory)))
+    (compilation-start
+     (mapconcat 'identity
+                (append (list pt-executable)
+                        pt-arguments
+                        args
+                        '("-e" "--nogroup" "--color" "--")
+                        (list (shell-quote-argument regexp) ".")) " ")
+     'pt-search-mode)))
+
+;;;###autoload
+(defun pt-regexp-file-pattern (regexp directory pattern)
+  "Run a pt search with REGEXP rooted at DIRECTORY with FILE-FILTER."
+  (interactive (list (read-from-minibuffer "Pt search for: " (thing-at-point 'symbol))
+                     (read-directory-name "Directory: ")
+                     (read-from-minibuffer "File pattern: ")))
+  (pt-regexp regexp
+             directory
+             (list (concat "--file-search-regexp=" (shell-quote-argument pattern)))))
+
+;;;###autoload
+(defun projectile-pt (regexp)
+  "Run a pt search with REGEXP rooted at the current projectile project root."
+  (interactive (list (read-from-minibuffer "Pt search for: " (thing-at-point 'symbol))))
+  (if (fboundp 'projectile-project-root)
+      (pt-regexp regexp
+                 (projectile-project-root)
+                 (mapcar (lambda (val) (concat "--ignore=" (shell-quote-argument val)))
+                         (append projectile-globally-ignored-files
+                                 projectile-globally-ignored-directories)))
+    (error "Projectile is not available")))
+
+(provide 'pt)
+;;; pt.el ends here
.emacs.d/elpa/pt-20161226.1159/pt.elc
Binary file
.emacs.d/elpa/ripgrep-20170602.152/ripgrep-autoloads.el
@@ -0,0 +1,28 @@
+;;; ripgrep-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
+
+;;;### (autoloads nil "ripgrep" "ripgrep.el" (22886 28310 837187
+;;;;;;  784000))
+;;; Generated autoloads from ripgrep.el
+
+(autoload 'ripgrep-regexp "ripgrep" "\
+Run a ripgrep search with `REGEXP' rooted at `DIRECTORY'.
+`ARGS' provides Ripgrep command line arguments.
+
+\(fn REGEXP DIRECTORY &optional ARGS)" t nil)
+
+;;;***
+
+;;;### (autoloads nil nil ("ripgrep-pkg.el") (22886 28177 956942
+;;;;;;  112000))
+
+;;;***
+
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; End:
+;;; ripgrep-autoloads.el ends here
.emacs.d/elpa/ripgrep-20170602.152/ripgrep-pkg.el
@@ -0,0 +1,2 @@
+;;; -*- no-byte-compile: t -*-
+(define-package "ripgrep" "20170602.152" "Front-end for ripgrep, a command line search tool" 'nil :commit "5af6a0b2ee8a639cf857724ce4328f1f0955c99e" :url "https://github.com/nlamirault/ripgrep.el" :keywords '("ripgrep" "ack" "pt" "ag" "sift" "grep" "search"))
.emacs.d/elpa/ripgrep-20170602.152/ripgrep.el
@@ -0,0 +1,191 @@
+;;; ripgrep.el --- Front-end for ripgrep, a command line search tool
+
+;; Copyright (C) 2016 Nicolas Lamirault <nicolas.lamirault@gmail.com>
+;;
+;; Author: Nicolas Lamirault <nicolas.lamirault@gmail.com>
+;; Version: 0.4.0
+;; Package-Version: 20170602.152
+;; Keywords : ripgrep ack pt ag sift grep search
+;; Homepage: https://github.com/nlamirault/ripgrep.el
+
+;;; Commentary:
+
+;; Emacs front-end for ripgrep, a command line search tool
+
+;; Installation:
+
+;; ripgrep.el is available on the two major community maintained repositories
+;; Melpa stable (https://stable.melpa.org), and Melpa (https://melpa.org)
+;;
+;; (add-to-list 'package-archives
+;;              '("melpa" . "https://melpa.org/packages/") t)
+;;
+;; M-x package-install ripgrep
+
+;;; License:
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License
+;; as published by the Free Software Foundation; either version 2
+;; of the License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; Usage :
+
+;; M-x ripgrep-regexp
+
+;;; Code:
+
+(require 'compile)
+(require 'grep)
+(require 'thingatpt)
+
+
+;; Customization
+;; --------------------------
+
+(defgroup ripgrep nil
+  "Ripgrep"
+  :group 'tools
+  :group 'matching)
+
+
+(defcustom ripgrep-executable
+  "rg"
+  "Name of the ripgrep executable to use."
+  :type 'string
+  :group 'ripgrep)
+
+
+(defcustom ripgrep-arguments
+  (list "")
+  "Default arguments passed to ripgrep."
+  :type '(repeat (string))
+  :group 'ripgrep)
+
+
+(defcustom ripgrep-highlight-search t
+  "Non-nil means we highlight the current search term in results.
+This requires the ripgrep command to support --color-match, which is only in v0.14+"
+  :type 'boolean
+  :group 'ripgrep)
+
+
+;; Faces
+;; --------------------------
+
+
+(defface ripgrep-hit-face '((t :inherit compilation-info))
+  "Face name to use for ripgrep matches."
+  :group 'ripgrep)
+
+
+(defface ripgrep-match-face '((t :inherit match))
+  "Face name to use for ripgrep matches."
+  :group 'ripgrep)
+
+
+
+;; Mode
+;; --------------------------
+
+
+(defvar ripgrep-search-finished-hook nil
+  "Hook run when ripgrep completes a search in a buffer.")
+
+(defun ripgrep/run-finished-hook (buffer how-finished)
+  "Run the ripgrep hook to signal that the search has completed."
+  (with-current-buffer buffer
+    (run-hooks 'ripgrep-search-finished-hook)))
+
+(defvar ripgrep-search-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map compilation-minor-mode-map)
+    (define-key map "p" 'compilation-previous-error)
+    (define-key map "n" 'compilation-next-error)
+    (define-key map "{" 'compilation-previous-file)
+    (define-key map "}" 'compilation-next-file)
+    (define-key map "k" '(lambda ()
+                           (interactive)
+                           (let ((kill-buffer-query-functions))
+                             (kill-buffer))))
+    map)
+  "Keymap for ripgrep-search buffers.
+`compilation-minor-mode-map' is a cdr of this.")
+
+
+(define-compilation-mode ripgrep-search-mode "Ripgrep"
+  "Ripgrep results compilation mode"
+  (set (make-local-variable 'truncate-lines) t)
+  (set (make-local-variable 'compilation-disable-input) t)
+  (set (make-local-variable 'tool-bar-map) grep-mode-tool-bar-map)
+  (let ((symbol 'compilation-ripgrep)
+        (pattern '("^\\([^:\n]+?\\):\\([0-9]+\\):\\([0-9]+\\):" 1 2 3)))
+    (set (make-local-variable 'compilation-error-regexp-alist) (list symbol))
+    (set (make-local-variable 'compilation-error-regexp-alist-alist) (list (cons symbol pattern))))
+  (set (make-local-variable 'compilation-error-face) 'ripgrep-hit-face)
+  (add-hook 'compilation-filter-hook 'ripgrep-filter nil t))
+
+
+;; Taken from grep-filter, just changed the color regex.
+(defun ripgrep-filter ()
+  "Handle match highlighting escape sequences inserted by the rg process.
+This function is called from `compilation-filter-hook'."
+  (when ripgrep-highlight-search
+    (save-excursion
+      (forward-line 0)
+      (let ((end (point)) beg)
+        (goto-char compilation-filter-start)
+        (forward-line 0)
+        (setq beg (point))
+        ;; Only operate on whole lines so we don't get caught with part of an
+        ;; escape sequence in one chunk and the rest in another.
+        (when (< (point) end)
+          (setq end (copy-marker end))
+          ;; Highlight rg matches and delete marking sequences.
+          (while (re-search-forward "\033\\[30;43m\\(.*?\\)\033\\[[0-9]*m" end 1)
+            (replace-match (propertize (match-string 1)
+                                       'face nil 'font-lock-face 'ripgrep-match-face)
+                           t t))
+          ;; Delete all remaining escape sequences
+          (goto-char beg)
+          (while (re-search-forward "\033\\[[0-9;]*[mK]" end 1)
+            (replace-match "" t t)))))))
+
+
+
+;; API
+;; --------------------------
+
+
+;;;###autoload
+(defun ripgrep-regexp (regexp directory &optional args)
+  "Run a ripgrep search with `REGEXP' rooted at `DIRECTORY'.
+`ARGS' provides Ripgrep command line arguments."
+  (interactive
+   (list (read-from-minibuffer "Ripgrep search for: " (thing-at-point 'symbol))
+         (read-directory-name "Directory: ")))
+  (let ((default-directory directory))
+    (compilation-start
+     (mapconcat 'identity
+                (append (list ripgrep-executable)
+                        ripgrep-arguments
+                        args
+                        '("--no-heading --vimgrep -n")
+                        (list (shell-quote-argument regexp) ".")) " ")
+     'ripgrep-search-mode)))
+
+
+(provide 'ripgrep)
+;;; ripgrep.el ends here
.emacs.d/elpa/ripgrep-20170602.152/ripgrep.elc
Binary file
.emacs.d/emacs.el
@@ -532,6 +532,8 @@
     (add-to-list 'popwin:special-display-config `("*Go Test*" :height 0.3))
     (add-to-list 'popwin:special-display-config `("*Async Shell Command*" :height 0.3))
     (add-to-list 'popwin:special-display-config `(flycheck-error-list-mode :height 0.5 :regexp t :position bottom))
+    (add-to-list 'popwin:special-display-config `("*Shell Command Output*" :height 0.3 :position bottom))
+    (add-to-list 'popwin:special-display-config `(pt-search-mode :height 0.4 :regexp t :position bottom :noselect t))
     (popwin-mode 1)
     (global-set-key (kbd "C-z") popwin:keymap)))
 
@@ -662,6 +664,18 @@
   :bind*
   (("M-m p p" . projectile-persp-switch-project)))
 
+(use-package ripgrep
+  :ensure t
+  :after projectile
+  :bind*
+  (("M-m p s r" . projectile-ripgrep)))
+
+(use-package pt
+  :ensure t
+  :after projectile
+  :bind*
+  (("M-m p s p" . projectile-pt)))
+
 (use-package doom-themes
   :ensure t
   :config
@@ -1056,8 +1070,8 @@ point reaches the beginning or end of the buffer, stop there."
 (setq org-capture-templates
    '(;; other entries
         ("t" "inbox"
-      entry (file+headline (expand-file-name org-main-file org-todos-directory) "Inbox")
-         "* TODO %?\n%i\n%a")
+      entry (file (expand-file-name org-inbox-file org-todos-directory))
+         "* %?\n%i\n%a")
         ("d" "task"
       entry (file+headline (expand-file-name org-main-file org-todos-directory) "Tasks")
          "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")
.emacs.d/emacs.org
@@ -1125,6 +1125,8 @@
           (add-to-list 'popwin:special-display-config `("*Go Test*" :height 0.3))
           (add-to-list 'popwin:special-display-config `("*Async Shell Command*" :height 0.3))
           (add-to-list 'popwin:special-display-config `(flycheck-error-list-mode :height 0.5 :regexp t :position bottom))
+          (add-to-list 'popwin:special-display-config `("*Shell Command Output*" :height 0.3 :position bottom))
+          (add-to-list 'popwin:special-display-config `(pt-search-mode :height 0.4 :regexp t :position bottom :noselect t))
           (popwin-mode 1)
           (global-set-key (kbd "C-z") popwin:keymap)))
     #+END_SRC
@@ -1271,6 +1273,18 @@
        :after projectile
        :bind*
        (("M-m p p" . projectile-persp-switch-project)))
+
+     (use-package ripgrep
+       :ensure t
+       :after projectile
+       :bind*
+       (("M-m p s r" . projectile-ripgrep)))
+
+     (use-package pt
+       :ensure t
+       :after projectile
+       :bind*
+       (("M-m p s p" . projectile-pt)))
    #+END_SRC
 
 * Visual ๐Ÿ˜Ž
@@ -1952,8 +1966,8 @@
      (setq org-capture-templates
         '(;; other entries
              ("t" "inbox"
-           entry (file+headline (expand-file-name org-main-file org-todos-directory) "Inbox")
-              "* TODO %?\n%i\n%a")
+           entry (file (expand-file-name org-inbox-file org-todos-directory))
+              "* %?\n%i\n%a")
              ("d" "task"
            entry (file+headline (expand-file-name org-main-file org-todos-directory) "Tasks")
               "* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")