0

I seem to have some misunderstanding with looking-at. This is my test function :

(defun lkat ()
  "interactive looking at"
  (interactive)
  (if (looking-at "^\\s-*")
      (message "yes")
    (message "no")))

I would expect that it answers with "yes", if point is on any whitespace after line-start. If I put my cursor at the first space of a line, this works, but if I put it on the second space, it fails. Is looking-at not greedy?

Thanks to anyone who points me to my mistake...

  • 1
    Ok, I see: since looking-at starts its matching at the cursor, it can't match ^ if it is not on the first character. (doh) ! – Markus Jul 14 '17 at 12:23
  • 2
    Also, you should also remove the *, as it means "zero or more times", but you want "exactly one time". – choroba Jul 14 '17 at 12:35

Your Answer

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

Browse other questions tagged or ask your own question.