Skip to content
Permalink
Browse files

Switch to literal search automaticity when parsing keyword regexp fai…

…led.
  • Loading branch information
manateelazycat committed Sep 11, 2018
1 parent 77e8bd3 commit 41f931a21801aa1c64f90c894bb52d5638648e35
Showing with 20 additions and 5 deletions.
  1. +20 −5 color-rg.el
@@ -6,8 +6,8 @@
;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-08-26 14:22:12
;; Version: 1.4
;; Last-Updated: 2018-09-04 12:55:03
;; Version: 1.5
;; Last-Updated: 2018-09-11 11:15:46
;; By: Andy Stewart
;; URL: http://www.emacswiki.org/emacs/download/color-rg.el
;; Keywords:
@@ -68,6 +68,9 @@

;;; Change log:
;;
;; 2018/09/11
;; * Switch to literal search automaticity when parsing keyword regexp failed.
;;
;; 2018/09/04
;; * Use `color-rg-process-setup' monitor process finished, then output search hit in minibuffer.
;; * Avoid function `move-to-column' change search file content.
@@ -366,7 +369,17 @@ This function is called from `compilation-filter-hook'."
((not (buffer-modified-p))
'("finished with no matches found\n" . "no match"))
(t
(cons msg code)))
(if (string-prefix-p "exited abnormally with code" msg)
;; Switch to literal search automaticity when parsing keyword regexp failed.
(with-current-buffer color-rg-buffer
(when (search-forward-regexp "(Hint:\\s-Try\\s-the\\s---fixed-strings\\s-flag" nil t)
(run-at-time "2sec" nil
(lambda ()
(message "COLOR-RG: parsing keyword regexp failed, switch to literal search automaticity.")))
(color-rg-rerun-literal t)
))
(cons msg code))
))
(cons msg code)))))

(defun color-rg-update-header-line ()
@@ -809,7 +822,7 @@ this function a no-op."
)))


(defun color-rg-rerun-literal ()
(defun color-rg-rerun-literal (&optional nointeractive)
(interactive)
(with-current-buffer color-rg-buffer
(let* (
@@ -820,7 +833,9 @@ this function a no-op."
(t
(replace-regexp-in-string (regexp-quote "--regexp") "--fixed-strings" color-rg-default-argument))
))
(input-keyword (read-string (format "Re-search with literal: ") search-keyword))
(input-keyword (if nointeractive
search-keyword
(read-string (format "Re-search with literal: ") search-keyword)))
(literal-keyword
(color-rg-literal-string-escape input-keyword)))

0 comments on commit 41f931a

Please sign in to comment.
You can’t perform that action at this time.