I want to skip blank region under cursor, so I created this regex:
\s+\w
translated to emacs regex [:space:]+[:graph:]
but it doesnt match what I want. It matches some random space somewhere!
Whats even worse, regex [:space:]\{1,\}[:graph:]
which is exactly same fails completelly without giving me anything.
What I want concretelly:
[cursor]_____some code...
I want to get position of the code to be able to jump there with cursor ...
EDIT: CODE
(trying to enhance code of someone else, just to be clear ...)
(setq custom/separators-regexp
(concat "\\([\-'\"(){};:,.\\/?!@#%&*+=\]\\)\\|\\(\\[\\)\\|"
"\\(\\]\\)\\|\\(\\s-\\)\\|\\(\\s_\\)\\|\\(\\`\\)\\|"
"\\(\\'\\)\\|\\(\\^\\)\\|\\(\n\\)"))
(defun custom/position-normalize-forward (saved-pos my-pos)
"Normalize position after forward move"
(if (>= (- my-pos saved-pos) 2)
(progn
;going to my-pos
(goto-char my-pos)
(if (not (eq my-pos (point-max)))
(progn
;also backward-to-separator to fix position
(custom/backward-symbol))))
(progn
;going to my-pos in the usual way
(goto-char my-pos))))
(defun custom/forward-symbol ()
"Move to the next separator like in the every NORMAL editor"
(interactive "^")
(let ((saved-pos (point))
(my-pos (re-search-forward custom/separators-regexp))
(my-pos2 (re-search-forward "[:space:]+[:graph:]")))
(if (> my-pos2 my-pos)
(progn
(message "POS %s %s" my-pos2 my-pos)
(goto-char my-pos2)
(return)))
(if (eq my-pos 1)
(progn
(goto-char (+ my-pos 1))
(setf my-pos (re-search-forward custom/separators-regexp))
(custom/position-normalize-forward saved-pos my-pos))
(custom/position-normalize-forward saved-pos my-pos))))
"[[:space:]]+[[:graph:]]"
.\=
(or in a double-quoted string,"\\="
) matches the empty string at point. Refer toC-h i g (elisp)Regexp Backslash
custom/separators-regexp
could be reduced to"\\([]['\"(){};:,.\\/?!@#%&*+=^[:space:]\n-]\\|\\s_\\|\\`\\|\\'\\)"
, assuming most of the groupings are as redundant as I suspect they are.looking-at
instead ofre-search-forward
to anchor the search at point.