diff options
| author | Richard M. Stallman | 2002-02-01 04:17:59 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-02-01 04:17:59 +0000 |
| commit | f87d993410e38fad12d69b2f18b0ee6f64cb3d78 (patch) | |
| tree | 7a3fd275c9439c300d9b42467faf58b2d5affad1 | |
| parent | e329ba0e056521e753840fc3337f41bc0058954b (diff) | |
| download | emacs-f87d993410e38fad12d69b2f18b0ee6f64cb3d78.tar.gz emacs-f87d993410e38fad12d69b2f18b0ee6f64cb3d78.zip | |
(hilit-chg-fixup): Don't alter overlay if not ours.
(hilit-chg-set-face-on-change): Rename arg.
(hilit-chg-make-ov): Detect error earlier.
| -rw-r--r-- | lisp/hilit-chg.el | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/lisp/hilit-chg.el b/lisp/hilit-chg.el index 357b39b5b45..607f320894a 100644 --- a/lisp/hilit-chg.el +++ b/lisp/hilit-chg.el | |||
| @@ -442,12 +442,12 @@ This is the opposite of `hilit-chg-hide-changes'." | |||
| 442 | 442 | ||
| 443 | 443 | ||
| 444 | (defun hilit-chg-make-ov (prop start end) | 444 | (defun hilit-chg-make-ov (prop start end) |
| 445 | (or prop | ||
| 446 | (error "hilit-chg-make-ov: prop is nil")) | ||
| 445 | ;; for the region make change overlays corresponding to | 447 | ;; for the region make change overlays corresponding to |
| 446 | ;; the text property 'hilit-chg | 448 | ;; the text property 'hilit-chg |
| 447 | (let ((ov (make-overlay start end)) | 449 | (let ((ov (make-overlay start end)) |
| 448 | face) | 450 | face) |
| 449 | (or prop | ||
| 450 | (error "hilit-chg-make-ov: prop is nil")) | ||
| 451 | (if (eq prop 'hilit-chg-delete) | 451 | (if (eq prop 'hilit-chg-delete) |
| 452 | (setq face 'highlight-changes-delete-face) | 452 | (setq face 'highlight-changes-delete-face) |
| 453 | (setq face (nth 1 (member prop hilit-chg-list)))) | 453 | (setq face (nth 1 (member prop hilit-chg-list)))) |
| @@ -487,30 +487,28 @@ This is the opposite of `hilit-chg-display-changes'." | |||
| 487 | Ensure the overlays agree with the changes as determined from | 487 | Ensure the overlays agree with the changes as determined from |
| 488 | the text properties of type `hilit-chg' ." | 488 | the text properties of type `hilit-chg' ." |
| 489 | ;; Remove or alter overlays in region beg..end | 489 | ;; Remove or alter overlays in region beg..end |
| 490 | (let (p ov ov-start ov-end | 490 | (let (ov-start ov-end props q) |
| 491 | props q) | ||
| 492 | (setq p (overlays-in beg end)) | ||
| 493 | ;; temp for debugging: | 491 | ;; temp for debugging: |
| 494 | ;; (or (eq highlight-changes-mode 'active) | 492 | ;; (or (eq highlight-changes-mode 'active) |
| 495 | ;; (error "hilit-chg-fixup called but Highlight Changes mode not active")) | 493 | ;; (error "hilit-chg-fixup called but Highlight Changes mode not active")) |
| 496 | (while p | 494 | (dolist (ov (overlays-in beg end)) |
| 497 | (setq ov (car p)) | 495 | ;; Don't alter overlays that are not ours. |
| 498 | (setq ov-start (overlay-start ov)) | 496 | (when (overlay-get ov 'hilit-chg) |
| 499 | (setq ov-end (overlay-end ov)) | 497 | (let ((ov-start (overlay-start ov)) |
| 500 | (if (< ov-start beg) | 498 | (ov-end (overlay-end ov))) |
| 501 | (progn | 499 | (if (< ov-start beg) |
| 502 | (move-overlay ov ov-start beg) | 500 | (progn |
| 501 | (move-overlay ov ov-start beg) | ||
| 502 | (if (> ov-end end) | ||
| 503 | (progn | ||
| 504 | (setq props (overlay-properties ov)) | ||
| 505 | (setq ov (make-overlay end ov-end)) | ||
| 506 | (while props | ||
| 507 | (overlay-put ov (car props)(car (cdr props))) | ||
| 508 | (setq props (cdr (cdr props))))))) | ||
| 503 | (if (> ov-end end) | 509 | (if (> ov-end end) |
| 504 | (progn | 510 | (move-overlay ov end ov-end) |
| 505 | (setq props (overlay-properties ov)) | 511 | (delete-overlay ov)))))) |
| 506 | (setq ov (make-overlay end ov-end)) | ||
| 507 | (while props | ||
| 508 | (overlay-put ov (car props)(car (cdr props))) | ||
| 509 | (setq props (cdr (cdr props))))))) | ||
| 510 | (if (> ov-end end) | ||
| 511 | (move-overlay ov end ov-end) | ||
| 512 | (delete-overlay ov))) | ||
| 513 | (setq p (cdr p))) | ||
| 514 | (hilit-chg-display-changes beg end))) | 512 | (hilit-chg-display-changes beg end))) |
| 515 | 513 | ||
| 516 | ;;;###autoload | 514 | ;;;###autoload |
| @@ -523,7 +521,7 @@ This allows you to manually remove highlighting from uninteresting changes." | |||
| 523 | (hilit-chg-fixup beg end))) | 521 | (hilit-chg-fixup beg end))) |
| 524 | 522 | ||
| 525 | (defun hilit-chg-set-face-on-change (beg end leng-before | 523 | (defun hilit-chg-set-face-on-change (beg end leng-before |
| 526 | &optional no-proerty-change) | 524 | &optional no-property-change) |
| 527 | "Record changes and optionally display them in a distinctive face. | 525 | "Record changes and optionally display them in a distinctive face. |
| 528 | `hilit-chg-set' adds this function to the `after-change-functions' hook." | 526 | `hilit-chg-set' adds this function to the `after-change-functions' hook." |
| 529 | ;; | 527 | ;; |
| @@ -569,9 +567,9 @@ This allows you to manually remove highlighting from uninteresting changes." | |||
| 569 | (put-text-property end (+ end 1) 'hilit-chg 'hilit-chg) | 567 | (put-text-property end (+ end 1) 'hilit-chg 'hilit-chg) |
| 570 | (if (eq highlight-changes-mode 'active) | 568 | (if (eq highlight-changes-mode 'active) |
| 571 | (hilit-chg-fixup beg (+ end 1)))))) | 569 | (hilit-chg-fixup beg (+ end 1)))))) |
| 572 | (unless no-proerty-change | 570 | (unless no-property-change |
| 573 | (put-text-property beg end 'hilit-chg type)) | 571 | (put-text-property beg end 'hilit-chg type)) |
| 574 | (if (or (eq highlight-changes-mode 'active) no-proerty-change) | 572 | (if (or (eq highlight-changes-mode 'active) no-property-change) |
| 575 | (hilit-chg-make-ov type beg end)))))) | 573 | (hilit-chg-make-ov type beg end)))))) |
| 576 | 574 | ||
| 577 | (defun hilit-chg-set (value) | 575 | (defun hilit-chg-set (value) |