summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-07-02 17:58:56 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-07-02 17:58:56 +0200
commitb79cfaaf14a7aa7e8bb56fc4063bd007e0edc69a (patch)
tree7eaba830369b171753959bb643519d467fd4c372
parenta06fc4be132b8dcf7a5dab9d68be3f280e14f436 (diff)
downloademacs-b79cfaaf14a7aa7e8bb56fc4063bd007e0edc69a.tar.gz
Filter out nul bytes when killing from a *grep* buffer
* lisp/progmodes/grep.el (grep-mode): Filter out the nul bytes (bug#48321).
-rw-r--r--lisp/progmodes/grep.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index a3ef90f397e..4f90a534440 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -885,6 +885,14 @@ The value depends on `grep-command', `grep-template',
(setq-local compilation-disable-input t)
(setq-local compilation-error-screen-columns
grep-error-screen-columns)
+ ;; We normally use a nul byte to separate the file name from the
+ ;; contents, but display it as ":". That's fine, but when yanking
+ ;; to other buffers, it's annoying to have the nul byte there.
+ (unless kill-transform-function
+ (setq-local kill-transform-function #'identity))
+ (add-function :filter-return (local 'kill-transform-function)
+ (lambda (string)
+ (string-replace "\0" ":" string)))
(add-hook 'compilation-filter-hook #'grep-filter nil t))
(defun grep--save-buffers ()