summaryrefslogtreecommitdiff
path: root/lisp/thingatpt.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-12-22 13:56:47 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-12-22 13:56:47 +0100
commit29fffbdd87391272e9131be63cf93f5067d6ae0d (patch)
tree46c1c5faf8b3029c82f6c4cabc570930a3d9ff4b /lisp/thingatpt.el
parent9bcb7326860ed8b234f8ffd8bceae866b968ff39 (diff)
downloademacs-29fffbdd87391272e9131be63cf93f5067d6ae0d.tar.gz
emacs-29fffbdd87391272e9131be63cf93f5067d6ae0d.tar.bz2
emacs-29fffbdd87391272e9131be63cf93f5067d6ae0d.zip
Revert field-related thingatpt changes
This reverts 7db376e560448e61485ba054def8c82b21f33d6a, which led to severe performance regressions when being run in large buffers with no fields (bug#52593)
Diffstat (limited to 'lisp/thingatpt.el')
-rw-r--r--lisp/thingatpt.el38
1 files changed, 16 insertions, 22 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 32e66184d70..4d3e68ec9c4 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -162,30 +162,24 @@ Possibilities include `symbol', `list', `sexp', `defun',
When the optional argument NO-PROPERTIES is non-nil,
strip text properties from the return value.
-If the current buffer uses fields (see Info node `(elisp)Fields'),
-this function will narrow to the field before identifying the
-thing at point.
-
See the file `thingatpt.el' for documentation on how to define
a symbol as a valid THING."
- (save-restriction
- (narrow-to-region (field-beginning) (field-end))
- (let ((text
- (cond
- ((cl-loop for (pthing . function) in thing-at-point-provider-alist
- when (eq pthing thing)
- for result = (funcall function)
- when result
- return result))
- ((get thing 'thing-at-point)
- (funcall (get thing 'thing-at-point)))
- (t
- (let ((bounds (bounds-of-thing-at-point thing)))
- (when bounds
- (buffer-substring (car bounds) (cdr bounds))))))))
- (when (and text no-properties (sequencep text))
- (set-text-properties 0 (length text) nil text))
- text)))
+ (let ((text
+ (cond
+ ((cl-loop for (pthing . function) in thing-at-point-provider-alist
+ when (eq pthing thing)
+ for result = (funcall function)
+ when result
+ return result))
+ ((get thing 'thing-at-point)
+ (funcall (get thing 'thing-at-point)))
+ (t
+ (let ((bounds (bounds-of-thing-at-point thing)))
+ (when bounds
+ (buffer-substring (car bounds) (cdr bounds))))))))
+ (when (and text no-properties (sequencep text))
+ (set-text-properties 0 (length text) nil text))
+ text))
;;;###autoload
(defun bounds-of-thing-at-mouse (event thing)