emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111263: * lisp/net/goto-addr.el (


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111263: * lisp/net/goto-addr.el (goto-address-fontify): Add start and end args.
Date: Thu, 14 Feb 2013 10:53:46 -0500
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111263
committer: Stefan Monnier <address@hidden>
branch nick: emacs-24
timestamp: Thu 2013-02-14 10:53:46 -0500
message:
  * lisp/net/goto-addr.el (goto-address-fontify): Add start and end args.
  (goto-address-fontify-region): Use them instead of narrowing, so
  syntax-ppss has access to the whole buffer.
modified:
  lisp/ChangeLog
  lisp/net/goto-addr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-02-14 00:42:11 +0000
+++ b/lisp/ChangeLog    2013-02-14 15:53:46 +0000
@@ -1,3 +1,9 @@
+2013-02-14  Stefan Monnier  <address@hidden>
+
+       * net/goto-addr.el (goto-address-fontify): Add start and end args.
+       (goto-address-fontify-region): Use them instead of narrowing, so
+       syntax-ppss has access to the whole buffer.
+
 2013-02-14  Fabián Ezequiel Gallina  <address@hidden>
 
        * progmodes/python.el: Explain how to restore "cc-mode"-like

=== modified file 'lisp/net/goto-addr.el'
--- a/lisp/net/goto-addr.el     2013-01-01 09:11:05 +0000
+++ b/lisp/net/goto-addr.el     2013-02-14 15:53:46 +0000
@@ -156,18 +156,19 @@
 
 (defvar goto-address-prog-mode)
 
-(defun goto-address-fontify ()
+(defun goto-address-fontify (&optional start end)
   "Fontify the URLs and e-mail addresses in the current buffer.
 This function implements `goto-address-highlight-p'
 and `goto-address-fontify-p'."
   ;; Clean up from any previous go.
-  (goto-address-unfontify (point-min) (point-max))
+  (goto-address-unfontify (or start (point-min)) (or end (point-max)))
   (save-excursion
     (let ((inhibit-point-motion-hooks t))
-      (goto-char (point-min))
+      (goto-char (or start (point-min)))
       (when (or (eq t goto-address-fontify-maximum-size)
-               (< (- (point-max) (point)) goto-address-fontify-maximum-size))
-       (while (re-search-forward goto-address-url-regexp nil t)
+               (< (- (or end (point-max)) (point))
+                   goto-address-fontify-maximum-size))
+       (while (re-search-forward goto-address-url-regexp end t)
          (let* ((s (match-beginning 0))
                 (e (match-end 0))
                 this-overlay)
@@ -187,8 +188,8 @@
              (overlay-put this-overlay
                           'keymap goto-address-highlight-keymap)
              (overlay-put this-overlay 'goto-address t))))
-       (goto-char (point-min))
-       (while (re-search-forward goto-address-mail-regexp nil t)
+       (goto-char (or start (point-min)))
+       (while (re-search-forward goto-address-mail-regexp end t)
          (let* ((s (match-beginning 0))
                 (e (match-end 0))
                 this-overlay)
@@ -212,11 +213,9 @@
 (defun goto-address-fontify-region (start end)
   "Fontify URLs and e-mail addresses in the given region."
   (save-excursion
-    (save-restriction
-      (let ((beg-line (progn (goto-char start) (line-beginning-position)))
-           (end-line (progn (goto-char end) (line-end-position))))
-       (narrow-to-region beg-line end-line)
-       (goto-address-fontify)))))
+    (let ((beg-line (progn (goto-char start) (line-beginning-position)))
+          (end-line (progn (goto-char end) (line-end-position))))
+      (goto-address-fontify beg-line end-line))))
 
 ;; code to find and goto addresses; much of this has been blatantly
 ;; snarfed from browse-url.el


reply via email to

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