From d1f4ec40cabc24524306d9a58590a3ad3c49b9cf Mon Sep 17 00:00:00 2001 From: David Landell Date: Sat, 15 Sep 2018 12:50:11 +0200 Subject: [PATCH] Don't underline line/column numbers Also allow for customization of the faces for line, column and the whole message. --- rg-result.el | 40 ++++++++++++++++++++++++++++++---------- rg.el | 6 +++--- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/rg-result.el b/rg-result.el index c0f7ca6..2ae2c59 100644 --- a/rg-result.el +++ b/rg-result.el @@ -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) @@ -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) @@ -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'." diff --git a/rg.el b/rg.el index e7a349e..545820c 100644 --- a/rg.el +++ b/rg.el @@ -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) @@ -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 "*"))))) @@ -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