]> git.eshelyaron.com Git - emacs.git/commitdiff
Make symbol-at-point return nil if there's no symbols in the buffer
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 20 Jan 2021 15:58:09 +0000 (16:58 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 20 Jan 2021 15:58:09 +0000 (16:58 +0100)
* lisp/thingatpt.el (thing-at-point--beginning-of-symbol): Special
op that errors out when there's no symbols in the buffer before
point (bug#14234).
(symbol): Use it.

lisp/thingatpt.el
test/lisp/thingatpt-tests.el

index d3ba941fcc2fb66f691a3a7b458ced1d89cf35a9..67d4092d407236686e53e68d70880f2aa79a9826 100644 (file)
@@ -218,6 +218,15 @@ The bounds of THING are determined by `bounds-of-thing-at-point'."
 
 (put 'sexp 'beginning-op 'thing-at-point--beginning-of-sexp)
 
+;; Symbols
+
+(put 'symbol 'beginning-op 'thing-at-point--beginning-of-symbol)
+
+(defun thing-at-point--beginning-of-symbol ()
+  "Move point to the beginning of the current symbol."
+  (and (re-search-backward "\\(\\sw\\|\\s_\\)+")
+       (skip-syntax-backward "w_")))
+
 ;;  Lists
 
 (put 'list 'bounds-of-thing-at-point 'thing-at-point-bounds-of-list-at-point)
index 8eec853d4619350378a7b356a11d8ea7d8166398..62a27f09cbd0196d249777331337c722ea708c2d 100644 (file)
@@ -185,7 +185,6 @@ position to retrieve THING.")
     (should (eq (symbol-at-point) 'bar))))
 
 (ert-deftest test-symbol-thing-3 ()
-  :expected-result :failed ; FIXME bug#14234
   (with-temp-buffer
     (insert "`[[`(")
     (goto-char 2)