summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-02-14 10:53:46 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2013-02-14 10:53:46 -0500
commit213ac1686cc1557a77c6fb38619f7f6d6076051a (patch)
tree5b0b2dc79bb5c2b4acb6706a8ad31a97ca899b84 /lisp
parentdf1af142da9a6800a9c7ffef62f38464613664df (diff)
downloademacs-213ac1686cc1557a77c6fb38619f7f6d6076051a.tar.gz
emacs-213ac1686cc1557a77c6fb38619f7f6d6076051a.tar.bz2
emacs-213ac1686cc1557a77c6fb38619f7f6d6076051a.zip
* 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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/net/goto-addr.el23
2 files changed, 17 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a8fd8c87c5b..5bd02f933de 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2013-02-14 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * 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 <fgallina@cuca>
* progmodes/python.el: Explain how to restore "cc-mode"-like
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 1005285917e..59e4da16619 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -156,18 +156,19 @@ A value of t means there is no limit--fontify regardless of the size."
(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 @@ and `goto-address-fontify-p'."
(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 @@ and `goto-address-fontify-p'."
(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