Is there a function that checks if a specific character sequence - "abc" - is on a line and puts point there if it is? And returning something (presumably nil) if "abc" isn't on the current line?

  • 3
    isearch? gnu.org/software/emacs/manual/html_node/emacs/… See also the function search-forward and re-search-forward -- type M-x describe-function or C-h f to read the doc-strings -- both functions have the ability to set bounds/limits; e.g,. line-ending-position – lawlist Dec 22 '16 at 21:42

No, but it's easy to write one (guaranteed 100% untested):

(defun search-like-alex-seems-to-want (regexp)
  (let ((pos (save-excursion
               (forward-line 0) ;; Go to BOL.
               (re-search-forward regexp (line-end-position) t))))
    (when pos (goto-char pos))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.