GNU bug report logs - #15808
24.3; thing-at-point slow for url and email

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Tue, 5 Nov 2013 02:53:02 UTC

Severity: normal

Found in version 24.3

Done: Leo Liu <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 15808 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 15808 <at> debbugs.gnu.org
Subject: Re: bug#15808: 24.3; thing-at-point slow for url and email
Date: Wed, 06 Nov 2013 11:35:39 +0800
On 2013-11-06 10:18 +0800, Stefan Monnier wrote:
> The count is too small: this is a sample-based profiler, so you need
> a long enough runtime to get meaningful results (otherwise, the various
> stack fragments collected can't be pieced together to get the whole tree).
>
> Also, it seems some of the code is interpreted.  If the result is still
> hard to interpret, you might want to try and byte-compile that code.

I tried the thingatpt.el and the URL case is not slow there but email
is. Profiler says most time is spent in thing-at-point-looking-at. I
propose the following fix? Comments?

=== modified file 'lisp/thingatpt.el'
--- lisp/thingatpt.el	2013-08-10 15:17:29 +0000
+++ lisp/thingatpt.el	2013-11-06 03:32:52 +0000
@@ -476,7 +476,7 @@
 ;; matches that straddle the start position so we search forwards once
 ;; and then back repeatedly and then back up a char at a time.
 
-(defun thing-at-point-looking-at (regexp)
+(defun thing-at-point-looking-at (regexp &optional limit)
   "Return non-nil if point is in or just after a match for REGEXP.
 Set the match data from the earliest such match ending at or after
 point."
@@ -487,7 +487,7 @@
 	   (setq match (point)))
       ;; Search back repeatedly from end of next match.
       ;; This may fail if next match ends before this match does.
-      (re-search-forward regexp nil 'limit)
+      (re-search-forward regexp limit 'limit)
       (while (and (re-search-backward regexp nil t)
 		  (or (> (match-beginning 0) old-point)
 		      (and (looking-at regexp)	; Extend match-end past search start
@@ -518,7 +518,8 @@
 
 (put 'email 'bounds-of-thing-at-point
      (lambda ()
-       (let ((thing (thing-at-point-looking-at thing-at-point-email-regexp)))
+       (let ((thing (thing-at-point-looking-at thing-at-point-email-regexp
+					       (+ (point) 500))))
          (if thing
              (let ((beginning (match-beginning 0))
                    (end (match-end 0)))




This bug report was last modified 11 years and 203 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.