From dc7ace6e14de4c5f1df946aa20d1684756f4ad53 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Tue, 25 Oct 2022 21:47:48 -0700 Subject: [PATCH] Global regular expression replacement Saving a keystroke and remembering my place. --- ha-data.org | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ha-data.org b/ha-data.org index c1dbec5..33baa29 100644 --- a/ha-data.org +++ b/ha-data.org @@ -31,9 +31,19 @@ Once upon a time, I [[https://www.youtube.com/watch?v=HKJMDJ4i-XI][gave a talk]] (ha-leader "d" '(:ignore t :which-key "data") "d |" '("pipe to shell" . replace-buffer-with-shell-command) + "d r" '("replace buffer" . ha-vr-replace-all) "d y" '("copy to clipboard" . ha-yank-buffer-contents)) #+end_src +** Global Replacements +The string replacement functions operate at the current point, which means I need to jump to the beginning before calling something like [[help:vr/replace][vr/replace]]. +#+begin_src emacs-lisp + (defun ha-vr-replace-all (regexp replace start end) + "Regexp-replace entire buffer with live visual feedback." + (interactive + (vr--interactive-get-args 'vr--mode-regexp-replace 'vr--calling-func-replace)) + (vr/replace regexp replace (point-min) (point-max))) +#+end_src * Line-Oriented Functions These functions focus on the data in the buffer as a series of lines: #+begin_src emacs-lisp