What's the most reliable way to get the start and end positions of the symbol at the cursor location (point)?
thingatpt.el API works as follows:
(thing-at-point 'symbol) ;=> foo (beginning-of-thing 'symbol) ;=> 42 (end-of-thing 'symbol) ;=> 45 (bounds-of-thing-at-point 'symbol) ;=> (42 . 45)
While it's not 100% reliable as it relies on
(forward-thing 'symbol) to do the right thing, it's pretty good and one of the better APIs in Emacs. Give it a try!
I would expect
symbol-at-point to be reliable.
Given that you yourself tagged this question with
thing-at-point, are you asking in particular whether there are flaws with this method?