comparison lisp/ediff/ediff-init.el @ 14:9ee227acff29 r19-15b90

Import from CVS: tag r19-15b90
author cvs
date Mon, 13 Aug 2007 08:48:42 +0200
parents bcdc7deadc19
children 0293115a14e9
comparison
equal deleted inserted replaced
13:13c6d0aaafe5 14:9ee227acff29
61 (cond ((ediff-window-display-p)) 61 (cond ((ediff-window-display-p))
62 (ediff-force-faces) 62 (ediff-force-faces)
63 (ediff-emacs-p (memq (ediff-device-type) '(pc))) 63 (ediff-emacs-p (memq (ediff-device-type) '(pc)))
64 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc))))) 64 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))))
65 65
66 66
67 ;; Defines SYMBOL as an advertised local variable. 67 ;; Defines SYMBOL as an advertised local variable.
68 ;; Performs a defvar, then executes `make-variable-buffer-local' on 68 ;; Performs a defvar, then executes `make-variable-buffer-local' on
69 ;; the variable. Also sets the `permanent-local' property, 69 ;; the variable. Also sets the `permanent-local' property,
70 ;; so that `kill-all-local-variables' (called by major-mode setting 70 ;; so that `kill-all-local-variables' (called by major-mode setting
71 ;; commands) won't destroy Ediff control variables. 71 ;; commands) won't destroy Ediff control variables.
511 ;; The original values of ediff-protected-variables for buffer Ancestor 511 ;; The original values of ediff-protected-variables for buffer Ancestor
512 (ediff-defvar-local ediff-buffer-values-orig-Ancestor nil "") 512 (ediff-defvar-local ediff-buffer-values-orig-Ancestor nil "")
513 ;; Buffer-local variables to be saved then restored during Ediff sessions 513 ;; Buffer-local variables to be saved then restored during Ediff sessions
514 ;; Buffer-local variables to be saved then restored during Ediff sessions 514 ;; Buffer-local variables to be saved then restored during Ediff sessions
515 (defconst ediff-protected-variables '( 515 (defconst ediff-protected-variables '(
516 ;;buffer-read-only 516 ;;buffer-read-only
517 mode-line-format)) 517 mode-line-format))
518 518
519 ;; Vector of differences between the variants. Each difference is 519 ;; Vector of differences between the variants. Each difference is
520 ;; represented by a vector of two overlays plus a vector of fine diffs, 520 ;; represented by a vector of two overlays plus a vector of fine diffs,
521 ;; plus a no-fine-diffs flag. The first overlay spans the 521 ;; plus a no-fine-diffs flag. The first overlay spans the
1155 (defsubst ediff-file-remote-p (file-name) 1155 (defsubst ediff-file-remote-p (file-name)
1156 (require 'ange-ftp) 1156 (require 'ange-ftp)
1157 (car (if ediff-xemacs-p 1157 (car (if ediff-xemacs-p
1158 (ange-ftp-ftp-path file-name) 1158 (ange-ftp-ftp-path file-name)
1159 (ange-ftp-ftp-name file-name)))) 1159 (ange-ftp-ftp-name file-name))))
1160
1160 1161
1161 (defsubst ediff-frame-unsplittable-p (frame) 1162 (defsubst ediff-frame-unsplittable-p (frame)
1162 (cdr (assq 'unsplittable (frame-parameters frame)))) 1163 (cdr (assq 'unsplittable (frame-parameters frame))))
1163 1164
1164 (defsubst ediff-get-next-window (wind prev-wind) 1165 (defsubst ediff-get-next-window (wind prev-wind)
1170 1171
1171 (defsubst ediff-kill-buffer-carefully (buf) 1172 (defsubst ediff-kill-buffer-carefully (buf)
1172 "Kill buffer BUF if it exists." 1173 "Kill buffer BUF if it exists."
1173 (if (ediff-buffer-live-p buf) 1174 (if (ediff-buffer-live-p buf)
1174 (kill-buffer (get-buffer buf)))) 1175 (kill-buffer (get-buffer buf))))
1176
1177 (defsubst ediff-background-face (buf-type dif-num)
1178 ;; The value of dif-num is always 1- the one that user sees.
1179 ;; This is why even face is used when dif-num is odd.
1180 (intern (format (if (ediff-odd-p dif-num)
1181 "ediff-even-diff-face-%S"
1182 "ediff-odd-diff-face-%S")
1183 buf-type)))
1175 1184
1176 1185
1177 ;; activate faces on diff regions in buffer 1186 ;; activate faces on diff regions in buffer
1178 (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight) 1187 (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight)
1179 (let ((diff-vector 1188 (let ((diff-vector
1181 overl diff-num) 1190 overl diff-num)
1182 (mapcar (function 1191 (mapcar (function
1183 (lambda (rec) 1192 (lambda (rec)
1184 (setq overl (ediff-get-diff-overlay-from-diff-record rec) 1193 (setq overl (ediff-get-diff-overlay-from-diff-record rec)
1185 diff-num (ediff-overlay-get overl 'ediff-diff-num)) 1194 diff-num (ediff-overlay-get overl 'ediff-diff-num))
1186 (ediff-set-overlay-face 1195 (if (ediff-overlay-buffer overl)
1187 overl 1196 ;; only if overlay is alive
1188 (if (not unhighlight) 1197 (ediff-set-overlay-face
1189 (ediff-background-face buf-type diff-num)) 1198 overl
1190 ))) 1199 (if (not unhighlight)
1200 (ediff-background-face buf-type diff-num))))
1201 ))
1191 diff-vector))) 1202 diff-vector)))
1192 1203
1193 1204
1194 ;; activate faces on diff regions in all buffers 1205 ;; activate faces on diff regions in all buffers
1195 (defun ediff-paint-background-regions (&optional unhighlight) 1206 (defun ediff-paint-background-regions (&optional unhighlight)
1235 (overlay 1246 (overlay
1236 (ediff-get-diff-overlay ediff-current-difference buf-type)) 1247 (ediff-get-diff-overlay ediff-current-difference buf-type))
1237 ) 1248 )
1238 1249
1239 (ediff-move-overlay current-diff-overlay 1 1) 1250 (ediff-move-overlay current-diff-overlay 1 1)
1240 1251
1241 ;; rehighlight the overlay in the background of the 1252 ;; rehighlight the overlay in the background of the
1242 ;; current difference region 1253 ;; current difference region
1243 (ediff-set-overlay-face 1254 (ediff-set-overlay-face
1244 overlay 1255 overlay
1245 (if (and (ediff-has-face-support-p) 1256 (if (and (ediff-has-face-support-p)
1257 (ediff-paint-background-regions 'unhighlight) 1268 (ediff-paint-background-regions 'unhighlight)
1258 (if (ediff-overlayp current-diff-overlay) 1269 (if (ediff-overlayp current-diff-overlay)
1259 (ediff-delete-overlay current-diff-overlay)) 1270 (ediff-delete-overlay current-diff-overlay))
1260 (set current-diff-overlay-var nil) 1271 (set current-diff-overlay-var nil)
1261 ))) 1272 )))
1273
1262 1274
1263 (defsubst ediff-highlight-diff (n) 1275 (defsubst ediff-highlight-diff (n)
1264 "Put face on diff N. Invoked for X displays only." 1276 "Put face on diff N. Invoked for X displays only."
1265 (ediff-highlight-diff-in-one-buffer n 'A) 1277 (ediff-highlight-diff-in-one-buffer n 'A)
1266 (ediff-highlight-diff-in-one-buffer n 'B) 1278 (ediff-highlight-diff-in-one-buffer n 'B)
1283 (ediff-unhighlight-diffs-totally-in-one-buffer 'B) 1295 (ediff-unhighlight-diffs-totally-in-one-buffer 'B)
1284 (ediff-unhighlight-diffs-totally-in-one-buffer 'C) 1296 (ediff-unhighlight-diffs-totally-in-one-buffer 'C)
1285 (ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor) 1297 (ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor)
1286 ) 1298 )
1287 1299
1288 (defsubst ediff-background-face (buf-type dif-num)
1289 ;; The value of dif-num is always 1- the one that user sees.
1290 ;; This is why even face is used when dif-num is odd.
1291 (intern (format (if (ediff-odd-p dif-num)
1292 "ediff-even-diff-face-%S"
1293 "ediff-odd-diff-face-%S")
1294 buf-type)))
1295
1296 1300
1297 ;; arg is a record for a given diff in a difference vector 1301 ;; arg is a record for a given diff in a difference vector
1298 ;; this record is itself a vector 1302 ;; this record is itself a vector
1299 (defsubst ediff-clear-fine-diff-vector (diff-record) 1303 (defsubst ediff-clear-fine-diff-vector (diff-record)
1300 (if diff-record 1304 (if diff-record
1414 (if ediff-xemacs-p 1418 (if ediff-xemacs-p
1415 (glyph-height ediff-H-glyph (selected-window frame)) 1419 (glyph-height ediff-H-glyph (selected-window frame))
1416 (frame-char-height frame))) 1420 (frame-char-height frame)))
1417 1421
1418 ;; Some overlay functions 1422 ;; Some overlay functions
1423
1424 (defsubst ediff-overlay-start (overl)
1425 (if (ediff-overlayp overl)
1426 (if ediff-emacs-p
1427 (overlay-start overl)
1428 (extent-start-position overl))))
1429
1430 (defsubst ediff-overlay-end (overl)
1431 (if (ediff-overlayp overl)
1432 (if ediff-emacs-p
1433 (overlay-end overl)
1434 (extent-end-position overl))))
1419 1435
1420 (defsubst ediff-empty-overlay-p (overl) 1436 (defsubst ediff-empty-overlay-p (overl)
1421 (= (ediff-overlay-start overl) (ediff-overlay-end overl))) 1437 (= (ediff-overlay-start overl) (ediff-overlay-end overl)))
1422 1438
1423 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is 1439 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is
1590 (defsubst ediff-file-modtime (filename) 1606 (defsubst ediff-file-modtime (filename)
1591 (ediff-file-attributes filename 5)) 1607 (ediff-file-attributes filename 5))
1592 1608
1593 1609
1594 (defun ediff-convert-standard-filename (fname) 1610 (defun ediff-convert-standard-filename (fname)
1595 (if ediff-emacs-p 1611 (if (fboundp 'convert-standard-filename)
1596 (convert-standard-filename fname) 1612 (convert-standard-filename fname)
1597 ;; hopefully, XEmacs adds this functionality
1598 fname)) 1613 fname))
1614
1599 1615
1600 ;;; Local Variables: 1616 ;;; Local Variables:
1601 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) 1617 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1602 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) 1618 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
1603 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) 1619 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body))
1604 ;;; End: 1620 ;;; End:
1605 1621
1606 (provide 'ediff-init) 1622 (provide 'ediff-init)
1607 1623
1608 1624
1609 ;;; ediff-init.el ends here 1625 ;;; ediff-init.el ends here