[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f30cf07: Make symbol-at-point return nil if there's no symbols in
From: |
Lars Ingebrigtsen |
Subject: |
master f30cf07: Make symbol-at-point return nil if there's no symbols in the buffer |
Date: |
Wed, 20 Jan 2021 10:58:18 -0500 (EST) |
branch: master
commit f30cf07ecba8f4316b268b7ad57705a0aa16d660
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make symbol-at-point return nil if there's no symbols in the buffer
* 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 | 9 +++++++++
test/lisp/thingatpt-tests.el | 1 -
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index d3ba941..67d4092 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -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)
diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el
index 8eec853..62a27f0 100644
--- a/test/lisp/thingatpt-tests.el
+++ b/test/lisp/thingatpt-tests.el
@@ -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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f30cf07: Make symbol-at-point return nil if there's no symbols in the buffer,
Lars Ingebrigtsen <=