summaryrefslogtreecommitdiff
path: root/emacs-config.org
diff options
context:
space:
mode:
Diffstat (limited to 'emacs-config.org')
-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