mickeynp / smart-scan Goto Github PK
View Code? Open in Web Editor NEWQuickly move between identical symbols at point
Quickly move between identical symbols at point
If the symbol under the cursor is foo->method foo- is the variable that gets searched for not foo.
I've been searching for a package to search word at point for a long time, and your package help me with exactly the same function I need! Thanks a lot!
How to cycle to the beginning of buffer if searching hits the end of buffer?
And can I switch to search word/subword other than symbol(default)?
Thanks!
Ideally, smartscan would know which languages have case insensitive symbols (like Common Lisp) and know when to ignore case and when to be case sensitive. However, this is probably more trouble than it is worth since symbols are almost always written with the same cases anyway.
An easy fix that seems good enough is to simply wrap the calls to search-forward, re-search-forward and re-search-backward in smartscan-symbol-replace and smartscan-symbol-goto with a
(let ((case-fold-search nil))
...)
Sample source code (R-language):
sample_func <- function(...) {
xy <- xy2(123)
xyz
xy
}
If I place the cursor on the xy
variable, then smartscan-symbol-go-forward
correctly jumps between the two instances and correctly skips the function xy2
and the variable xyz
. However, if I use smartscan-symbol-replace
and set it to xyWRONG
, then I get:
sample_func <- function(...) {
xyWRONG <- xyWRONG2(123)
xyWRONGz
xyWRONG
}
Expected output:
sample_func <- function(...) {
xyWRONG <- xy2(123)
xyz
xyWRONG
}
Looking at the function it is using search-forward to find the next match, which makes it also match sub words. It should probably be changed to a re-search-forward with a conditional for also matching boundaries.
Hello, Micky.
The name of this repository, "smart-scan", does not match the name of the .el
file or the provides identifier in that file. I propose changing the name of the repository to "smartscan" to make it more consistent.
Regards,
Ryan Mulligan
Feature request for a command that is a combination of cua-repeat-replace-region (M-v) from CUA mode and smartscan-symbol-go-forward (M-n) from smart-scan.
When one uses cua-repeat-replace-region to replace hello with hi, it ends up replacing hello in ohello or helloo as well. On the other hand, the new command should replace just those parts that smart-scan would get to.
At the conservative side, one could provide a command not bound to any key by default that works only when CUA mode is enabled. At the forcing side, the command may be bound to a key in smart-scan mode map by default, depending on a user option.
Currently, global-smartscan-mode works in all buffers save the minibuffer.
I find that smartscan is not helpful in shell or eshell-modes. I'm sure there are other modes where it would be useful to turn off smartscan. It would be nice to be able to configure something like
(setq smartscan-ignore-modes '(eshell-mode shell-mode)) and have global-smartscan-mode respect that.
Alternatively, you could also have a function that could be hooked in, e.g. turn-off-smartscan or the like.
Hi there!
I've tried out smart-scan in a PHP mode buffer, changing a symbol inside a function with C-U M-', where symbol under point was $msg, and changed it to $mesg.
But the function also had variables like $error_msg. This ones were changed to $error_mesg.
It seems that smart-scan does not take into account the "$" character as part of the symbol.
Is there a way to configure smart-scan to consider the whole PHP variable as the symbol?
Thank you very much.
It'd be nice to have the option to move to the start of the next matching symbol, rather than the end.
Consider the following "input" with line numbers.
1 xxxxxx
2 xxXXxx
3 xxxxxx_bar
4 xxxxxx-bar
5 axxxxxxb
I observe the following.
(a) smartscan-symbol-go-forward
and smartscan-symbol-go-backward
cut these lines (or rather, their respective contents) into equivalence classes. 1 and 2 are considered equivalent by default, the others form singletons. If I want to have line 1 and 2 considered as not identical, I can employ something like
(defadvice smartscan-symbol-go-forward (around smartscan activate)
"Match in a case-sensitive way."
(let ((case-fold-search nil))
ad-do-it))
(defadvice smartscan-symbol-go-backward (around smartscan activate)
"Match in a case-sensitive way."
(let ((case-fold-search nil))
ad-do-it))
Is there a simpler way?
(b) smartscan-symbol-replace
when called on line 1 or 2 will also replace matches in line 3-5. Why?
Here's a fix:
(defun smartscan-symbol-replace (arg)
"Replaces the symbol at point with another string in the entire buffer.
With C-u the scope is limited to the current defun, as defined by
`narrow-to-defun'.
This function uses `search-forward' and `replace-match' to do the
actual work."
(interactive "P")
(save-excursion
(let* ((oldsymbol (smartscan-symbol-at-pt 'beginning))
(newsymbol (query-replace-read-to
oldsymbol (format "%sSmart Scan replace"
(if arg "[Defun] " "")) nil))
(counter 0))
(if arg (goto-char (save-excursion (beginning-of-defun) (point)))
;; go to the beginning of the buffer as it's assumed you want to
;; apply it from there onwards. beginning
(goto-char (point-min)))
(while (re-search-forward
(concat "\\_<" oldsymbol "\\_>")
(if arg (save-excursion (end-of-defun) (point)) nil) t nil)
(replace-match newsymbol nil t) (cl-incf counter 1))
(message "Smart Scan replaced %d matches" counter))))
(c) Setting smartscan-use-extended-syntax
should affect the behaviour described in (a) and (b), no? [what exactly should it do?]. It doesn't seem to have any effect for me.
Hello,
Judging from these lines in the package, smart-scan should jump over occurrences of the symbol/word in strings or comments. It works for strings, but not for comments.
Steps to reproduce:
Enter the *scratch*
buffer
Enter the following
test
;; test
"test"
;; test
test
Place point on the first test
Press M-n
As I understand it, point should jump to the last test, instead it jumps to the second and fourth before fifth.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.