diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-01-20 16:58:09 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-01-20 16:58:09 +0100 |
commit | f30cf07ecba8f4316b268b7ad57705a0aa16d660 (patch) | |
tree | 494ce046c3d73f86eecbc3dd6fedaaed9f73e484 /lisp/thingatpt.el | |
parent | ce1a42a6eb41ab7a4473de9e8d8961498568576a (diff) | |
download | emacs-f30cf07ecba8f4316b268b7ad57705a0aa16d660.tar.gz emacs-f30cf07ecba8f4316b268b7ad57705a0aa16d660.tar.bz2 emacs-f30cf07ecba8f4316b268b7ad57705a0aa16d660.zip |
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.
Diffstat (limited to 'lisp/thingatpt.el')
-rw-r--r-- | lisp/thingatpt.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index d3ba941fcc2..67d4092d407 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) |