benma / visual-regexp.el

A regexp/replace command for Emacs with interactive visual feedback
392 stars 28 forks source link

support thing-at-point #44

Closed yuandaxing closed 7 years ago

yuandaxing commented 7 years ago

I use vr/query-replace a lot. often i like to grab the word at the my cursor to the replace mini-buffer. I think thing-at-the point is a great feature.

could you please support that?

benma commented 7 years ago

Hi

You can add something like this to your config:

(defvar vr-current-thing-at-point)
(defun vr-thing-at-point-minibuffer-setup ()
  (when (and vr-current-thing-at-point
             (equal vr--in-minibuffer 'vr--minibuffer-regexp))
    (insert vr-current-thing-at-point)))
(add-hook 'minibuffer-setup-hook 'vr-thing-at-point-minibuffer-setup)

(defun vr-thing-at-point ()
  (interactive)
  (let ((vr-current-thing-at-point (thing-at-point 'symbol t)))
    (call-interactively 'vr/replace)))

You can tweak it to match your needs better (i.e. how thing-at-point is invoked).

Does this help?

yuandaxing commented 7 years ago

yes, it works. the bad thing is that, it give me the error message "vr-current-thing-at-point" is void.

benma commented 7 years ago

Change (defvar vr-current-thing-at-point) to (defvar vr-current-thing-at-point nil).

benma commented 7 years ago

Is it ok now? If so, please close the issue.

yuandaxing commented 7 years ago

fixed