summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Romero <blake@blkrom.com>2025-07-10 10:24:48 +0100
committerBlake Romero <blake@blkrom.com>2025-07-10 10:38:49 +0100
commit769f6f1fb50c272880912c8535e478c89410f024 (patch)
tree42659f78dafb8a45b95e55ea9887a99f7b00e716
parentba293be02163b916581eb3530863125fa781e6d9 (diff)
Change query-replace to work on whole buffer by default
-rw-r--r--emacs-config.org13
1 files changed, 13 insertions, 0 deletions
diff --git a/emacs-config.org b/emacs-config.org
index c067c52..d80ee24 100644
--- a/emacs-config.org
+++ b/emacs-config.org
@@ -66,6 +66,19 @@ Add advice to cut line or region at cursor point.
(line-beginning-position 2)))))
#+end_src
+Add advice to enable ~query-replace~ to search the whole buffer or region if selected, as the original default behaviour would only begin to replace from the cursor point position.
+#+begin_src elisp
+ (defun +advice-goto-top-no-region (func &rest args)
+ "Move point to top of buffer when no region applying ARGS to FUNC."
+ (save-excursion
+ (when (not (use-region-p))
+ (goto-char (point-min)))
+ (apply func args)))
+
+ (advice-add 'query-replace :around #'+advice-goto-top-no-region)
+ (advice-add 'query-replace-regexp :around #'+advice-goto-top-no-region)
+#+end_src
+
** Editor
Tab behaviour settings.
#+begin_src elisp