aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-01-20 04:44:18 +0100
committerLars Ingebrigtsen2021-01-20 04:44:18 +0100
commit40a5df81434ce02fba01779256b50976fb74da4f (patch)
tree706991cdbf784b269a206df7202cf6bf5b0503db /test
parent3bbec2eb2b2a48a0eaac8e83c27313bfbe9d420e (diff)
downloademacs-40a5df81434ce02fba01779256b50976fb74da4f.tar.gz
emacs-40a5df81434ce02fba01779256b50976fb74da4f.zip
Make `symbol-at-point' work in buffers with no symbols
* 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.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/thingatpt-tests.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el
index c43c81af9fd..b7c315062f9 100644
--- a/test/lisp/thingatpt-tests.el
+++ b/test/lisp/thingatpt-tests.el
@@ -146,4 +146,18 @@ position to retrieve THING.")
146 (should (thing-at-point-looking-at "2abcd")) 146 (should (thing-at-point-looking-at "2abcd"))
147 (should (equal (match-data) m2))))) 147 (should (equal (match-data) m2)))))
148 148
149(ert-deftest test-narrow-buffer-symbol ()
150 (with-temp-buffer
151 (insert "foo bar zot")
152 (goto-char 5)
153 (should (equal (symbol-at-point) 'bar)))
154 (with-temp-buffer
155 (insert "`[[`(")
156 (goto-char 2)
157 (should (equal (symbol-at-point) nil)))
158 (with-temp-buffer
159 (insert "aa `[[`(")
160 (goto-char 4)
161 (should (equal (symbol-at-point) nil))))
162
149;;; thingatpt.el ends here 163;;; thingatpt.el ends here