Skip to content

Commit

Permalink
Switch to literal search automaticity when parsing keyword regexp fai…
Browse files Browse the repository at this point in the history
…led.
  • Loading branch information
manateelazycat committed Sep 11, 2018
1 parent 77e8bd3 commit 41f931a
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions color-rg.el
Expand Up @@ -6,8 +6,8 @@
;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com> ;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
;; Copyright (C) 2018, Andy Stewart, all rights reserved. ;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-08-26 14:22:12 ;; Created: 2018-08-26 14:22:12
;; Version: 1.4 ;; Version: 1.5
;; Last-Updated: 2018-09-04 12:55:03 ;; Last-Updated: 2018-09-11 11:15:46
;; By: Andy Stewart ;; By: Andy Stewart
;; URL: http://www.emacswiki.org/emacs/download/color-rg.el ;; URL: http://www.emacswiki.org/emacs/download/color-rg.el
;; Keywords: ;; Keywords:
Expand Down Expand Up @@ -68,6 +68,9 @@


;;; Change log: ;;; Change log:
;; ;;
;; 2018/09/11
;; * Switch to literal search automaticity when parsing keyword regexp failed.
;;
;; 2018/09/04 ;; 2018/09/04
;; * Use `color-rg-process-setup' monitor process finished, then output search hit in minibuffer. ;; * Use `color-rg-process-setup' monitor process finished, then output search hit in minibuffer.
;; * Avoid function `move-to-column' change search file content. ;; * Avoid function `move-to-column' change search file content.
Expand Down Expand Up @@ -366,7 +369,17 @@ This function is called from `compilation-filter-hook'."
((not (buffer-modified-p)) ((not (buffer-modified-p))
'("finished with no matches found\n" . "no match")) '("finished with no matches found\n" . "no match"))
(t (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))))) (cons msg code)))))


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




(defun color-rg-rerun-literal () (defun color-rg-rerun-literal (&optional nointeractive)
(interactive) (interactive)
(with-current-buffer color-rg-buffer (with-current-buffer color-rg-buffer
(let* ( (let* (
Expand All @@ -820,7 +833,9 @@ this function a no-op."
(t (t
(replace-regexp-in-string (regexp-quote "--regexp") "--fixed-strings" color-rg-default-argument)) (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 (literal-keyword
(color-rg-literal-string-escape input-keyword))) (color-rg-literal-string-escape input-keyword)))


Expand Down

0 comments on commit 41f931a

Please sign in to comment.