diff options
| author | Dave Love | 2000-07-20 17:29:46 +0000 |
|---|---|---|
| committer | Dave Love | 2000-07-20 17:29:46 +0000 |
| commit | 51107a70f5cd426cbdab907eb5512c99a7b1e72f (patch) | |
| tree | fe210ecc3e48e72dbfe7ab3ff07c72460a6ed110 | |
| parent | 157f852b76e802d7101d16b018faa377e196bbc5 (diff) | |
| download | emacs-51107a70f5cd426cbdab907eb5512c99a7b1e72f.tar.gz emacs-51107a70f5cd426cbdab907eb5512c99a7b1e72f.zip | |
(goto-address-fontify): Don't bother with buffer-modified and read-only
stuff -- irrelevant with overlays. Put an extra property on the
overlays and use it to clean up in case goto-address is re-run.
| -rw-r--r-- | lisp/net/goto-addr.el | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index 2a11f3dfa1a..21f027af341 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el | |||
| @@ -50,17 +50,13 @@ | |||
| 50 | ;; m)) | 50 | ;; m)) |
| 51 | ;; | 51 | ;; |
| 52 | 52 | ||
| 53 | ;; BUG REPORTS | ||
| 54 | ;; | ||
| 55 | ;; Please send bug reports to me at ericding@mit.edu. | ||
| 56 | |||
| 57 | ;; Known bugs/features: | 53 | ;; Known bugs/features: |
| 58 | ;; * goto-address-mail-regexp only catches foo@bar.org style addressing, | 54 | ;; * goto-address-mail-regexp only catches foo@bar.org style addressing, |
| 59 | ;; not stuff like X.400 addresses, etc. | 55 | ;; not stuff like X.400 addresses, etc. |
| 60 | ;; * regexp also catches Message-Id line, since it is in the format of | 56 | ;; * regexp also catches Message-Id line, since it is in the format of |
| 61 | ;; an Internet e-mail address (like Compuserve addresses) | 57 | ;; an Internet e-mail address (like Compuserve addresses) |
| 62 | ;; * If show buffer is fontified after goto-address-fontify is run | 58 | ;; * If the buffer is fontified after goto-address-fontify is run |
| 63 | ;; (say, using font-lock-fontify-buffer), then font-lock face will | 59 | ;; (say, using font-lock-fontify-buffer), then font-lock faces will |
| 64 | ;; override goto-address faces. | 60 | ;; override goto-address faces. |
| 65 | 61 | ||
| 66 | ;;; Code: | 62 | ;;; Code: |
| @@ -132,10 +128,12 @@ But only if `goto-address-highlight-p' is also non-nil." | |||
| 132 | "Fontify the URLs and e-mail addresses in the current buffer. | 128 | "Fontify the URLs and e-mail addresses in the current buffer. |
| 133 | This function implements `goto-address-highlight-p' | 129 | This function implements `goto-address-highlight-p' |
| 134 | and `goto-address-fontify-p'." | 130 | and `goto-address-fontify-p'." |
| 131 | ;; Clean up from any previous go. | ||
| 132 | (dolist (overlay (overlays-in (point-min) (point-max))) | ||
| 133 | (if (overlay-get overlay 'goto-address) | ||
| 134 | (delete-overlay overlay))) | ||
| 135 | (save-excursion | 135 | (save-excursion |
| 136 | (let ((inhibit-read-only t) | 136 | (let ((inhibit-point-motion-hooks t)) |
| 137 | (inhibit-point-motion-hooks t) | ||
| 138 | (modified (buffer-modified-p))) | ||
| 139 | (goto-char (point-min)) | 137 | (goto-char (point-min)) |
| 140 | (if (< (- (point-max) (point)) goto-address-fontify-maximum-size) | 138 | (if (< (- (point-max) (point)) goto-address-fontify-maximum-size) |
| 141 | (progn | 139 | (progn |
| @@ -150,7 +148,8 @@ and `goto-address-fontify-p'." | |||
| 150 | (overlay-put this-overlay | 148 | (overlay-put this-overlay |
| 151 | 'help-echo "mouse-2: follow URL") | 149 | 'help-echo "mouse-2: follow URL") |
| 152 | (overlay-put this-overlay | 150 | (overlay-put this-overlay |
| 153 | 'keymap goto-address-highlight-keymap))) | 151 | 'keymap goto-address-highlight-keymap) |
| 152 | (overlay-put this-overlay 'goto-address t))) | ||
| 154 | (goto-char (point-min)) | 153 | (goto-char (point-min)) |
| 155 | (while (re-search-forward goto-address-mail-regexp nil t) | 154 | (while (re-search-forward goto-address-mail-regexp nil t) |
| 156 | (let* ((s (match-beginning 0)) | 155 | (let* ((s (match-beginning 0)) |
| @@ -163,10 +162,8 @@ and `goto-address-fontify-p'." | |||
| 163 | (overlay-put this-overlay | 162 | (overlay-put this-overlay |
| 164 | 'help-echo "mouse-2: follow URL") | 163 | 'help-echo "mouse-2: follow URL") |
| 165 | (overlay-put this-overlay | 164 | (overlay-put this-overlay |
| 166 | 'keymap goto-address-highlight-keymap))))) | 165 | 'keymap goto-address-highlight-keymap) |
| 167 | (and (buffer-modified-p) | 166 | (overlay-put this-overlay 'goto-address t)))))))) |
| 168 | (not modified) | ||
| 169 | (set-buffer-modified-p nil))))) | ||
| 170 | 167 | ||
| 171 | ;;; code to find and goto addresses; much of this has been blatantly | 168 | ;;; code to find and goto addresses; much of this has been blatantly |
| 172 | ;;; snarfed from browse-url.el | 169 | ;;; snarfed from browse-url.el |