0

When using thing-at-point to get a word or filename - for example, how can I get the cursor position relative to the text?

Either by getting the absolute starting location of the thing, or a relative character index.

2

You find the following answer within the code of thing-at-point:

(defun start-of-thing-at-point (thing)
  "Get start of THING at point."
  (let ((bounds (bounds-of-thing-at-point thing)))
    (and bounds (car bounds))))

For your examples thing should be either 'word or 'filename.

Tested with 26.3.

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.