emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115001: * thingatpt.el (thing-at-point-looking-at):


From: Leo Liu
Subject: [Emacs-diffs] trunk r115001: * thingatpt.el (thing-at-point-looking-at): Add optional arg
Date: Wed, 06 Nov 2013 09:06:58 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115001
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/15808
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Wed 2013-11-06 17:06:05 +0800
message:
  * thingatpt.el (thing-at-point-looking-at): Add optional arg
  DISTANCE to bound the search. All uses changed.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/thingatpt.el              
thingatpt.el-20091113204419-o5vbwnq5f7feedwu-637
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-11-06 08:37:01 +0000
+++ b/lisp/ChangeLog    2013-11-06 09:06:05 +0000
@@ -1,3 +1,8 @@
+2013-11-06  Leo Liu  <address@hidden>
+
+       * thingatpt.el (thing-at-point-looking-at): Add optional arg
+       DISTANCE to bound the search. All uses changed.  (Bug#15808)
+
 2013-11-06  Glenn Morris  <address@hidden>
 
        * Makefile.in (setwins, setwins_almost, setwins_for_subdirs): Simplify.

=== modified file 'lisp/thingatpt.el'
--- a/lisp/thingatpt.el 2013-08-10 15:17:29 +0000
+++ b/lisp/thingatpt.el 2013-11-06 09:06:05 +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)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]