From: Leo Liu <sdl.web@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 15808@debbugs.gnu.org
Subject: bug#15808: 24.3; thing-at-point slow for url and email
Date: Wed, 06 Nov 2013 11:45:21 +0800 [thread overview]
Message-ID: <m1a9hi42i6.fsf@gmail.com> (raw)
In-Reply-To: <jwv8ux2cm7g.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Tue, 05 Nov 2013 21:18:52 -0500")
Revised patch:
=== modified file 'lisp/thingatpt.el'
--- lisp/thingatpt.el 2013-08-10 15:17:29 +0000
+++ lisp/thingatpt.el 2013-11-06 03:43:24 +0000
@@ -476,19 +476,22 @@
;; 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 distance)
"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."
(save-excursion
- (let ((old-point (point)) match)
+ (let ((old-point (point))
+ (forward-bound (and distance (+ (point) distance)))
+ (backward-bound (and distance (- (point) distance)))
+ match)
(and (looking-at regexp)
(>= (match-end 0) old-point)
(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)
- (while (and (re-search-backward regexp nil t)
+ (re-search-forward regexp forward-bound 'limit)
+ (while (and (re-search-backward regexp backward-bound t)
(or (> (match-beginning 0) old-point)
(and (looking-at regexp) ; Extend match-end past search start
(>= (match-end 0) old-point)
@@ -518,7 +521,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 500)))
(if thing
(let ((beginning (match-beginning 0))
(end (match-end 0)))
next prev parent reply other threads:[~2013-11-06 3:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 2:52 bug#15808: 24.3; thing-at-point slow for url and email Leo Liu
2013-11-05 8:41 ` Andreas Röhler
2013-11-05 16:32 ` Stefan Monnier
2013-11-06 0:59 ` Leo Liu
2013-11-06 2:18 ` Stefan Monnier
2013-11-06 3:35 ` Leo Liu
2013-11-06 3:45 ` Leo Liu [this message]
2013-11-06 6:55 ` Stefan Monnier
2013-11-06 9:10 ` Leo Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1a9hi42i6.fsf@gmail.com \
--to=sdl.web@gmail.com \
--cc=15808@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).