]> code.delx.au - gnu-emacs/blobdiff - lisp/ediff-util.el
(proced-mode): Redefine as just the major-mode.
[gnu-emacs] / lisp / ediff-util.el
index 7497cd3745fa84cb9ae26ec99e01fb6542dd4b4b..120228cca846ec0822f32415f88343d044c2150e 100644 (file)
@@ -27,6 +27,8 @@
 ;;; Code:
 
 
+(provide 'ediff-util)
+
 ;; Compiler pacifier
 (defvar ediff-patch-diagnostics)
 (defvar ediff-patchbufer)
   (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
 
 (eval-when-compile
-  (let ((load-path (cons (expand-file-name ".") load-path)))
-    (provide 'ediff-util) ; to break recursive load cycle
-    (or (featurep 'ediff-init)
-       (load "ediff-init.el" nil t 'nosuffix))
-    (or (featurep 'ediff-help)
-       (load "ediff-help.el" nil t 'nosuffix))
-    (or (featurep 'ediff-mult)
-       (load "ediff-mult.el" nil t 'nosuffix))
-    (or (featurep 'ediff-wind)
-       (load "ediff-wind.el" nil t 'nosuffix))
-    (or (featurep 'ediff-diff)
-       (load "ediff-diff.el" nil t 'nosuffix))
-    (or (featurep 'ediff-merg)
-       (load "ediff-merg.el" nil t 'nosuffix))
-    (or (featurep 'ediff)
-       (load "ediff.el" nil t 'nosuffix))
-    (or (featurep 'ediff-tbar)
-       (featurep 'emacs)
-       (load "ediff-tbar.el" 'noerror nil 'nosuffix))
-    ))
+  (require 'ediff-init)
+  (require 'ediff-help)
+  (if (not (featurep 'ediff-mult))
+      (require 'ediff-mult))
+  (require 'ediff-mult)
+  (require 'ediff-wind)
+  (if (not (featurep 'ediff-diff))
+      (require 'ediff-diff))
+  (require 'ediff-merg)
+  (require 'ediff)
+  ;; for compatibility with current stable version of xemacs
+  (if (featurep 'xemacs)
+      (require 'ediff-tbar))
+  )
 ;; end pacifier
 
 
@@ -75,6 +71,7 @@
 (require 'ediff-diff)
 (require 'ediff-merg)
 
+;; for compatibility with current stable version of xemacs
 (if (featurep 'xemacs)
     (require 'ediff-tbar))
 
@@ -306,10 +303,11 @@ to invocation.")
       (make-local-variable 'ediff-window-setup-function)
       (make-local-variable 'ediff-keep-variants)
 
-      (ediff-cond-compile-for-xemacs-or-emacs
-       (make-local-hook 'ediff-after-quit-hook-internal) ; xemacs form
-       nil ; emacs form
-       )
+      (make-local-variable 'window-min-height)
+      (setq window-min-height 2)
+
+      (if (featurep 'xemacs)
+         (make-local-hook 'ediff-after-quit-hook-internal))
 
       ;; unwrap set up parameters passed as argument
       (while setup-parameters
@@ -332,10 +330,8 @@ to invocation.")
       (if (string-match "buffer" (symbol-name ediff-job-name))
          (setq ediff-keep-variants t))
 
-      (ediff-cond-compile-for-xemacs-or-emacs
-       (make-local-hook 'pre-command-hook) ; xemacs form
-       nil                                 ; emacs form
-       )
+      (if (featurep 'xemacs)
+         (make-local-hook 'pre-command-hook))
 
       (if (ediff-window-display-p)
          (add-hook 'pre-command-hook 'ediff-spy-after-mouse nil 'local))
@@ -585,6 +581,7 @@ to invocation.")
                  (ediff-multiframe-setup-p)
                  ediff-wide-display-p))
 
+    (set-window-dedicated-p (selected-window) t)
     ;; In multiframe, toolbar is set in ediff-setup-control-frame
     (if (not (ediff-multiframe-setup-p))
        (ediff-make-bottom-toolbar)) ; this checks if toolbar is requested
@@ -1309,11 +1306,21 @@ which see."
               (if (featurep 'emacs) "" "X")))
 
   (cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe)
+        (setq ediff-multiframe nil)
         (setq window-setup-func 'ediff-setup-windows-plain))
        ((eq ediff-window-setup-function 'ediff-setup-windows-plain)
         (if (ediff-in-control-buffer-p)
             (ediff-kill-bottom-toolbar))
-        (setq window-setup-func 'ediff-setup-windows-multiframe)))
+        (if (ediff-buffer-live-p ediff-control-buffer)
+            (set-window-dedicated-p ediff-control-window nil))
+        (setq ediff-multiframe t)
+        (setq window-setup-func 'ediff-setup-windows-multiframe))
+       (t
+        (if (ediff-buffer-live-p ediff-control-buffer)
+            (set-window-dedicated-p ediff-control-window nil))
+        (setq ediff-multiframe t)
+        (setq window-setup-func 'ediff-setup-windows-multiframe))
+       )
 
   ;; change default
   (setq-default ediff-window-setup-function window-setup-func)
@@ -1360,43 +1367,28 @@ To change the default, set the variable `ediff-use-toolbar-p', which see."
   ;; The problem with this is that any previous bottom-toolbar
   ;; will not re-appear after our cleanup here.  Is there a way
   ;; to do "push" and "pop" toolbars ?  --marcpa
-  (if (ediff-use-toolbar-p)
-      (ediff-cond-compile-for-xemacs-or-emacs
-       (progn ; xemacs
-        (set-specifier bottom-toolbar (list (selected-frame) nil))
-        (set-specifier bottom-toolbar-visible-p (list (selected-frame) nil)))
-       nil  ; emacs
-       )
-    ))
+  (if (featurep 'xemacs)
+      (when (ediff-use-toolbar-p)
+       (set-specifier bottom-toolbar (list (selected-frame) nil))
+       (set-specifier bottom-toolbar-visible-p (list (selected-frame) nil)))))
 
 ;; If wants to use toolbar, make it.
 ;; If not, zero the toolbar for XEmacs.
 ;; Do nothing for Emacs.
 (defun ediff-make-bottom-toolbar (&optional frame)
-  (if (ediff-window-display-p)
-      (progn
-       (setq frame (or frame (selected-frame)))
+  (when (ediff-window-display-p)
+    (setq frame (or frame (selected-frame)))
+    (if (featurep 'xemacs)
        (cond ((ediff-use-toolbar-p) ; this checks for XEmacs
-              (ediff-cond-compile-for-xemacs-or-emacs
-               (progn ; xemacs
-                 (set-specifier
-                  bottom-toolbar
-                  (list frame (if (ediff-3way-comparison-job)
-                                  ediff-toolbar-3way ediff-toolbar)))
-                 (set-specifier bottom-toolbar-visible-p (list frame t))
-                 (set-specifier bottom-toolbar-height
-                                (list frame ediff-toolbar-height)))
-               nil ; emacs
-               )
-              )
+              (set-specifier
+               bottom-toolbar
+               (list frame (if (ediff-3way-comparison-job)
+                               ediff-toolbar-3way ediff-toolbar)))
+              (set-specifier bottom-toolbar-visible-p (list frame t))
+              (set-specifier bottom-toolbar-height
+                             (list frame ediff-toolbar-height)))
              ((ediff-has-toolbar-support-p)
-              (ediff-cond-compile-for-xemacs-or-emacs
-               (set-specifier bottom-toolbar-height (list frame 0)) ; xemacs
-               nil                                                  ; emacs
-               )
-              )
-             ))
-    ))
+              (set-specifier bottom-toolbar-height (list frame 0)))))))
 
 ;; Merging
 
@@ -3408,15 +3400,13 @@ Without an argument, it saves customized diff argument, if available
 (defun ediff-make-cloned-buffer (buff region-name)
   (ediff-make-indirect-buffer
    buff (generate-new-buffer-name
-         (concat (if (stringp buff) buff (buffer-name buff)) region-name))
-   ))
+         (concat (if (stringp buff) buff (buffer-name buff)) region-name))))
 
 
 (defun ediff-make-indirect-buffer (base-buf indirect-buf-name)
-  (ediff-cond-compile-for-xemacs-or-emacs
-   (make-indirect-buffer base-buf indirect-buf-name) ; xemacs
-   (make-indirect-buffer base-buf indirect-buf-name 'clone) ; emacs
-   ))
+  (if (featurep 'xemacs)
+      (make-indirect-buffer base-buf indirect-buf-name)
+    (make-indirect-buffer base-buf indirect-buf-name 'clone)))
 
 
 ;; This function operates only from an ediff control buffer
@@ -3427,13 +3417,11 @@ Without an argument, it saves customized diff argument, if available
     (unless (and buf-A-file-name
                 (file-exists-p buf-A-file-name)
                 (not (ediff-file-remote-p buf-A-file-name)))
-      (setq file-A
-           (ediff-make-temp-file ediff-buffer-A)))
+      (setq file-A (ediff-make-temp-file ediff-buffer-A)))
     (unless (and buf-B-file-name
                 (file-exists-p buf-B-file-name)
                 (not (ediff-file-remote-p buf-B-file-name)))
-      (setq file-B
-           (ediff-make-temp-file ediff-buffer-B)))
+      (setq file-B (ediff-make-temp-file ediff-buffer-B)))
     (or (ediff-buffer-live-p ediff-custom-diff-buffer)
        (setq ediff-custom-diff-buffer
              (get-buffer-create
@@ -3445,14 +3433,16 @@ Without an argument, it saves customized diff argument, if available
      ediff-custom-diff-program ediff-custom-diff-buffer 'synchronize
      ediff-custom-diff-options
      ;; repetition of buf-A-file-name is needed so it'll return a file
-     (or file-A buf-A-file-name)
-     (or file-B buf-B-file-name))
+     (or (and buf-A-file-name (file-exists-p buf-A-file-name) buf-A-file-name)
+        file-A)
+     (or (and buf-B-file-name (file-exists-p buf-B-file-name) buf-B-file-name)
+        file-B))
     ;; put the diff file in diff-mode, if it is available
     (if (fboundp 'diff-mode)
        (with-current-buffer ediff-custom-diff-buffer
          (diff-mode)))
-    (and file-A (delete-file file-A))
-    (and file-B (delete-file file-B))
+    (and file-A (file-exists-p file-A) (delete-file file-A))
+    (and file-B (file-exists-p file-B) (delete-file file-B))
     ))
 
 (defun ediff-show-diff-output (arg)
@@ -3787,21 +3777,19 @@ Ediff Control Panel to restore highlighting."
          (or (number-or-marker-p end)
              (setq end (eval end)))
          (setq overl
-               (ediff-cond-compile-for-xemacs-or-emacs
-                (make-extent beg end buff)                     ; xemacs
-                ;; advance front and rear of the overlay
-                (make-overlay beg end buff nil 'rear-advance)  ; emacs
-                ))
+               (if (featurep 'xemacs)
+                   (make-extent beg end buff)
+                 ;; advance front and rear of the overlay
+                 (make-overlay beg end buff nil 'rear-advance)))
 
          ;; never detach
          (ediff-overlay-put
           overl (if (featurep 'emacs) 'evaporate 'detachable) nil)
          ;; make overlay open-ended
          ;; In emacs, it is made open ended at creation time
-         (if (featurep 'xemacs)
-             (progn
-               (ediff-overlay-put overl 'start-open nil)
-               (ediff-overlay-put overl 'end-open nil)))
+         (when (featurep 'xemacs)
+           (ediff-overlay-put overl 'start-open nil)
+           (ediff-overlay-put overl 'end-open nil))
          (ediff-overlay-put overl 'ediff-diff-num 0)
          overl))))
 
@@ -4065,19 +4053,15 @@ Mail anyway? (y or n) ")
 
 
 (defun ediff-deactivate-mark ()
-  (ediff-cond-compile-for-xemacs-or-emacs
-   (zmacs-deactivate-region) ; xemacs
-   (deactivate-mark) ; emacs
-   ))
+  (if (featurep 'xemacs)
+      (zmacs-deactivate-region)
+    (deactivate-mark)))
+
 (defun ediff-activate-mark ()
-  (ediff-cond-compile-for-xemacs-or-emacs
-   (zmacs-activate-region) ; xemacs
-   (progn
-     (make-local-variable 'transient-mark-mode)
-     (setq mark-active t
-          transient-mark-mode t) ; emacs
-     )
-   ))
+  (if (featurep 'xemacs)
+      (zmacs-activate-region)
+    (make-local-variable 'transient-mark-mode)
+    (setq mark-active t transient-mark-mode t)))
 
 (defun ediff-nuke-selective-display ()
   (if (featurep 'xemacs)
@@ -4187,10 +4171,8 @@ Mail anyway? (y or n) ")
   (interactive)
   (ediff-barf-if-not-control-buffer)
 
-  (ediff-cond-compile-for-xemacs-or-emacs
-   (make-local-hook 'post-command-hook) ; xemacs form
-   nil                                  ; emacs form
-   )
+  (if (featurep 'xemacs)
+      (make-local-hook 'post-command-hook))
 
   (let ((pre-hook 'pre-command-hook)
        (post-hook 'post-command-hook))
@@ -4308,8 +4290,6 @@ Mail anyway? (y or n) ")
 
 (run-hooks 'ediff-load-hook)
 
-(provide 'ediff-util)
-
 
 ;; Local Variables:
 ;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)