comparison lisp/hilit-chg.el @ 90295:4b3d39451150

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-14 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 58-65) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 22-28) - Update from CVS - Merge from emacs--devo--0 - Update from CVS: lisp/gnus.el: Remove bogus comment.
author Miles Bader <miles@gnu.org>
date Sat, 11 Feb 2006 00:11:19 +0000
parents c5406394f567 e065294f485f
children f1d13e615070
comparison
equal deleted inserted replaced
90294:c5406394f567 90295:4b3d39451150
519 (defun highlight-changes-remove-highlight (beg end) 519 (defun highlight-changes-remove-highlight (beg end)
520 "Remove the change face from the region between BEG and END. 520 "Remove the change face from the region between BEG and END.
521 This allows you to manually remove highlighting from uninteresting changes." 521 This allows you to manually remove highlighting from uninteresting changes."
522 (interactive "r") 522 (interactive "r")
523 (let ((after-change-functions nil)) 523 (let ((after-change-functions nil))
524 (remove-text-properties beg end '(hilit-chg nil)) 524 (remove-text-properties beg end '(hilit-chg nil))
525 (hilit-chg-fixup beg end))) 525 (hilit-chg-fixup beg end)))
526 526
527 (defun hilit-chg-set-face-on-change (beg end leng-before 527 (defun hilit-chg-set-face-on-change (beg end leng-before
528 &optional no-property-change) 528 &optional no-property-change)
529 "Record changes and optionally display them in a distinctive face. 529 "Record changes and optionally display them in a distinctive face.
660 (if (eq highlight-changes-mode 'active) 'passive 'active) 660 (if (eq highlight-changes-mode 'active) 'passive 'active)
661 highlight-changes-initial-state)) 661 highlight-changes-initial-state))
662 ;; an argument is given 662 ;; an argument is given
663 ((eq arg 'active) 663 ((eq arg 'active)
664 'active) 664 'active)
665 ((eq arg 'passive) 665 ((eq arg 'passive)
666 'passive) 666 'passive)
667 ((> (prefix-numeric-value arg) 0) 667 ((> (prefix-numeric-value arg) 0)
668 'active) 668 'active)
669 ((< (prefix-numeric-value arg) 0) 669 ((< (prefix-numeric-value arg) 0)
670 nil) 670 nil)
671 (t 671 (t
672 'passive)))) 672 'passive))))
673 (if new-highlight-changes-mode 673 (if new-highlight-changes-mode
674 ;; mode is turned on -- but may be passive 674 ;; mode is turned on -- but may be passive
675 (progn 675 (progn
676 (add-to-list 'desktop-locals-to-save 'highlight-changes-mode)
677 (hilit-chg-set new-highlight-changes-mode) 676 (hilit-chg-set new-highlight-changes-mode)
678 (or was-on 677 (or was-on
679 ;; run highlight-changes-enable-hook once 678 ;; run highlight-changes-enable-hook once
680 (run-hooks 'highlight-changes-enable-hook)) 679 (run-hooks 'highlight-changes-enable-hook))
681 (run-hooks 'highlight-changes-toggle-hook)) 680 (run-hooks 'highlight-changes-toggle-hook))
958 (defun hilit-chg-get-diff-list-hk () 957 (defun hilit-chg-get-diff-list-hk ()
959 ;; x and y are dynamically bound by hilit-chg-get-diff-info 958 ;; x and y are dynamically bound by hilit-chg-get-diff-info
960 ;; which calls this function as a hook 959 ;; which calls this function as a hook
961 (defvar x) ;; placate the byte-compiler 960 (defvar x) ;; placate the byte-compiler
962 (defvar y) 961 (defvar y)
963 (setq e (current-buffer)) 962 (setq e (current-buffer))
964 (let ((n 0) extent p va vb a b) 963 (let ((n 0) extent p va vb a b)
965 (setq x nil y nil) ;; x and y are bound by hilit-chg-get-diff-info 964 (setq x nil y nil) ;; x and y are bound by hilit-chg-get-diff-info
966 (while (< n ediff-number-of-differences) 965 (while (< n ediff-number-of-differences)
967 (ediff-make-fine-diffs n) 966 (ediff-make-fine-diffs n)
968 (setq va (ediff-get-fine-diff-vector n 'A)) 967 (setq va (ediff-get-fine-diff-vector n 'A))
969 ;; va is a vector if there are fine differences 968 ;; va is a vector if there are fine differences
970 (if va 969 (if va
1083 1082
1084 (if arg 1083 (if arg
1085 (progn 1084 (progn
1086 (if (eq arg 'active) 1085 (if (eq arg 'active)
1087 (setq highlight-changes-global-initial-state 'active) 1086 (setq highlight-changes-global-initial-state 'active)
1088 (if (eq arg 'passive) 1087 (if (eq arg 'passive)
1089 (setq highlight-changes-global-initial-state 'passive))) 1088 (setq highlight-changes-global-initial-state 'passive)))
1090 (setq global-highlight-changes t) 1089 (setq global-highlight-changes t)
1091 (message "Turning ON Global Highlight Changes mode in %s state" 1090 (message "Turning ON Global Highlight Changes mode in %s state"
1092 highlight-changes-global-initial-state) 1091 highlight-changes-global-initial-state)
1093 ;; FIXME: Not sure what this was intended to do. --Stef 1092 ;; FIXME: Not sure what this was intended to do. --Stef
1129 (if (eq (car-safe highlight-changes-global-modes) 'not) 1128 (if (eq (car-safe highlight-changes-global-modes) 'not)
1130 (not (memq major-mode (cdr highlight-changes-global-modes))) 1129 (not (memq major-mode (cdr highlight-changes-global-modes)))
1131 (memq major-mode highlight-changes-global-modes))) 1130 (memq major-mode highlight-changes-global-modes)))
1132 (t 1131 (t
1133 (and 1132 (and
1134 (not (string-match "^[ *]" (buffer-name))) 1133 (not (string-match "^[ *]" (buffer-name)))
1135 (buffer-file-name)))) 1134 (buffer-file-name))))
1136 (progn 1135 (progn
1137 (hilit-chg-set value) 1136 (hilit-chg-set value)
1138 (run-hooks 'highlight-changes-enable-hook))))) 1137 (run-hooks 'highlight-changes-enable-hook)))))
1139 1138
1144 (run-hooks 'highlight-changes-disable-hook) 1143 (run-hooks 'highlight-changes-disable-hook)
1145 (hilit-chg-clear)))) 1144 (hilit-chg-clear))))
1146 1145
1147 1146
1148 (defun hilit-chg-update-all-buffers (value) 1147 (defun hilit-chg-update-all-buffers (value)
1149 (mapcar 1148 (mapc
1150 (function (lambda (buffer) 1149 (function (lambda (buffer)
1151 (with-current-buffer buffer 1150 (with-current-buffer buffer
1152 (if value 1151 (if value
1153 (hilit-chg-turn-on-maybe value) 1152 (hilit-chg-turn-on-maybe value)
1154 (hilit-chg-turn-off-maybe)) 1153 (hilit-chg-turn-off-maybe))
1155 ))) 1154 )))
1156 (buffer-list))) 1155 (buffer-list))
1156 nil)
1157 1157
1158 ;;;; Desktop support. 1158 ;;;; Desktop support.
1159 1159
1160 ;; Called by `desktop-create-buffer' to restore `highlight-changes-mode'. 1160 ;; Called by `desktop-create-buffer' to restore `highlight-changes-mode'.
1161 (defun hilit-chg-desktop-restore (desktop-buffer-locals) 1161 (defun hilit-chg-desktop-restore (desktop-buffer-locals)
1162 (highlight-changes-mode 1162 (highlight-changes-mode
1163 (or (cdr (assq 'highlight-changes-mode desktop-buffer-locals)) 1))) 1163 (or (cdr (assq 'highlight-changes-mode desktop-buffer-locals)) 1)))
1164 1164
1165 (add-to-list 'desktop-minor-mode-handlers 1165 (add-to-list 'desktop-minor-mode-handlers
1166 '(highlight-changes-mode . hilit-chg-desktop-restore)) 1166 '(highlight-changes-mode . hilit-chg-desktop-restore))
1167
1168 (add-to-list 'desktop-locals-to-save 'highlight-changes-mode)
1167 1169
1168 ;; ===================== debug ================== 1170 ;; ===================== debug ==================
1169 ;; For debug & test use: 1171 ;; For debug & test use:
1170 ;; 1172 ;;
1171 ;; (defun hilit-chg-debug-show (&optional beg end) 1173 ;; (defun hilit-chg-debug-show (&optional beg end)