Skip to content

Commit

Permalink
Don't underline line/column numbers
Browse files Browse the repository at this point in the history
Also allow for customization of the faces for line, column and the
whole message.
  • Loading branch information
dajva committed Sep 15, 2018
1 parent b161fe1 commit d1f4ec4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
40 changes: 30 additions & 10 deletions rg-result.el
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,54 @@ new content and filtered through the `rg-filter' function.")

(defface rg-match-face
`((t :inherit ,grep-match-face))
"face for match highlight"
"Face for match highlight."
:group 'rg-face)

(defface rg-error-face
`((t :inherit ,grep-error-face))
"face for error"
"Face for error."
:group 'rg-face)

(defface rg-context-face
`((t :inherit ,grep-context-face))
"face for context lines"
"Face for context lines."
:group 'rg-face)

(defface rg-info-face
'((t :inherit compilation-info))
"face for info"
"Face for info."
:group 'rg-face)

(defface rg-warning-face
'((t :inherit compilation-warning))
"face for warning"
"Face for warning."
:group 'rg-face)

(defface rg-filename-face
'((t :inherit rg-info-face))
"face for filename"
"Face for filename."
:group 'rg-face)

(defface rg-file-tag-face
'((t :inherit font-lock-function-name-face))
"face for file tag in grouped layout"
"Face for file tag in grouped layout."
:group 'rg-face)

(defface rg-line-number-face
'((t :inherit compilation-line-number))
"Face for line numbers."
:group 'rg-face)

(defface rg-column-number-face
'((t :inherit compilation-column-number))
"Face for column numbers."
:group 'rg-face)

(defface rg-match-position-face
'((t :inherit default))
"Face that is being appended to file positions.
This is the start of each matching line. This includes line number
and, depending on configuration, also column number and file name."
:group 'rg-face)


Expand Down Expand Up @@ -298,8 +315,11 @@ Commands:
\\{rg-mode-map}"
(setq grep-last-buffer (current-buffer))
(set (make-local-variable 'tool-bar-map) grep-mode-tool-bar-map)
(set (make-local-variable 'compilation-error-face)
'rg-filename-face)
(set (make-local-variable 'compilation-error-face) 'rg-filename-face)
(set (make-local-variable 'compilation-message-face) 'rg-match-position-face)
(set (make-local-variable 'compilation-line-face) 'rg-line-number-face)
(set (make-local-variable 'compilation-column-face) 'rg-column-number-face)

(set (make-local-variable 'compilation-error-regexp-alist)
'(rg-group-with-column rg-nogroup-with-column rg-group-no-column rg-nogroup-no-column))
(set (make-local-variable 'compilation-error-regexp-alist-alist)
Expand All @@ -319,7 +339,7 @@ Commands:
(when rg-show-header
(rg-create-header-line 'rg-cur-search
(rg-search-full-command rg-cur-search)))
(add-hook 'compilation-filter-hook 'rg-filter nil t) )
(add-hook 'compilation-filter-hook 'rg-filter nil t))

(defun rg-rerun ()
"Run `rg-recompile' with `compilation-arguments' taken from `rg-cur-search'."
Expand Down
6 changes: 3 additions & 3 deletions rg.el
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ detailed info."
(setq rg-toggle-command-line-flags
(delete "-i" rg-toggle-command-line-flags))))

(defun rg-rename-target ()
(defun rg-get-rename-target ()
"Return the buffer that will be target for renaming."
(let ((buffer (if (eq major-mode 'rg-mode)
(current-buffer)
Expand Down Expand Up @@ -455,7 +455,7 @@ The result buffer will be renamed to *rg NEWNAME*. New searches will use the
standard *rg* buffer unless the search is done from a saved buffer in
which case the saved buffer will be reused."
(interactive "sSave search as name: ")
(let ((buffer (rg-rename-target)))
(let ((buffer (rg-get-rename-target)))
(with-current-buffer buffer
(rename-buffer (concat "*rg " newname "*")))))

Expand All @@ -466,7 +466,7 @@ To choose a custom name, use `rg-save-search-as-name' instead. New
searches will use the standard *rg* buffer unless the search is done
from a saved buffer in which case the saved buffer will be reused."
(interactive)
(let ((buffer (rg-rename-target)))
(let ((buffer (rg-get-rename-target)))
(with-current-buffer buffer
(rename-uniquely)
;; If the new buffer name became '*rg*', just rename again to make
Expand Down

0 comments on commit d1f4ec4

Please sign in to comment.