From 7dab52dfbce9c39a77524376a53e8d65b3e470a3 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 7 Aug 2022 19:21:09 +0200 Subject: [PATCH] Minor cleanups in ediff-*.el * lisp/vc/ediff-init.el (ediff-window-visible-p): (ediff-nonempty-string-p): Simplify. (stipple-pixmap): Don't try XEmacs specific(?) variable. (ediff-frame-unsplittable-p): Make obsolete. Update callers. (ediff-has-gutter-support-p): Redefine as obsolete function alias for 'ignore'. (ediff-mouse-event-p): Redefine as obsolete function alias for 'mouse-event-p'. Update callers. * lisp/vc/ediff-util.el (ediff-submit-report): Simplify. (ediff-filename-magic-p): Make obsolete. Update callers. (ediff-activate-mark): Make obsolete. Update callers. * lisp/vc/ediff-help.el: * lisp/vc/ediff-hook.el: * lisp/vc/ediff-util.el: * lisp/vc/ediff-wind.el: Remove superfluous defvars. --- lisp/vc/ediff-help.el | 4 --- lisp/vc/ediff-hook.el | 8 ------ lisp/vc/ediff-init.el | 64 ++++++++++++------------------------------- lisp/vc/ediff-ptch.el | 2 -- lisp/vc/ediff-util.el | 51 +++++++--------------------------- lisp/vc/ediff-wind.el | 24 ++++------------ lisp/vc/ediff.el | 5 ++-- 7 files changed, 35 insertions(+), 123 deletions(-) diff --git a/lisp/vc/ediff-help.el b/lisp/vc/ediff-help.el index 42fbde21659..e2d93d2b31b 100644 --- a/lisp/vc/ediff-help.el +++ b/lisp/vc/ediff-help.el @@ -24,10 +24,6 @@ ;;; Code: -;; Compiler pacifier start -(defvar ediff-multiframe) -;; end pacifier - (require 'ediff-init) (defvar ediff-multiframe) diff --git a/lisp/vc/ediff-hook.el b/lisp/vc/ediff-hook.el index 0160d9f6848..d1eff0151a8 100644 --- a/lisp/vc/ediff-hook.el +++ b/lisp/vc/ediff-hook.el @@ -35,16 +35,8 @@ ;; (define-key menu-bar-tools-menu [ediff] ;; '("Compare" . menu-bar-ediff-menu)) -;; Compiler pacifier -(defvar ediff-menu) -(defvar ediff-merge-menu) -(defvar epatch-menu) -(defvar ediff-misc-menu) -;; end pacifier - ;; allow menus to be set up without ediff-wind.el being loaded -;; Emacs ;; initialize menu bar keymaps (defvar menu-bar-ediff-misc-menu (make-sparse-keymap "Ediff Miscellanea")) diff --git a/lisp/vc/ediff-init.el b/lisp/vc/ediff-init.el index 29f24436e1c..a3e77200ddf 100644 --- a/lisp/vc/ediff-init.el +++ b/lisp/vc/ediff-init.el @@ -27,17 +27,13 @@ (require 'cl-lib) (require 'ediff-util) -;; Start compiler pacifier (defvar ediff-metajob-name) (defvar ediff-meta-buffer) (defvar ediff-grab-mouse) (defvar ediff-mouse-pixel-position) (defvar ediff-mouse-pixel-threshold) -(defvar ediff-whitespace) (defvar ediff-multiframe) (defvar ediff-use-toolbar-p) -(defvar mswindowsx-bitmap-file-path) -;; end pacifier (defvar ediff-force-faces nil "If t, Ediff will think that it is running on a display that supports faces. @@ -59,11 +55,6 @@ that Ediff doesn't know about.") (defun ediff-has-toolbar-support-p () nil) - -(defun ediff-has-gutter-support-p () - (declare (obsolete nil "27.1")) - nil) - (defun ediff-use-toolbar-p () (and (ediff-has-toolbar-support-p) ;Can it do it ? (boundp 'ediff-use-toolbar-p) @@ -717,18 +708,6 @@ Ediff needs to find fine differences." :type 'symbol :group 'ediff) - -(define-obsolete-function-alias 'ediff-read-event #'read-event "27.1") - -(define-obsolete-function-alias 'ediff-overlayp #'overlayp "27.1") - -(define-obsolete-function-alias 'ediff-make-overlay #'make-overlay "27.1") - -(define-obsolete-function-alias 'ediff-delete-overlay #'delete-overlay "27.1") - -(define-obsolete-function-alias 'ediff-color-display-p #'display-color-p "27.1") - - ;; A var local to each control panel buffer. Indicates highlighting style ;; in effect for this buffer: `face', `ascii', ;; `off' -- turned off (on a dumb terminal only). @@ -967,8 +946,6 @@ this variable represents.") (cond ((not (ediff-has-face-support-p)) nil) ((and (boundp 'x-bitmap-file-path) (locate-library "stipple" t x-bitmap-file-path)) "stipple") - ((and (boundp 'mswindowsx-bitmap-file-path) - (locate-library "stipple" t mswindowsx-bitmap-file-path)) "stipple") (t "Stipple"))) (defface ediff-even-diff-A @@ -1275,6 +1252,7 @@ This default should work without changes." (defsubst ediff-frame-unsplittable-p (frame) + (declare (obsolete nil "29.1")) (cdr (assq 'unsplittable (frame-parameters frame)))) (defsubst ediff-get-next-window (wind prev-wind) @@ -1349,29 +1327,23 @@ This default should work without changes." (ediff-clear-fine-differences-in-one-buffer n 'C))) -(defsubst ediff-mouse-event-p (event) - (string-match "mouse" (format "%S" (event-basic-type event)))) - - (defsubst ediff-key-press-event-p (event) (or (char-or-string-p event) (symbolp event))) (defun ediff-event-point (event) - (cond ((ediff-mouse-event-p event) + (cond ((mouse-event-p event) (posn-point (event-start event))) ((ediff-key-press-event-p event) (point)) (t (error "Error")))) (defun ediff-event-buffer (event) - (cond ((ediff-mouse-event-p event) + (cond ((mouse-event-p event) (window-buffer (posn-window (event-start event)))) ((ediff-key-press-event-p event) (current-buffer)) (t (error "Error")))) -(define-obsolete-function-alias 'ediff-event-key #'identity "27.1") - (defun ediff-last-command-char () (declare (obsolete last-command-event "27.1")) last-command-event) @@ -1383,14 +1355,8 @@ This default should work without changes." (eq (frame-visible-p frame) 'icon))) (defsubst ediff-window-visible-p (wind) - ;; under TTY, window-live-p also means window is visible (and (window-live-p wind) - (or (not (display-graphic-p)) - (frame-visible-p (window-frame wind))))) - - -(define-obsolete-function-alias 'ediff-frame-char-width - #'frame-char-width "27.1") + (frame-visible-p (window-frame wind)))) (defun ediff-reset-mouse (&optional frame do-not-grab-mouse) (or frame (setq frame (selected-frame))) @@ -1433,8 +1399,6 @@ This default should work without changes." ediff-mouse-pixel-threshold)))) (t nil))))) -(define-obsolete-function-alias 'ediff-frame-char-height - #'frame-char-height "27.1") ;; Some overlay functions @@ -1449,12 +1413,6 @@ This default should work without changes." (defsubst ediff-empty-overlay-p (overl) (= (ediff-overlay-start overl) (ediff-overlay-end overl))) -(define-obsolete-function-alias 'ediff-overlay-buffer - #'overlay-buffer "27.1") - -(define-obsolete-function-alias 'ediff-overlay-get #'overlay-get "27.1") - - (defun ediff-move-overlay (overlay beg end &optional buffer) "If OVERLAY's buffer exists, call `move-overlay'." (let ((buf (and overlay (overlay-buffer overlay)))) @@ -1493,7 +1451,7 @@ This default should work without changes." (ediff-abbreviate-file-name (file-name-directory dir)))) (defsubst ediff-nonempty-string-p (string) - (and (stringp string) (not (string= string "")))) + (and (stringp string) (string-empty-p string))) (defun ediff-abbrev-jobname (jobname) (cond ((eq jobname 'ediff-directories) @@ -1554,11 +1512,23 @@ This default should work without changes." (ediff-file-attributes filename 5)) +(define-obsolete-function-alias 'ediff-has-gutter-support-p #'ignore "27.1") +(define-obsolete-function-alias 'ediff-event-key #'identity "27.1") +(define-obsolete-function-alias 'ediff-frame-char-width #'frame-char-width "27.1") +(define-obsolete-function-alias 'ediff-frame-char-height #'frame-char-height "27.1") +(define-obsolete-function-alias 'ediff-overlay-buffer #'overlay-buffer "27.1") +(define-obsolete-function-alias 'ediff-overlay-get #'overlay-get "27.1") +(define-obsolete-function-alias 'ediff-read-event #'read-event "27.1") +(define-obsolete-function-alias 'ediff-overlayp #'overlayp "27.1") +(define-obsolete-function-alias 'ediff-make-overlay #'make-overlay "27.1") +(define-obsolete-function-alias 'ediff-delete-overlay #'delete-overlay "27.1") +(define-obsolete-function-alias 'ediff-color-display-p #'display-color-p "27.1") (define-obsolete-function-alias 'ediff-with-syntax-table #'with-syntax-table "27.1") (define-obsolete-function-alias 'ediff-convert-standard-filename #'convert-standard-filename "28.1") (define-obsolete-function-alias 'ediff-hide-face #'ignore "28.1") (define-obsolete-function-alias 'ediff-file-remote-p #'file-remote-p "29.1") (define-obsolete-function-alias 'ediff-window-display-p #'display-graphic-p "29.1") +(define-obsolete-function-alias 'ediff-mouse-event-p #'mouse-event-p "29.1") (provide 'ediff-init) ;;; ediff-init.el ends here diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el index 94a890d95d5..4d471e21b4c 100644 --- a/lisp/vc/ediff-ptch.el +++ b/lisp/vc/ediff-ptch.el @@ -24,10 +24,8 @@ ;;; Code: - (require 'diff-mode) ; For `diff-file-junk-re'. - (defgroup ediff-ptch nil "Ediff patch support." :tag "Patch" diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el index e8510acfb19..0d96a195ade 100644 --- a/lisp/vc/ediff-util.el +++ b/lisp/vc/ediff-util.el @@ -24,24 +24,11 @@ ;;; Code: - (provide 'ediff-util) ;FIXME: Break cyclic dependencies and move to the end! -;; Compiler pacifier (defvar ediff-use-toolbar-p) -(defvar ediff-toolbar-height) -(defvar ediff-toolbar) -(defvar ediff-toolbar-3way) -(defvar bottom-toolbar) -(defvar bottom-toolbar-visible-p) -(defvar bottom-toolbar-height) -(defvar mark-active) - (defvar ediff-after-quit-hook-internal nil) -;; end pacifier - - (require 'ediff-init) (require 'ediff-help) (require 'ediff-mult) @@ -1337,10 +1324,6 @@ To change the default, set the variable `ediff-use-toolbar-p', which see." (if (ediff-in-control-buffer-p) (ediff-recenter 'no-rehighlight))))) - -(define-obsolete-function-alias 'ediff-kill-bottom-toolbar #'ignore "27.1") -(define-obsolete-function-alias 'ediff-make-bottom-toolbar #'ignore "27.1") - ;; Merging (defun ediff-toggle-show-clashes-only () @@ -3082,10 +3065,6 @@ Hit \\[ediff-recenter] to reset the windows afterward." ) -;; for compatibility -(define-obsolete-function-alias 'ediff-minibuffer-with-setup-hook - #'minibuffer-with-setup-hook "28.1") - ;; This is adapted from a similar function in `emerge.el'. ;; PROMPT should not have a trailing ': ', so that it can be modified ;; according to context. @@ -3202,16 +3181,6 @@ Hit \\[ediff-recenter] to reset the windows afterward." file)) -;; Quote metacharacters (using \) when executing diff in Unix. -;;(defun ediff-protect-metachars (str) -;; (let ((limit 0)) -;; (while (string-match ediff-metachars str limit) -;; (setq str (concat (substring str 0 (match-beginning 0)) -;; "\\" -;; (substring str (match-beginning 0)))) -;; (setq limit (1+ (match-end 0))))) -;; str) - ;; Make sure the current buffer (for a file) has the same contents as the ;; file on disk, and attempt to remedy the situation if not. ;; Signal an error if we can't make them the same, or the user doesn't want @@ -3272,6 +3241,7 @@ Hit \\[ediff-recenter] to reset the windows afterward." (defun ediff-filename-magic-p (file) + (declare (obsolete nil "29.1")) (or (ediff-file-compressed-p file) (file-remote-p file))) @@ -3320,7 +3290,8 @@ Without an argument, it saves customized diff argument, if available (select-window wind) (delete-other-windows) (or (mark) (push-mark)) - (ediff-activate-mark) + (setq mark-active 'ediff-util) + (setq-local transient-mark-mode t) (split-window-vertically) (ediff-select-lowest-window) (setq other-wind (selected-window)) @@ -3899,11 +3870,9 @@ Ediff Control Panel to restore highlighting." "Submit bug report on Ediff." (interactive) (ediff-barf-if-not-control-buffer) - (defvar ediff-device-type) (defvar ediff-buffer-name) (let ((reporter-prompt-for-summary-p t) (ctl-buf ediff-control-buffer) - (ediff-device-type window-system) varlist salutation ediff-buffer-name) (setq varlist '(ediff-diff-program ediff-diff-options ediff-diff3-program ediff-diff3-options @@ -3922,8 +3891,7 @@ Ediff Control Panel to restore highlighting." ediff-job-name ediff-word-mode ediff-buffer-name - ediff-device-type - )) + window-system)) (setq salutation " Congratulations! You may have unearthed a bug in Ediff! @@ -4009,15 +3977,11 @@ Mail anyway? (y or n) ") (syntax-table)))) ) - -(define-obsolete-function-alias 'ediff-deactivate-mark #'deactivate-mark "27.1") - (defun ediff-activate-mark () + (declare (obsolete nil "29.1")) (setq mark-active 'ediff-util) (setq-local transient-mark-mode t)) -(define-obsolete-function-alias 'ediff-nuke-selective-display #'ignore "27.1") - ;; The next two are modified versions from emerge.el. ;; VARS must be a list of symbols ;; ediff-save-variables returns an association list: ((var . val) ...) @@ -4169,7 +4133,12 @@ Mail anyway? (y or n) ") (key-description desc) (format "M-x %s" func-def)))) +(define-obsolete-function-alias 'ediff-kill-bottom-toolbar #'ignore "27.1") +(define-obsolete-function-alias 'ediff-make-bottom-toolbar #'ignore "27.1") +(define-obsolete-function-alias 'ediff-deactivate-mark #'deactivate-mark "27.1") +(define-obsolete-function-alias 'ediff-nuke-selective-display #'ignore "27.1") (define-obsolete-function-alias 'ediff-add-to-history #'add-to-history "27.1") +(define-obsolete-function-alias 'ediff-minibuffer-with-setup-hook #'minibuffer-with-setup-hook "28.1") (define-obsolete-function-alias 'ediff-copy-list #'copy-sequence "28.1") (define-obsolete-function-alias 'ediff-union #'seq-union "28.1") (define-obsolete-function-alias 'ediff-intersection #'seq-intersection "28.1") diff --git a/lisp/vc/ediff-wind.el b/lisp/vc/ediff-wind.el index bd3f6880da1..d45e13ea725 100644 --- a/lisp/vc/ediff-wind.el +++ b/lisp/vc/ediff-wind.el @@ -1,6 +1,6 @@ ;;; ediff-wind.el --- window manipulation utilities -*- lexical-binding:t -*- -;; Copyright (C) 1994-1997, 2000-2022 Free Software Foundation, Inc. +;; Copyright (C) 1994-2022 Free Software Foundation, Inc. ;; Author: Michael Kifer ;; Package: ediff @@ -24,23 +24,11 @@ ;;; Code: - -;; Compiler pacifier (defvar icon-title-format) -(defvar top-toolbar-height) -(defvar bottom-toolbar-height) -(defvar left-toolbar-height) -(defvar right-toolbar-height) -(defvar left-toolbar-width) -(defvar right-toolbar-width) -(defvar default-menubar) -(defvar top-gutter) -(defvar frame-icon-title-format) (defvar ediff-diff-status) (require 'ediff-init) (require 'ediff-help) -;; end pacifier (defgroup ediff-window nil "Ediff window manipulation." @@ -261,8 +249,8 @@ keyboard input to go into icons." (let (event) (message "Select windows by clicking. Please click on Window %d " wind-number) - (while (not (ediff-mouse-event-p (setq event - (read--potential-mouse-event)))) + (while (not (mouse-event-p (setq event + (read--potential-mouse-event)))) (if (sit-for 1) ; if sequence of events, wait till the final word (beep 1)) (message "Please click on Window %d " wind-number)) @@ -846,7 +834,7 @@ keyboard input to go into icons." Create a new splittable frame if none is found." (if (display-graphic-p) (let ((wind-frame (window-frame)) - seen-windows) + seen-windows) (while (and (not (memq (selected-window) seen-windows)) (or (ediff-frame-has-dedicated-windows wind-frame) @@ -855,8 +843,8 @@ Create a new splittable frame if none is found." (< (frame-height wind-frame) (* 3 window-min-height)) (if ok-unsplittable - nil - (ediff-frame-unsplittable-p wind-frame)))) + nil + (cdr (assq 'unsplittable (frame-parameters wind-frame)))))) ;; remember history (setq seen-windows (cons (selected-window) seen-windows)) ;; try new window diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el index 840ab8cf51c..84ad5cef90f 100644 --- a/lisp/vc/ediff.el +++ b/lisp/vc/ediff.el @@ -107,8 +107,6 @@ ;;; Code: (require 'ediff-util) -;; end pacifier - (require 'ediff-init) (require 'ediff-mult) ; required because of the registry stuff @@ -283,7 +281,8 @@ deleted. Returns the buffer into which the file is visited. Also sets `ediff--magic-file-name' to indicate where the file's content has been saved (if not in `buffer-file-name')." - (let* ((file-magic (ediff-filename-magic-p file)) + (let* ((file-magic (or (ediff-file-compressed-p file) + (file-remote-p file))) (temp-file-name-prefix (file-name-nondirectory file))) (cond ((not (file-readable-p file)) (user-error "File `%s' does not exist or is not readable" file)) -- 2.39.2