Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve anzu-replace-at-cursor-thing with region in evil-mode #70

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cask
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

(development
(depends-on "powerline")
(depends-on "evil")
(depends-on "migemo"))
11 changes: 8 additions & 3 deletions anzu.el
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,13 @@
(forward-line 1)
(point)))

(defun anzu--query-from-at-cursor (buf beg end overlay-limit)
(let ((symbol (thing-at-point 'symbol)))
(defun anzu--query-from-at-cursor (buf beg end overlay-limit use-region)
(let ((symbol (save-excursion
(when use-region
(let ((orig (bound-and-true-p evil-visual-point)))
(when orig
(goto-char orig))))
(thing-at-point 'symbol))))
(unless symbol
(error "No symbol at cursor!!"))
(let ((symbol-regexp (concat "\\_<" (regexp-quote symbol) "\\_>")))
Expand Down Expand Up @@ -735,7 +740,7 @@
(let* ((from (if (and at-cursor beg)
(progn
(setq delimited nil)
(anzu--query-from-at-cursor curbuf beg end overlay-limit))
(anzu--query-from-at-cursor curbuf beg end overlay-limit use-region))
(anzu--query-from-string prompt beg end use-regexp overlay-limit)))
(to (cond ((consp from)
(prog1 (cdr from)
Expand Down