Mercurial > emacs
comparison lisp/ediff-util.el @ 21940:f7e788ea680b
new version
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Mon, 04 May 1998 22:42:59 +0000 |
parents | f44ff2c52fac |
children | 3261e4a5f472 |
comparison
equal
deleted
inserted
replaced
21939:e9014d2166a4 | 21940:f7e788ea680b |
---|---|
50 (or (featurep 'ediff-merg) | 50 (or (featurep 'ediff-merg) |
51 (load "ediff-merg.el" nil nil 'nosuffix)) | 51 (load "ediff-merg.el" nil nil 'nosuffix)) |
52 (or (featurep 'ediff) | 52 (or (featurep 'ediff) |
53 (load "ediff.el" nil nil 'nosuffix)) | 53 (load "ediff.el" nil nil 'nosuffix)) |
54 (or (featurep 'ediff-tbar) | 54 (or (featurep 'ediff-tbar) |
55 ediff-emacs-p | |
55 (load "ediff-tbar.el" 'noerror nil 'nosuffix)) | 56 (load "ediff-tbar.el" 'noerror nil 'nosuffix)) |
56 )) | 57 )) |
57 ;; end pacifier | 58 ;; end pacifier |
59 | |
58 | 60 |
59 (require 'ediff-init) | 61 (require 'ediff-init) |
60 (require 'ediff-help) | 62 (require 'ediff-help) |
61 (require 'ediff-mult) | 63 (require 'ediff-mult) |
62 (require 'ediff-wind) | 64 (require 'ediff-wind) |
63 (require 'ediff-diff) | 65 (require 'ediff-diff) |
64 (require 'ediff-merg) | 66 (require 'ediff-merg) |
65 | 67 |
66 | |
67 ;; be careful with ediff-tbar | |
68 (if ediff-xemacs-p | 68 (if ediff-xemacs-p |
69 (condition-case nil | 69 (require 'ediff-tbar)) |
70 (require 'ediff-tbar) | |
71 (error | |
72 (defun ediff-use-toolbar-p () nil))) | |
73 (defun ediff-use-toolbar-p () nil)) | |
74 | 70 |
75 | 71 |
76 ;;; Functions | 72 ;;; Functions |
77 | 73 |
78 (defun ediff-mode () | 74 (defun ediff-mode () |
1051 (ediff-abbreviate-file-name file) (beep 1))) | 1047 (ediff-abbreviate-file-name file) (beep 1))) |
1052 )))) | 1048 )))) |
1053 | 1049 |
1054 ;; checkout if visited file is checked in | 1050 ;; checkout if visited file is checked in |
1055 (defun ediff-maybe-checkout (buf) | 1051 (defun ediff-maybe-checkout (buf) |
1056 (let ((file (buffer-file-name buf)) | 1052 (let ((file (expand-file-name (buffer-file-name buf))) |
1057 (checkout-function (key-binding "\C-x\C-q"))) | 1053 (checkout-function (key-binding "\C-x\C-q"))) |
1058 (if (and (ediff-file-checked-in-p file) | 1054 (if (and (ediff-file-checked-in-p file) |
1059 (or (beep 1) t) | 1055 (or (beep 1) t) |
1060 (y-or-n-p | 1056 (y-or-n-p |
1061 (format | 1057 (format |
1068 ;; This is a simple-minded check for whether a file is under version control. | 1064 ;; This is a simple-minded check for whether a file is under version control. |
1069 ;; If file,v exists but file doesn't, this file is considered to be not checked | 1065 ;; If file,v exists but file doesn't, this file is considered to be not checked |
1070 ;; in and not checked out for the purpose of patching (since patch won't be | 1066 ;; in and not checked out for the purpose of patching (since patch won't be |
1071 ;; able to read such a file anyway). | 1067 ;; able to read such a file anyway). |
1072 ;; FILE is a string representing file name | 1068 ;; FILE is a string representing file name |
1073 (defun ediff-file-under-version-control (file) | 1069 ;;(defun ediff-file-under-version-control (file) |
1074 (let* ((filedir (file-name-directory file)) | 1070 ;; (let* ((filedir (file-name-directory file)) |
1075 (file-nondir (file-name-nondirectory file)) | 1071 ;; (file-nondir (file-name-nondirectory file)) |
1076 (trial (concat file-nondir ",v")) | 1072 ;; (trial (concat file-nondir ",v")) |
1077 (full-trial (concat filedir trial)) | 1073 ;; (full-trial (concat filedir trial)) |
1078 (full-rcs-trial (concat filedir "RCS/" trial))) | 1074 ;; (full-rcs-trial (concat filedir "RCS/" trial))) |
1079 (and (stringp file) | 1075 ;; (and (stringp file) |
1080 (file-exists-p file) | 1076 ;; (file-exists-p file) |
1081 (or | 1077 ;; (or |
1082 (and | 1078 ;; (and |
1083 (file-exists-p full-trial) | 1079 ;; (file-exists-p full-trial) |
1084 ;; in FAT FS, `file,v' and `file' may turn out to be the same! | 1080 ;; ;; in FAT FS, `file,v' and `file' may turn out to be the same! |
1085 ;; don't be fooled by this! | 1081 ;; ;; don't be fooled by this! |
1086 (not (equal (file-attributes file) | 1082 ;; (not (equal (file-attributes file) |
1087 (file-attributes full-trial)))) | 1083 ;; (file-attributes full-trial)))) |
1088 ;; check if a version is in RCS/ directory | 1084 ;; ;; check if a version is in RCS/ directory |
1089 (file-exists-p full-rcs-trial))) | 1085 ;; (file-exists-p full-rcs-trial))) |
1090 )) | 1086 ;; )) |
1091 | 1087 |
1092 (defun ediff-file-checked-out-p (file) | 1088 |
1093 (and (ediff-file-under-version-control file) | 1089 (defsubst ediff-file-checked-out-p (file) |
1094 (file-writable-p file))) | 1090 (or (not (featurep 'vc-hooks)) |
1095 (defun ediff-file-checked-in-p (file) | 1091 (and (vc-backend file) |
1096 (and (ediff-file-under-version-control file) | 1092 (vc-locking-user file)))) |
1097 (not (file-writable-p file)))) | 1093 (defsubst ediff-file-checked-in-p (file) |
1094 (and (featurep 'vc-hooks) | |
1095 (vc-backend file) | |
1096 (not (vc-locking-user file)))) | |
1097 | |
1098 (defun ediff-file-compressed-p (file) | |
1099 (condition-case nil | |
1100 (require 'jka-compr) | |
1101 (error)) | |
1102 (if (featurep 'jka-compr) | |
1103 (string-match (jka-compr-build-file-regexp) file))) | |
1104 | |
1098 | 1105 |
1099 (defun ediff-swap-buffers () | 1106 (defun ediff-swap-buffers () |
1100 "Rotate the display of buffers A, B, and C." | 1107 "Rotate the display of buffers A, B, and C." |
1101 (interactive) | 1108 (interactive) |
1102 (ediff-barf-if-not-control-buffer) | 1109 (ediff-barf-if-not-control-buffer) |
1310 (list frame (if (ediff-3way-comparison-job) | 1317 (list frame (if (ediff-3way-comparison-job) |
1311 ediff-toolbar-3way ediff-toolbar))) | 1318 ediff-toolbar-3way ediff-toolbar))) |
1312 (set-specifier bottom-toolbar-visible-p (list frame t)) | 1319 (set-specifier bottom-toolbar-visible-p (list frame t)) |
1313 (set-specifier bottom-toolbar-height | 1320 (set-specifier bottom-toolbar-height |
1314 (list frame ediff-toolbar-height))) | 1321 (list frame ediff-toolbar-height))) |
1315 (ediff-xemacs-p | 1322 ((ediff-has-toolbar-support-p) |
1316 (set-specifier bottom-toolbar-height (list frame 0))) | 1323 (set-specifier bottom-toolbar-height (list frame 0))) |
1317 )) | 1324 )) |
1318 )) | 1325 )) |
1319 | 1326 |
1320 ;; Merging | 1327 ;; Merging |
1570 (setq lines (count-lines beg end)) | 1577 (setq lines (count-lines beg end)) |
1571 (setq lines 0)) | 1578 (setq lines 0)) |
1572 lines | 1579 lines |
1573 )))) | 1580 )))) |
1574 | 1581 |
1575 ;; get number of lines from window end to region start | 1582 ;; Calculate the number of lines from window end to the start of diff region |
1576 (defun ediff-get-lines-to-region-start (buf-type &optional n ctl-buf) | 1583 (defun ediff-get-lines-to-region-start (buf-type &optional diff-num ctl-buf) |
1577 (or n (setq n ediff-current-difference)) | 1584 (or diff-num (setq diff-num ediff-current-difference)) |
1578 (or ctl-buf (setq ctl-buf ediff-control-buffer)) | 1585 (or ctl-buf (setq ctl-buf ediff-control-buffer)) |
1579 (ediff-with-current-buffer ctl-buf | 1586 (ediff-with-current-buffer ctl-buf |
1580 (let* ((buf (ediff-get-buffer buf-type)) | 1587 (let* ((buf (ediff-get-buffer buf-type)) |
1581 (wind (eval (ediff-get-symbol-from-alist | 1588 (wind (eval (ediff-get-symbol-from-alist |
1582 buf-type ediff-window-alist))) | 1589 buf-type ediff-window-alist))) |
1583 (end (window-end wind)) | 1590 (end (or (window-end wind) (window-end wind t))) |
1584 (beg (ediff-get-diff-posn buf-type 'beg))) | 1591 (beg (ediff-get-diff-posn buf-type 'beg diff-num))) |
1585 (ediff-with-current-buffer buf | 1592 (ediff-with-current-buffer buf |
1586 (if (< beg end) (count-lines beg end) 0)) | 1593 (if (< beg end) |
1594 (count-lines (max beg (point-min)) (min end (point-max))) 0)) | |
1587 ))) | 1595 ))) |
1588 | 1596 |
1589 | 1597 |
1590 ;; region size coefficient is a coefficient by which to adjust scrolling | 1598 ;; region size coefficient is a coefficient by which to adjust scrolling |
1591 ;; up/down of the window displaying buffer of type BUFTYPE. | 1599 ;; up/down of the window displaying buffer of type BUFTYPE. |
2972 (erase-buffer)) | 2980 (erase-buffer)) |
2973 (revert-buffer t t)) | 2981 (revert-buffer t t)) |
2974 (error "Buffer out of sync for file %s" buffer-file-name)))) | 2982 (error "Buffer out of sync for file %s" buffer-file-name)))) |
2975 | 2983 |
2976 | 2984 |
2977 (defun ediff-file-compressed-p (file) | |
2978 (require 'jka-compr) | |
2979 (string-match (jka-compr-build-file-regexp) file)) | |
2980 | |
2981 (defun ediff-filename-magic-p (file) | 2985 (defun ediff-filename-magic-p (file) |
2982 (or (ediff-file-compressed-p file) | 2986 (or (ediff-file-compressed-p file) |
2983 (ediff-file-remote-p file))) | 2987 (ediff-file-remote-p file))) |
2984 | 2988 |
2985 | 2989 |