From 76efc318f7529ecae939a764223c63983eac0bc6 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 4 Oct 2019 16:06:32 +0200 Subject: [PATCH] Remove XEmacs compat code from edt.el * lisp/emulation/edt.el (top-level, edt-emacs-variant) (edt-window-system, edt-xserver, edt-page-backward) (edt-beginning-of-line, edt-end-of-line-forward) (edt-end-of-line-backward, edt-one-word-forward) (edt-one-word-backward, edt-character, edt-line-forward) (edt-next-line, edt-previous-line, edt-top, edt-find-forward) (edt-find-backward, edt-find-next-forward) (edt-find-next-backward, edt-reset, edt-advance, edt-backup) (edt-define-key, edt-bottom-check, edt-sentence-forward) (edt-sentence-backward, edt-paragraph-forward) (edt-paragraph-backward, edt-restore-key, edt-window-top) (edt-window-bottom, edt-scroll-window-backward-line) (edt-line-to-bottom-of-window, edt-line-to-middle-of-window) (edt-goto-percentage, edt-display-the-time, edt-remember) (edt-split-window, edt-load-keys, edt-emulation-on) (edt-emulation-off, edt-default-emulation-setup) (edt-user-emulation-setup, edt-select-default-global-map) (edt-select-user-global-map): Remove XEmacs compat code. --- lisp/emulation/edt.el | 213 +++++++++++++----------------------------- 1 file changed, 66 insertions(+), 147 deletions(-) diff --git a/lisp/emulation/edt.el b/lisp/emulation/edt.el index dcc327dbd4..0fdfd75a26 100644 --- a/lisp/emulation/edt.el +++ b/lisp/emulation/edt.el @@ -106,10 +106,7 @@ ;; customization file, edt-user.el, to do this. ;; See Info node `edt' for more details. -;; 3. EDT Emulation now also works in XEmacs, including the -;; highlighting of selected text. - -;; 4. If you access a workstation using an X Server, observe that +;; 3. If you access a workstation using an X Server, observe that ;; the initialization file generated by edt-mapper.el will now ;; contain the name of the X Server vendor. This is a ;; convenience for those who have access to their Unix account @@ -120,7 +117,7 @@ ;; names. Then, the correct initialization file for the ;; particular X server in use is loaded correctly automatically. -;; 5. Also, edt-mapper.el is now capable of binding an ASCII key +;; 4. Also, edt-mapper.el is now capable of binding an ASCII key ;; sequence, providing the ASCII key sequence prefix is already ;; known by Emacs to be a prefix. As a result of providing this ;; support, some terminal/keyboard/window system configurations, @@ -140,7 +137,7 @@ ;; your terminal OR a bug in the terminal emulation software you ;; are using.) -;; 6. The edt-quit function (bound to GOLD-q by default) has been +;; 5. The edt-quit function (bound to GOLD-q by default) has been ;; modified to warn the user when file-related buffer ;; modifications exist. It now cautions the user that those ;; modifications will be lost if the user quits without saving @@ -180,8 +177,6 @@ edt-orig-transient-mark-mode (defvar edt-rect-start-point) (defvar edt-user-global-map) (defvar rect-start-point) -(defvar time-string) -(defvar zmacs-region-stays) ;;; ;;; Version Information @@ -310,23 +305,13 @@ edt-term ;;; ;;; o edt-emulation-on o edt-load-keys ;;; -(defconst edt-emacs-variant (if (featurep 'emacs) "gnu" "xemacs") - "Indicates Emacs variant: GNU Emacs or XEmacs (aka Lucid Emacs).") - -(defconst edt-window-system (if (featurep 'emacs) window-system (console-type)) - "Indicates window system (in GNU Emacs) or console type (in XEmacs).") - -(declare-function x-server-vendor "xfns.c" (&optional terminal)) - -(defconst edt-xserver (when (eq edt-window-system 'x) +(defconst edt-xserver (when (eq window-system 'x) ;; The Cygwin window manager has a `/' in its ;; name, which breaks the generated file name of ;; the custom key map file. Replace `/' with a ;; `-' to work around that. - (if (featurep 'xemacs) - (replace-in-string (x-server-vendor) "[ /]" "-") - (replace-regexp-in-string "[ /]" "-" - (x-server-vendor)))) + (replace-regexp-in-string "[ /]" "-" + (x-server-vendor))) "Indicates X server vendor name, if applicable.") (defvar edt-keys-file nil @@ -388,8 +373,7 @@ edt-page-backward (error "Beginning of buffer") (progn (backward-page num) - (edt-line-to-top-of-window) - (if (featurep 'xemacs) (setq zmacs-region-stays t))))) + (edt-line-to-top-of-window)))) (defun edt-page (num) "Move in current direction to next page delimiter. @@ -449,8 +433,7 @@ edt-beginning-of-line (progn (setq num (1- num)) (forward-line (* -1 num)))) - (edt-top-check beg num)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (edt-top-check beg num))) ;;; @@ -465,8 +448,7 @@ edt-end-of-line-forward (let ((beg (edt-current-line))) (forward-char) (end-of-line num) - (edt-bottom-check beg num)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (edt-bottom-check beg num))) (defun edt-end-of-line-backward (num) @@ -476,8 +458,7 @@ edt-end-of-line-backward (edt-check-prefix num) (let ((beg (edt-current-line))) (end-of-line (1- num)) - (edt-top-check beg num)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (edt-top-check beg num))) (defun edt-end-of-line (num) @@ -521,8 +502,7 @@ edt-one-word-forward (not (eobp)) (eq ?\ (char-syntax (following-char))) (not (memq (following-char) edt-word-entities))) - (forward-char)))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (forward-char))))) (defun edt-one-word-backward () "Move backward to first character of previous word." @@ -545,8 +525,7 @@ edt-one-word-backward (not (bobp)) (not (eq ?\ (char-syntax (preceding-char)))) (not (memq (preceding-char) edt-word-entities))) - (backward-char))))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (backward-char)))))) (defun edt-word-forward (num) "Move forward to first character of next word. @@ -585,8 +564,7 @@ edt-character (edt-check-prefix num) (if (equal edt-direction-string edt-forward-string) (forward-char num) - (backward-char num)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (backward-char num))) ;;; ;;; LINE @@ -608,8 +586,7 @@ edt-line-forward (edt-check-prefix num) (let ((beg (edt-current-line))) (forward-line num) - (edt-bottom-check beg num)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (edt-bottom-check beg num))) (defun edt-line (num) "Move in current direction to next beginning of line mark. @@ -631,8 +608,7 @@ edt-next-line (let ((beg (edt-current-line))) ;; We're deliberately using next-line instead of forward-line. (with-no-warnings (next-line num)) - (edt-bottom-check beg num)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (edt-bottom-check beg num))) (defun edt-previous-line (num) "Move cursor up one line. @@ -642,8 +618,7 @@ edt-previous-line (let ((beg (edt-current-line))) ;; We're deliberately using previous-line instead of forward-line. (with-no-warnings (previous-line num)) - (edt-top-check beg num)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (edt-top-check beg num))) ;;; @@ -653,8 +628,7 @@ edt-previous-line (defun edt-top () "Move cursor to the beginning of buffer." (interactive) - (goto-char (point-min)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (goto-char (point-min))) ;;; ;;; BOTTOM @@ -703,8 +677,7 @@ edt-find-forward (if (zerop (setq left (save-excursion (forward-line height)))) (recenter top-margin) (recenter (- left bottom-up-margin))) - (and (> (point) bottom) (recenter bottom-margin))))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (and (> (point) bottom) (recenter bottom-margin)))))) (defun edt-find-backward (&optional find) "Find first occurrence of a string in the backward direction and save it. @@ -715,8 +688,7 @@ edt-find-backward (edt-with-position (if (search-backward edt-find-last-text) (edt-set-match)) - (and (< (point) top) (recenter (min beg top-margin)))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (and (< (point) top) (recenter (min beg top-margin))))) (defun edt-find () "Find first occurrence of string in current direction and save it." @@ -746,8 +718,7 @@ edt-find-next-forward (recenter (- left bottom-up-margin))) (and (> (point) bottom) (recenter bottom-margin)))) (backward-char 1) - (error "Search failed: \"%s\"" edt-find-last-text))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (error "Search failed: \"%s\"" edt-find-last-text)))) (defun edt-find-next-backward () "Find next occurrence of a string in backward direction." @@ -756,8 +727,7 @@ edt-find-next-backward (if (not (search-backward edt-find-last-text nil t)) (error "Search failed: \"%s\"" edt-find-last-text) (edt-set-match) - (and (< (point) top) (recenter (min beg top-margin))))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (and (< (point) top) (recenter (min beg top-margin)))))) (defun edt-find-next () "Find next occurrence of a string in current direction." @@ -834,9 +804,7 @@ edt-select (defun edt-reset () "Cancel text selection." (interactive) - (if (featurep 'emacs) - (deactivate-mark) - (zmacs-deactivate-region))) + (deactivate-mark)) ;;; ;;; CUT @@ -1050,8 +1018,7 @@ edt-advance (force-mode-line-update) (if (string-equal " *Minibuf" (substring (buffer-name) 0 (min (length (buffer-name)) 9))) - (exit-minibuffer)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (exit-minibuffer))) ;;; @@ -1066,8 +1033,7 @@ edt-backup (force-mode-line-update) (if (string-equal " *Minibuf" (substring (buffer-name) 0 (min (length (buffer-name)) 9))) - (exit-minibuffer)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (exit-minibuffer))) ;;; @@ -1117,14 +1083,11 @@ edt-define-key The current key definition is saved in `edt-last-replaced-key-definition'. Use `edt-restore-key' to restore last replaced key definition." (interactive) - (if (featurep 'xemacs) (setq zmacs-region-stays t)) (let (edt-function edt-key-definition) (setq edt-key-definition (read-key-sequence "Press the key to be defined: ")) - (if (if (featurep 'emacs) - (string-equal "\C-m" edt-key-definition) - (string-equal "\C-m" (events-to-keys edt-key-definition))) + (if (string-equal "\C-m" edt-key-definition) (message "Key not defined") (progn (setq edt-function (read-command "Enter command name: ")) @@ -1202,8 +1165,6 @@ edt-bottom-check ;; subtract 1 from height because it includes mode line (difference (- height margin 1))) (cond ((> beg difference) (recenter beg)) - ((and (featurep 'xemacs) (> (+ beg lines 1) difference)) - (recenter (- margin))) ((> (+ beg lines) difference) (recenter (- margin)))))) (defun edt-current-line nil @@ -1289,8 +1250,7 @@ edt-sentence-forward (if (zerop (setq left (save-excursion (forward-line height)))) (recenter top-margin) (recenter (- left bottom-up-margin))) - (and (> (point) bottom) (recenter bottom-margin)))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (and (> (point) bottom) (recenter bottom-margin))))) (defun edt-sentence-backward (num) "Move backward to next sentence beginning. @@ -1301,8 +1261,7 @@ edt-sentence-backward (if (eobp) (error "End of buffer") (backward-sentence num)) - (and (< (point) top) (recenter (min beg top-margin)))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (and (< (point) top) (recenter (min beg top-margin))))) (defun edt-sentence (num) "Move in current direction to next sentence. @@ -1332,8 +1291,7 @@ edt-paragraph-forward (if (zerop (setq left (save-excursion (forward-line height)))) (recenter top-margin) (recenter (- left bottom-up-margin))) - (and (> (point) bottom) (recenter bottom-margin)))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (and (> (point) bottom) (recenter bottom-margin))))) (defun edt-paragraph-backward (num) "Move backward to beginning of paragraph. @@ -1344,8 +1302,7 @@ edt-paragraph-backward (while (> num 0) (start-of-paragraph-text) (setq num (1- num))) - (and (< (point) top) (recenter (min beg top-margin)))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (and (< (point) top) (recenter (min beg top-margin))))) (defun edt-paragraph (num) "Move in current direction to next paragraph. @@ -1363,24 +1320,18 @@ edt-restore-key "Restore last replaced key definition. Definition is stored in `edt-last-replaced-key-definition'." (interactive) - (if (featurep 'xemacs) (setq zmacs-region-stays t)) (if edt-last-replaced-key-definition (progn (let (edt-key-definition) (set 'edt-key-definition (read-key-sequence "Press the key to be restored: ")) - (if (if (featurep 'emacs) - (string-equal "\C-m" edt-key-definition) - (string-equal "\C-m" (events-to-keys edt-key-definition))) + (if (string-equal "\C-m" edt-key-definition) (message "Key not restored") (progn (define-key (current-global-map) edt-key-definition edt-last-replaced-key-definition) - (if (featurep 'emacs) - (message "Key definition for %s has been restored." - edt-key-definition) - (message "Key definition for %s has been restored." - (events-to-keys edt-key-definition))))))) + (message "Key definition for %s has been restored." + edt-key-definition))))) (error "No replaced key definition to restore!"))) ;;; @@ -1392,8 +1343,7 @@ edt-window-top (interactive) (let ((start-column (current-column))) (move-to-window-line 0) - (move-to-column start-column)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (move-to-column start-column))) ;;; ;;; WINDOW BOTTOM @@ -1404,8 +1354,7 @@ edt-window-bottom (interactive) (let ((start-column (current-column))) (move-to-window-line (- (window-height) 2)) - (move-to-column start-column)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (move-to-column start-column))) ;;; ;;; SCROLL WINDOW LINE @@ -1414,14 +1363,12 @@ edt-window-bottom (defun edt-scroll-window-forward-line () "Move window forward one line leaving cursor at position in window." (interactive) - (scroll-up 1) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (scroll-up 1)) (defun edt-scroll-window-backward-line () "Move window backward one line leaving cursor at position in window." (interactive) - (scroll-down 1) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (scroll-down 1)) (defun edt-scroll-line () "Move window one line in current direction." @@ -1467,8 +1414,7 @@ edt-scroll-window (defun edt-line-to-bottom-of-window () "Move the current line to the bottom of the window." (interactive) - (recenter -1) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (recenter -1)) ;;; ;;; LINE TO TOP OF WINDOW @@ -1477,8 +1423,7 @@ edt-line-to-bottom-of-window (defun edt-line-to-top-of-window () "Move the current line to the top of the window." (interactive) - (recenter 0) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (recenter 0)) ;;; ;;; LINE TO MIDDLE OF WINDOW @@ -1487,8 +1432,7 @@ edt-line-to-top-of-window (defun edt-line-to-middle-of-window () "Move window so line with cursor is in the middle of the window." (interactive) - (recenter '(4)) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (recenter '(4))) ;;; ;;; GOTO PERCENTAGE @@ -1500,8 +1444,7 @@ edt-goto-percentage (interactive "NGoto-percentage: ") (if (or (> num 100) (< num 0)) (error "Percentage %d out of range 0 < percent < 100" num) - (goto-char (/ (* (point-max) num) 100))) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (goto-char (/ (* (point-max) num) 100)))) ;;; ;;; FILL REGION @@ -1673,7 +1616,6 @@ edt-eliminate-all-tabs (defun edt-display-the-time () "Display the current time." (interactive) - (if (featurep 'xemacs) (setq zmacs-region-stays t)) (message "%s" (current-time-string))) ;;; @@ -1701,9 +1643,7 @@ edt-remember (let (edt-key-definition) (set 'edt-key-definition (read-key-sequence "Enter key for binding: ")) - (if (if (featurep 'emacs) - (string-equal "\C-m" edt-key-definition) - (string-equal "\C-m" (events-to-keys edt-key-definition))) + (if (string-equal "\C-m" edt-key-definition) (message "Key sequence not remembered") (progn (set 'edt-learn-macro-count (+ edt-learn-macro-count 1)) @@ -1753,8 +1693,7 @@ edt-split-window "Split current window and place cursor in the new window." (interactive) (split-window) - (other-window 1) - (if (featurep 'xemacs) (setq zmacs-region-stays t))) + (other-window 1)) ;;; ;;; COPY RECTANGLE @@ -1935,9 +1874,8 @@ edt-y-or-n-p (defun edt-load-keys (file) "Load the LK-201 key mapping FILE generated by edt-mapper.el. If FILE is nil, which is the normal case, try to load a default file. -The default file names are based upon the window system, terminal -type, and version of Emacs in use: GNU Emacs or XEmacs (aka Lucid -Emacs). If a default file does not exist, ask user if one should be +The default file names are based upon the window system and terminal +type. If a default file does not exist, ask user if one should be created." (interactive "fKey definition file: ") (cond (file @@ -1948,11 +1886,11 @@ edt-load-keys (setq file (expand-file-name (concat - "~/.edt-" edt-emacs-variant + "~/.edt-gnu" (if edt-term (concat "-" edt-term)) (if edt-xserver (concat "-" edt-xserver)) - (if edt-window-system - (concat "-" (upcase (symbol-name edt-window-system)))) + (if window-system + (concat "-" (upcase (symbol-name window-system)))) "-keys"))))) (cond ((file-readable-p file) (load-file file)) @@ -2002,15 +1940,14 @@ edt-emulation-on "Turn on EDT Emulation." (interactive) ;; If using pc window system (MS-DOS), set terminal type to pc. - ;; If not a window system (GNU) or a tty window system (XEmacs), - ;; get terminal type. - (if (eq edt-window-system 'pc) + ;; If not a window system, get terminal type. + (if (eq window-system 'pc) (setq edt-term "pc") - (if (or (not edt-window-system) (eq edt-window-system 'tty)) + (if (not window-system) (setq edt-term (getenv "TERM")))) ;; Look for a terminal configuration file for this terminal type. ;; Otherwise, load the user's custom configuration file. - (if (or (not edt-window-system) (memq edt-window-system '(pc tty))) + (if (or (not window-system) (memq window-system '(pc tty))) (progn ;; Load terminal-specific configuration file, if it exists for this ;; terminal type. Note: All DEC VT series terminals are supported @@ -2037,27 +1974,16 @@ edt-emulation-on (setq edt-term term)))) (edt-load-keys nil)) ;; Make highlighting of selected text work properly for EDT commands. - (if (featurep 'emacs) - (progn - (setq edt-orig-transient-mark-mode - (default-value 'transient-mark-mode)) - (add-hook 'activate-mark-hook - (function - (lambda () - (edt-select-mode t)))) - (add-hook 'deactivate-mark-hook - (function - (lambda () - (edt-select-mode nil))))) - (progn - (add-hook 'zmacs-activate-region-hook - (function - (lambda () - (edt-select-mode t)))) - (add-hook 'zmacs-deactivate-region-hook - (function - (lambda () - (edt-select-mode nil)))))) + (setq edt-orig-transient-mark-mode + (default-value 'transient-mark-mode)) + (add-hook 'activate-mark-hook + (function + (lambda () + (edt-select-mode t)))) + (add-hook 'deactivate-mark-hook + (function + (lambda () + (edt-select-mode nil)))) ;; Load user's EDT custom key bindings file, if it exists. ;; Otherwise, use the default bindings. (if (load "edt-user" t t) @@ -2074,8 +2000,7 @@ edt-emulation-off (setq edt-select-mode-current nil) (edt-reset) (force-mode-line-update t) - (if (featurep 'emacs) - (setq-default transient-mark-mode edt-orig-transient-mark-mode)) + (setq-default transient-mark-mode edt-orig-transient-mark-mode) (message "Original key bindings restored; EDT Emulation disabled")) (defun edt-default-menu-bar-update-buffers () @@ -2103,9 +2028,7 @@ edt-default-emulation-setup ;; disturbing the original bindings in global-map. (fset 'edt-default-ESC-prefix (copy-keymap 'ESC-prefix)) (setq edt-default-global-map (copy-keymap (current-global-map))) - (if (featurep 'emacs) - (define-key edt-default-global-map "\e" 'edt-default-ESC-prefix) - (define-key edt-default-global-map [escape] 'edt-default-ESC-prefix)) + (define-key edt-default-global-map "\e" 'edt-default-ESC-prefix) (define-prefix-command 'edt-default-gold-map) (edt-setup-default-bindings) ;; If terminal has additional function keys, the terminal-specific @@ -2141,9 +2064,7 @@ edt-user-emulation-setup ;; Setup user EDT global map by copying default EDT global map bindings. (fset 'edt-user-ESC-prefix (copy-keymap 'edt-default-ESC-prefix)) (setq edt-user-global-map (copy-keymap edt-default-global-map)) - (if (featurep 'emacs) - (define-key edt-user-global-map "\e" 'edt-user-ESC-prefix) - (define-key edt-user-global-map [escape] 'edt-user-ESC-prefix)) + (define-key edt-user-global-map "\e" 'edt-user-ESC-prefix) ;; If terminal has additional function keys, the user's initialization ;; file can assign bindings to them via the optional ;; function edt-setup-extra-default-bindings. @@ -2160,8 +2081,7 @@ edt-user-emulation-setup (defun edt-select-default-global-map() "Select default EDT emulation key bindings." (interactive) - (if (featurep 'emacs) - (transient-mark-mode 1)) + (transient-mark-mode 1) (use-global-map edt-default-global-map) (if (not edt-keep-current-page-delimiter) (progn @@ -2178,8 +2098,7 @@ edt-select-user-global-map (interactive) (if edt-user-map-configured (progn - (if (featurep 'emacs) - (transient-mark-mode 1)) + (transient-mark-mode 1) (use-global-map edt-user-global-map) (if (not edt-keep-current-page-delimiter) (progn -- 2.20.1