Subject: Re: bug#22692: docstring for xref-find-definitions

From: Dmitry Gutov <[email-masked]>
Date: Sat, 20 Feb 2016 03:24:18 +0200

On 02/19/2016 05:34 PM, Eli Zaretskii wrote:

>> I'd prefer to use the more precise behavior in find-tag-default-bounds
>> as well. And if there's general agreement here, I wouldn't mind taking
>> care of that patch.
>
> Making such a change is fine with me, thanks.

The patch is trivial (*). But can we really make this change? And can we 
do it in emacs-25?

It's a breaking one, but it primarily affects xref (aside from the 
"obsolete" etags commands). And by doing it now, we can avoid similar 
breakage in the next Emacs release.

The only other place find-tag-default-bounds is used, is in 
isearch-forward-symbol-at-point. Yuri, was there a reason you chose to 
use it instead of `bounds-of-thing-at-point'?

> If find-tag-default-function is also used by xref-find-references,
> then it won't be TRT to reject constants up front.  A request to find
> all the places where a certain constant is used is a valid use case.
> It is indeed unlikely to have such a request for the constant 1, but
> think about constants like 3.14159 or 3.0e+8.

That's a valid argument. I also don't think numeric literals will create 
too many false positives, even for xref-find-definitions.

(*)

diff --git a/lisp/subr.el b/lisp/subr.el
index c685f95..5f88d99 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2626,29 +2626,8 @@ find-tag-default-bounds
    "Determine the boundaries of the default tag, based on text at point.
  Return a cons cell with the beginning and end of the found tag.
  If there is no plausible default, return nil."
-  (let (from to bound)
-    (when (or (progn
-		;; Look at text around `point'.
-		(save-excursion
-		  (skip-syntax-backward "w_") (setq from (point)))
-		(save-excursion
-		  (skip-syntax-forward "w_") (setq to (point)))
-		(> to from))
-	      ;; Look between `line-beginning-position' and `point'.
-	      (save-excursion
-		(and (setq bound (line-beginning-position))
-		     (skip-syntax-backward "^w_" bound)
-		     (> (setq to (point)) bound)
-		     (skip-syntax-backward "w_")
-		     (setq from (point))))
-	      ;; Look between `point' and `line-end-position'.
-	      (save-excursion
-		(and (setq bound (line-end-position))
-		     (skip-syntax-forward "^w_" bound)
-		     (< (setq from (point)) bound)
-		     (skip-syntax-forward "w_")
-		     (setq to (point)))))
-      (cons from to))))
+  (require 'thingatpt)
+  (bounds-of-thing-at-point 'symbol))

  (defun find-tag-default ()
    "Determine default tag to search for, based on text at point.