0

How can I move the text cursor to any of these locations, using Lisp?

(let ((beg (progn 
             (skip-syntax-backward "^ " (line-beginning-position))
             (point)))
      (end (progn 
             (skip-syntax-forward "^ " (line-end-position))
             (point))))
  ...)

I know we have goto-char, but beg and end here are not exactly character positions? ;)

I just want to move the cursor to end, for example.

4
  • 1
    (goto-char (point-max)) to go the end. See the Positions chapter in the Emacs Lisp manual and its Motion subsection: C-h i g(elisp)Positions. Also search this site for goto-char: there are plenty of hits.
    – NickD
    Commented Mar 24, 2023 at 14:20
  • 2
    " ... beg and end here is not exactly character positions?" - yes, they are character positions.
    – NickD
    Commented Mar 24, 2023 at 14:25
  • 1
    emacs.stackexchange.com/tags/elisp/info - the elisp tag is not meant as a tag for questions that have a snippet of Emacs Lisp code in them (otherwise, most questions on this site have something to do with Emacs Lisp and would contain the tag, which would make it useless for searching).
    – NickD
    Commented Mar 24, 2023 at 14:31
  • My first comment should say (goto-char end) to go to the end character position in your snippet. (goto-char (point-max)) goes to the end of the buffer - apologies for my misunderstanding.
    – NickD
    Commented Mar 25, 2023 at 17:17

1 Answer 1

1

(point) specifically returns a character position, and therefore beg and end are both character positions.

Replacing ... with (goto-char end) is precisely the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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