Mercurial > emacs
comparison lisp/ediff-init.el @ 18054:0b9d9cbf3cd4
new version
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Sat, 31 May 1997 01:10:39 +0000 |
parents | beb94a5271e2 |
children | 1405083241e8 |
comparison
equal
deleted
inserted
replaced
18053:941f5d1a241e | 18054:0b9d9cbf3cd4 |
---|---|
1 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff | 1 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff |
2 | 2 |
3 ;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | 5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> |
6 | 6 |
7 ;; This file is part of GNU Emacs. | 7 ;; This file is part of GNU Emacs. |
8 | 8 |
30 (defvar ediff-grab-mouse) | 30 (defvar ediff-grab-mouse) |
31 (defvar ediff-mouse-pixel-position) | 31 (defvar ediff-mouse-pixel-position) |
32 (defvar ediff-mouse-pixel-threshold) | 32 (defvar ediff-mouse-pixel-threshold) |
33 (defvar ediff-whitespace) | 33 (defvar ediff-whitespace) |
34 (defvar ediff-multiframe) | 34 (defvar ediff-multiframe) |
35 | |
36 (and noninteractive | |
37 (eval-when-compile | |
38 (load "ange-ftp" 'noerror))) | |
35 ;; end pacifier | 39 ;; end pacifier |
36 | 40 |
37 ;; Is it XEmacs? | 41 ;; Is it XEmacs? |
38 (defconst ediff-xemacs-p (string-match "XEmacs" emacs-version)) | 42 (defconst ediff-xemacs-p (string-match "XEmacs" emacs-version)) |
39 ;; Is it Emacs? | 43 ;; Is it Emacs? |
88 (ediff-defvar-local ediff-buffer-B nil "") | 92 (ediff-defvar-local ediff-buffer-B nil "") |
89 ;; The buffer in which the C variant is stored. | 93 ;; The buffer in which the C variant is stored. |
90 (ediff-defvar-local ediff-buffer-C nil "") | 94 (ediff-defvar-local ediff-buffer-C nil "") |
91 ;; Ancestor buffer | 95 ;; Ancestor buffer |
92 (ediff-defvar-local ediff-ancestor-buffer nil "") | 96 (ediff-defvar-local ediff-ancestor-buffer nil "") |
93 ;; The control buffer of ediff. | 97 ;; The Ediff control buffer |
94 (ediff-defvar-local ediff-control-buffer nil "") | 98 (ediff-defvar-local ediff-control-buffer nil "") |
95 | 99 |
96 ;;; Macros | 100 ;;; Macros |
97 (defmacro ediff-odd-p (arg) | 101 (defmacro ediff-odd-p (arg) |
98 (` (eq (logand (, arg) 1) 1))) | 102 (` (eq (logand (, arg) 1) 1))) |
123 (defmacro ediff-get-difference (n buf-type) | 127 (defmacro ediff-get-difference (n buf-type) |
124 (` (aref | 128 (` (aref |
125 (symbol-value | 129 (symbol-value |
126 (intern (format "ediff-difference-vector-%S" (, buf-type)))) (, n)))) | 130 (intern (format "ediff-difference-vector-%S" (, buf-type)))) (, n)))) |
127 | 131 |
128 ;; tell if it has been previously determined that the region has | 132 ;; Tell if it has been previously determined that the region has |
129 ;; no diffs other than the white space and newlines | 133 ;; no diffs other than the white space and newlines |
130 ;; The argument, N, is the diff region number used by Ediff to index the | 134 ;; The argument, N, is the diff region number used by Ediff to index the |
131 ;; diff vector. It is 1 less than the number seen by the user. | 135 ;; diff vector. It is 1 less than the number seen by the user. |
136 ;; Returns: | |
137 ;; t if the diffs are whitespace in all buffers | |
138 ;; 'A (in 3-buf comparison only) if there are only whitespace | |
139 ;; diffs in bufs B and C | |
140 ;; 'B (in 3-buf comparison only) if there are only whitespace | |
141 ;; diffs in bufs A and C | |
142 ;; 'C (in 3-buf comparison only) if there are only whitespace | |
143 ;; diffs in bufs A and B | |
132 ;; | 144 ;; |
133 ;; A difference vector has the form: | 145 ;; A difference vector has the form: |
134 ;; [diff diff diff ...] | 146 ;; [diff diff diff ...] |
135 ;; where each diff has the form: | 147 ;; where each diff has the form: |
136 ;; [overlay fine-diff-vector no-fine-diffs-flag] | 148 ;; [overlay fine-diff-vector no-fine-diffs-flag] |
623 (cond ((memq op '(= > >=)) nil) | 635 (cond ((memq op '(= > >=)) nil) |
624 ((memq op '(< <=)) t)))) | 636 ((memq op '(< <=)) t)))) |
625 | 637 |
626 | 638 |
627 ;;;; warn if it is a wrong version of emacs | 639 ;;;; warn if it is a wrong version of emacs |
628 ;;(if (or (ediff-check-version '< 19 29 'emacs) | 640 ;;(if (or (ediff-check-version '< 19 35 'emacs) |
629 ;; (ediff-check-version '< 19 12 'xemacs)) | 641 ;; (ediff-check-version '< 19 15 'xemacs)) |
630 ;; (progn | 642 ;; (progn |
631 ;; (with-output-to-temp-buffer ediff-msg-buffer | 643 ;; (with-output-to-temp-buffer ediff-msg-buffer |
632 ;; (switch-to-buffer ediff-msg-buffer) | 644 ;; (switch-to-buffer ediff-msg-buffer) |
633 ;; (insert | 645 ;; (insert |
634 ;; (format " | 646 ;; (format " |
635 ;; | 647 ;; |
636 ;;This version of Ediff requires | 648 ;;This version of Ediff requires |
637 ;; | 649 ;; |
638 ;;\t Emacs 19.29 and higher | 650 ;;\t Emacs 19.35 and higher |
639 ;;\t OR | 651 ;;\t OR |
640 ;;\t XEmacs 19.12 and higher | 652 ;;\t XEmacs 19.15 and higher |
641 ;; | 653 ;; |
642 ;;It is unlikely to work under Emacs version %s | 654 ;;It is unlikely to work under Emacs version %s |
643 ;;that you are using... " emacs-version)) | 655 ;;that you are using... " emacs-version)) |
644 ;; (if noninteractive | 656 ;; (if noninteractive |
645 ;; () | 657 ;; () |
1150 (ediff-defvar-local ediff-temp-file-C nil | 1162 (ediff-defvar-local ediff-temp-file-C nil |
1151 "Temporary file used for refining difference regions in buffer C.") | 1163 "Temporary file used for refining difference regions in buffer C.") |
1152 | 1164 |
1153 ;;; In-line functions | 1165 ;;; In-line functions |
1154 | 1166 |
1155 (defsubst ediff-file-remote-p (file-name) | 1167 (or (fboundp 'ediff-file-remote-p) ; user supplied his own function: use it |
1156 (require 'ange-ftp) | 1168 (defun ediff-file-remote-p (file-name) |
1157 (car (if ediff-xemacs-p | 1169 (car (cond ((featurep 'efs-auto) (efs-ftp-path file-name)) |
1158 (ange-ftp-ftp-path file-name) | 1170 ((fboundp 'file-remote-p) (file-remote-p file-name)) |
1159 (ange-ftp-ftp-name file-name)))) | 1171 (t (require 'ange-ftp) |
1172 ;; Can happen only in Emacs, since XEmacs has file-remote-p | |
1173 (ange-ftp-ftp-name file-name)))))) | |
1160 | 1174 |
1161 | 1175 |
1162 (defsubst ediff-frame-unsplittable-p (frame) | 1176 (defsubst ediff-frame-unsplittable-p (frame) |
1163 (cdr (assq 'unsplittable (frame-parameters frame)))) | 1177 (cdr (assq 'unsplittable (frame-parameters frame)))) |
1164 | 1178 |
1171 | 1185 |
1172 (defsubst ediff-kill-buffer-carefully (buf) | 1186 (defsubst ediff-kill-buffer-carefully (buf) |
1173 "Kill buffer BUF if it exists." | 1187 "Kill buffer BUF if it exists." |
1174 (if (ediff-buffer-live-p buf) | 1188 (if (ediff-buffer-live-p buf) |
1175 (kill-buffer (get-buffer buf)))) | 1189 (kill-buffer (get-buffer buf)))) |
1190 | |
1191 (defsubst ediff-background-face (buf-type dif-num) | |
1192 ;; The value of dif-num is always 1- the one that user sees. | |
1193 ;; This is why even face is used when dif-num is odd. | |
1194 (intern (format (if (ediff-odd-p dif-num) | |
1195 "ediff-even-diff-face-%S" | |
1196 "ediff-odd-diff-face-%S") | |
1197 buf-type))) | |
1176 | 1198 |
1177 | 1199 |
1178 ;; activate faces on diff regions in buffer | 1200 ;; activate faces on diff regions in buffer |
1179 (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight) | 1201 (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight) |
1180 (let ((diff-vector | 1202 (let ((diff-vector |
1182 overl diff-num) | 1204 overl diff-num) |
1183 (mapcar (function | 1205 (mapcar (function |
1184 (lambda (rec) | 1206 (lambda (rec) |
1185 (setq overl (ediff-get-diff-overlay-from-diff-record rec) | 1207 (setq overl (ediff-get-diff-overlay-from-diff-record rec) |
1186 diff-num (ediff-overlay-get overl 'ediff-diff-num)) | 1208 diff-num (ediff-overlay-get overl 'ediff-diff-num)) |
1187 (ediff-set-overlay-face | 1209 (if (ediff-overlay-buffer overl) |
1188 overl | 1210 ;; only if overlay is alive |
1189 (if (not unhighlight) | 1211 (ediff-set-overlay-face |
1190 (ediff-background-face buf-type diff-num)) | 1212 overl |
1191 ))) | 1213 (if (not unhighlight) |
1214 (ediff-background-face buf-type diff-num)))) | |
1215 )) | |
1192 diff-vector))) | 1216 diff-vector))) |
1193 | 1217 |
1194 | 1218 |
1195 ;; activate faces on diff regions in all buffers | 1219 ;; activate faces on diff regions in all buffers |
1196 (defun ediff-paint-background-regions (&optional unhighlight) | 1220 (defun ediff-paint-background-regions (&optional unhighlight) |
1285 (ediff-unhighlight-diffs-totally-in-one-buffer 'B) | 1309 (ediff-unhighlight-diffs-totally-in-one-buffer 'B) |
1286 (ediff-unhighlight-diffs-totally-in-one-buffer 'C) | 1310 (ediff-unhighlight-diffs-totally-in-one-buffer 'C) |
1287 (ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor) | 1311 (ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor) |
1288 ) | 1312 ) |
1289 | 1313 |
1290 (defsubst ediff-background-face (buf-type dif-num) | |
1291 ;; The value of dif-num is always 1- the one that user sees. | |
1292 ;; This is why even face is used when dif-num is odd. | |
1293 (intern (format (if (ediff-odd-p dif-num) | |
1294 "ediff-even-diff-face-%S" | |
1295 "ediff-odd-diff-face-%S") | |
1296 buf-type))) | |
1297 | |
1298 | 1314 |
1299 ;; arg is a record for a given diff in a difference vector | 1315 ;; arg is a record for a given diff in a difference vector |
1300 ;; this record is itself a vector | 1316 ;; this record is itself a vector |
1301 (defsubst ediff-clear-fine-diff-vector (diff-record) | 1317 (defsubst ediff-clear-fine-diff-vector (diff-record) |
1302 (if diff-record | 1318 (if diff-record |
1416 (if ediff-xemacs-p | 1432 (if ediff-xemacs-p |
1417 (glyph-height ediff-H-glyph (selected-window frame)) | 1433 (glyph-height ediff-H-glyph (selected-window frame)) |
1418 (frame-char-height frame))) | 1434 (frame-char-height frame))) |
1419 | 1435 |
1420 ;; Some overlay functions | 1436 ;; Some overlay functions |
1437 | |
1438 (defsubst ediff-overlay-start (overl) | |
1439 (if (ediff-overlayp overl) | |
1440 (if ediff-emacs-p | |
1441 (overlay-start overl) | |
1442 (extent-start-position overl)))) | |
1443 | |
1444 (defsubst ediff-overlay-end (overl) | |
1445 (if (ediff-overlayp overl) | |
1446 (if ediff-emacs-p | |
1447 (overlay-end overl) | |
1448 (extent-end-position overl)))) | |
1421 | 1449 |
1422 (defsubst ediff-empty-overlay-p (overl) | 1450 (defsubst ediff-empty-overlay-p (overl) |
1423 (= (ediff-overlay-start overl) (ediff-overlay-end overl))) | 1451 (= (ediff-overlay-start overl) (ediff-overlay-end overl))) |
1424 | 1452 |
1425 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is | 1453 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is |
1581 (defsubst ediff-message-if-verbose (string &rest args) | 1609 (defsubst ediff-message-if-verbose (string &rest args) |
1582 (if ediff-verbose-p | 1610 (if ediff-verbose-p |
1583 (apply 'message string args))) | 1611 (apply 'message string args))) |
1584 | 1612 |
1585 (defun ediff-file-attributes (filename attr-number) | 1613 (defun ediff-file-attributes (filename attr-number) |
1586 (let ((handler (find-file-name-handler filename 'find-file-noselect))) | 1614 (if (ediff-file-remote-p filename) |
1587 (if (and handler (string-match "ange-ftp" (format "%S" handler))) | 1615 -1 |
1588 -1 | 1616 (nth attr-number (file-attributes filename)))) |
1589 (nth attr-number (file-attributes filename))))) | 1617 |
1590 (defsubst ediff-file-size (filename) | 1618 (defsubst ediff-file-size (filename) |
1591 (ediff-file-attributes filename 7)) | 1619 (ediff-file-attributes filename 7)) |
1592 (defsubst ediff-file-modtime (filename) | 1620 (defsubst ediff-file-modtime (filename) |
1593 (ediff-file-attributes filename 5)) | 1621 (ediff-file-attributes filename 5)) |
1594 | 1622 |
1595 | 1623 |
1596 (defun ediff-convert-standard-filename (fname) | 1624 (defun ediff-convert-standard-filename (fname) |
1597 (if ediff-emacs-p | 1625 (if (fboundp 'convert-standard-filename) |
1598 (convert-standard-filename fname) | 1626 (convert-standard-filename fname) |
1599 ;; hopefully, XEmacs adds this functionality | |
1600 fname)) | 1627 fname)) |
1601 | 1628 |
1602 | 1629 |
1603 ;;; Local Variables: | 1630 ;;; Local Variables: |
1604 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | 1631 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) |