* lisp/thingatpt.el (thing-at-point--end-of-symbol): New function
(bug#14234).
(symbol): Use it instead of `forward-symbol', because the latter
will move to the end of the buffer even if there is no symbol
there. Instead error out like `forward-sexp' and friends.
(put 'sexp 'beginning-op 'thing-at-point--beginning-of-sexp)
+;; Symbols
+
+(put 'symbol 'end-op 'thing-at-point--end-of-symbol)
+
+(defun thing-at-point--end-of-symbol ()
+ "Move point to the end of the current symbol."
+ (re-search-forward "\\(\\sw\\|\\s_\\)+"))
+
;; Lists
(put 'list 'bounds-of-thing-at-point 'thing-at-point-bounds-of-list-at-point)
(should (thing-at-point-looking-at "2abcd"))
(should (equal (match-data) m2)))))
+(ert-deftest test-narrow-buffer-symbol ()
+ (with-temp-buffer
+ (insert "foo bar zot")
+ (goto-char 5)
+ (should (equal (symbol-at-point) 'bar)))
+ (with-temp-buffer
+ (insert "`[[`(")
+ (goto-char 2)
+ (should (equal (symbol-at-point) nil)))
+ (with-temp-buffer
+ (insert "aa `[[`(")
+ (goto-char 4)
+ (should (equal (symbol-at-point) nil))))
+
;;; thingatpt.el ends here