Remove XEmacs compat code from erc

* lisp/erc/erc-button.el (button, erc-button-keymap)
(erc-button-setup, erc-button-add-button): Remove XEmacs compat code.

* lisp/erc/erc-compat.el (erc-replace-match-subexpression-in-string):

* lisp/erc/erc-log.el (erc-log-file-coding-system):

* lisp/erc/erc-menu.el (menu):

* lisp/erc/erc-stamp.el (erc-timestamp-use-align-to):

* lisp/erc/erc-track.el (erc-modified-channels-object, track)
(erc-track-mouse-face):

* lisp/erc/erc.el (erc-update-undo-list)
(erc-quit-reason-various, erc-part-reason-various, erc-cmd-SV)
(erc-input-message, erc-get-channel-mode-from-keypress)
(erc-update-mode-line-buffer):
This commit is contained in:
Lars Ingebrigtsen 2019-06-20 01:44:19 +02:00
parent 45a0ce0905
commit 9f4cced5db
7 changed files with 31 additions and 114 deletions

View file

@ -59,11 +59,7 @@
((remove-hook 'erc-insert-modify-hook 'erc-button-add-buttons)
(remove-hook 'erc-send-modify-hook 'erc-button-add-buttons)
(remove-hook 'erc-complete-functions 'erc-button-next-function)
(remove-hook 'erc-mode-hook 'erc-button-setup)
(when (featurep 'xemacs)
(dolist (buffer (erc-buffer-list))
(with-current-buffer buffer
(kill-local-variable 'widget-button-face))))))
(remove-hook 'erc-mode-hook 'erc-button-setup)))
;;; Variables
@ -218,9 +214,7 @@ PAR is a number of a regexp grouping whose text will be passed to
(defvar erc-button-keymap
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") 'erc-button-press-button)
(if (featurep 'xemacs)
(define-key map (kbd "<button2>") 'erc-button-click-button)
(define-key map (kbd "<mouse-2>") 'erc-button-click-button))
(define-key map (kbd "<mouse-2>") 'erc-button-click-button)
(define-key map (kbd "TAB") 'erc-button-next)
(define-key map (kbd "<backtab>") 'erc-button-previous)
(define-key map [follow-link] 'mouse-face)
@ -255,8 +249,6 @@ global-level ERC button keys yet.")
(defun erc-button-setup ()
"Add ERC mode-level button movement keys. This is only done once."
;; Make XEmacs use `erc-button-face'.
(when (featurep 'xemacs)
(set (make-local-variable 'widget-button-face) nil))
;; Add keys.
(unless erc-button-keys-added
(define-key erc-mode-map (kbd "<backtab>") 'erc-button-previous)
@ -374,18 +366,7 @@ REGEXP is the regular expression which matched for this button."
(list 'erc-callback fun)
(list 'keymap erc-button-keymap)
(list 'rear-nonsticky t)
(and data (list 'erc-data data))))
(when (featurep 'xemacs)
(widget-convert-button 'link from to :action 'erc-button-press-button
:suppress-face t
;; Make XEmacs use our faces.
:button-face (if nick-p
erc-button-nickname-face
erc-button-face)
;; Make XEmacs behave with mouse-clicks, for
;; some reason, widget stuff overrides the
;; 'keymap text-property.
:mouse-down-action 'erc-button-click-button)))
(and data (list 'erc-data data)))))
(defun erc-button-add-face (from to face)
"Add FACE to the region between FROM and TO."

View file

@ -71,17 +71,13 @@ See `erc-encoding-coding-alist'."
are placed.
Note that this should end with a directory separator.")
;; XEmacs's `replace-match' does not replace matching subexpressions in strings.
(defun erc-replace-match-subexpression-in-string
(newtext string match subexp start &optional fixedcase literal)
"Replace the subexpression SUBEXP of the last match in STRING with NEWTEXT.
MATCH is the text which matched the subexpression (see `match-string').
START is the beginning position of the last match (see `match-beginning').
See `replace-match' for explanations of FIXEDCASE and LITERAL."
(cond ((featurep 'xemacs)
(string-match match string start)
(replace-match newtext fixedcase literal string))
(t (replace-match newtext fixedcase literal string subexp))))
(replace-match newtext fixedcase literal string subexp))
(defalias 'erc-with-selected-window 'with-selected-window)
(defalias 'erc-cancel-timer 'cancel-timer)

View file

@ -195,9 +195,7 @@ If you set this to nil, you may want to enable both
:group 'erc-log
:type 'boolean)
(defcustom erc-log-file-coding-system (if (featurep 'xemacs)
'binary
'emacs-mule)
(defcustom erc-log-file-coding-system 'emacs-mule
"The coding system ERC should use for writing log files.
This should ideally, be a \"catch-all\" coding system, like

View file

@ -115,22 +115,10 @@ ERC menu yet.")
;; activates it immediately
(easy-menu-define erc-menu erc-mode-map "ERC menu" erc-menu-definition)
(setq erc-menu-defined t))
(if (featurep 'xemacs)
(progn
;; the menu isn't automatically added to the menu bar in
;; XEmacs
(add-hook 'erc-mode-hook 'erc-menu-add)
(dolist (buffer (erc-buffer-list))
(with-current-buffer buffer (erc-menu-add))))
(erc-menu-add)))
((if (featurep 'xemacs)
(progn
(remove-hook 'erc-mode-hook 'erc-menu-add)
(dolist (buffer (erc-buffer-list))
(with-current-buffer buffer (erc-menu-remove))))
(erc-menu-remove)
;; `easy-menu-remove' is a no-op in Emacs 22
(message "You might have to restart Emacs to remove the ERC menu"))))
(erc-menu-add))
((erc-menu-remove)
;; `easy-menu-remove' is a no-op in Emacs 22
(message "You might have to restart Emacs to remove the ERC menu")))
;; silence byte-compiler warning
(defvar erc-menu)

View file

@ -227,14 +227,10 @@ the correct column."
(integer :tag "Column number")
(const :tag "Unspecified" nil)))
(defcustom erc-timestamp-use-align-to (and (not (featurep 'xemacs))
(>= emacs-major-version 22)
(eq window-system 'x))
(defcustom erc-timestamp-use-align-to (eq window-system 'x)
"If non-nil, use the :align-to display property to align the stamp.
This gives better results when variable-width characters (like
Asian language characters and math symbols) precede a timestamp.
Unfortunately, it only works in Emacs 22 and when using the X
Window System.
A side effect of enabling this is that there will only be one
space before a right timestamp in any saved logs."

View file

@ -267,22 +267,12 @@ nil - don't add to mode line."
(defun erc-modified-channels-object (strings)
"Generate a new `erc-modified-channels-object' based on STRINGS."
(if strings
(if (featurep 'xemacs)
(let ((e-m-c-s '("[")))
(push (cons (extent-at 0 (car strings)) (car strings))
e-m-c-s)
(dolist (string (cdr strings))
(push "," e-m-c-s)
(push (cons (extent-at 0 string) string)
e-m-c-s))
(push "] " e-m-c-s)
(reverse e-m-c-s))
(concat (if (eq erc-track-position-in-mode-line 'after-modes)
"[" " [")
(mapconcat 'identity (nreverse strings) ",")
(if (eq erc-track-position-in-mode-line 'before-modes)
"] " "]")))
(if (featurep 'xemacs) '() "")))
(concat (if (eq erc-track-position-in-mode-line 'after-modes)
"[" " [")
(mapconcat 'identity (nreverse strings) ",")
(if (eq erc-track-position-in-mode-line 'before-modes)
"] " "]"))
""))
(defvar erc-modified-channels-object (erc-modified-channels-object nil)
"Internal object used for displaying modified channels in the mode line.")
@ -546,20 +536,13 @@ keybindings will not do anything useful."
((when (boundp 'erc-track-when-inactive)
(if erc-track-when-inactive
(progn
(if (featurep 'xemacs)
(defadvice switch-to-buffer (after erc-update-when-inactive
(&rest args) activate)
(erc-user-is-active))
(add-hook 'window-configuration-change-hook 'erc-user-is-active))
(add-hook 'window-configuration-change-hook 'erc-user-is-active)
(add-hook 'erc-send-completed-hook 'erc-user-is-active)
(add-hook 'erc-server-001-functions 'erc-user-is-active))
(erc-track-add-to-mode-line erc-track-position-in-mode-line)
(erc-update-mode-line)
(if (featurep 'xemacs)
(defadvice switch-to-buffer (after erc-update (&rest args) activate)
(erc-modified-channels-update))
(add-hook 'window-configuration-change-hook
'erc-window-configuration-change))
(add-hook 'window-configuration-change-hook
'erc-window-configuration-change)
(add-hook 'erc-insert-post-hook 'erc-track-modified-channels)
(add-hook 'erc-disconnected-hook 'erc-modified-channels-update))
;; enable the tracking keybindings
@ -570,18 +553,13 @@ keybindings will not do anything useful."
(erc-track-remove-from-mode-line)
(if erc-track-when-inactive
(progn
(if (featurep 'xemacs)
(ad-disable-advice 'switch-to-buffer 'after
'erc-update-when-inactive)
(remove-hook 'window-configuration-change-hook
'erc-user-is-active))
(remove-hook 'window-configuration-change-hook
'erc-user-is-active)
(remove-hook 'erc-send-completed-hook 'erc-user-is-active)
(remove-hook 'erc-server-001-functions 'erc-user-is-active)
(remove-hook 'erc-timer-hook 'erc-user-is-active))
(if (featurep 'xemacs)
(ad-disable-advice 'switch-to-buffer 'after 'erc-update)
(remove-hook 'window-configuration-change-hook
'erc-window-configuration-change))
(remove-hook 'window-configuration-change-hook
'erc-window-configuration-change)
(remove-hook 'erc-disconnected-hook 'erc-modified-channels-update)
(remove-hook 'erc-insert-post-hook 'erc-track-modified-channels))
;; disable the tracking keybindings
@ -671,9 +649,7 @@ ARGS are ignored."
(when removed-channel
(erc-modified-channels-display)))))
(defvar erc-track-mouse-face (if (featurep 'xemacs)
'modeline-mousable
'mode-line-highlight)
(defvar erc-track-mouse-face 'mode-line-highlight
"The face to use when mouse is over channel names in the mode line.")
(defun erc-make-mode-line-buffer-name (string buffer &optional faces count)

View file

@ -2443,11 +2443,7 @@ If STRING is nil, the function does nothing."
((null (car elt)) ; (nil PROPERTY VALUE BEG . END)
(let ((cons (nthcdr 3 elt)))
(cl-incf (car cons) shift)
(cl-incf (cdr cons) shift)))
((and (featurep 'xemacs)
(extentp (car elt))) ; (EXTENT START END)
(cl-incf (nth 1 elt) shift)
(cl-incf (nth 2 elt) shift)))
(cl-incf (cdr cons) shift))))
(setq list (cdr list))))))
(defvar erc-valid-nick-regexp "[]a-zA-Z^[;\\`_{}|][]^[;\\`_{}|a-zA-Z0-9-]*"
@ -3498,7 +3494,6 @@ If S is non-nil, it will be used as the quit reason."
(defun erc-quit-reason-various (s)
"Choose a quit reason based on S (a string)."
(when (featurep 'xemacs) (require 'poe))
(let ((res (car (assoc-default (or s "")
erc-quit-reason-various-alist 'string-match))))
(cond
@ -3526,7 +3521,6 @@ If S is non-nil, it will be used as the quit reason."
(defun erc-part-reason-various (s)
"Choose a part reason based on S (a string)."
(when (featurep 'xemacs) (require 'poe))
(let ((res (car (assoc-default (or s "")
erc-part-reason-various-alist 'string-match))))
(cond
@ -3627,8 +3621,7 @@ the message given by REASON."
(defun erc-cmd-SV ()
"Say the current ERC and Emacs version into channel."
(erc-send-message (format "I'm using ERC with %s %s (%s%s)%s."
(if (featurep 'xemacs) "XEmacs" "GNU Emacs")
(erc-send-message (format "I'm using ERC with GNU Emacs %s (%s%s)%s."
emacs-version
system-configuration
(concat
@ -3969,9 +3962,7 @@ If FACE is non-nil, it will be used to propertize the prompt. If it is nil,
(let ((minibuffer-allow-text-properties t)
(read-map minibuffer-local-map))
(insert (read-from-minibuffer "Message: "
(string (if (featurep 'xemacs)
last-command-char
last-command-event))
(string last-command-event)
read-map))
(erc-send-current-line)))
@ -5766,8 +5757,6 @@ If \"l\" is pressed, `erc-set-channel-limit' gets called.
If \"k\" is pressed, `erc-set-channel-key' gets called.
Anything else will be sent to `erc-toggle-channel-mode'."
(interactive "kChannel mode (RET to set more than one): ")
(when (featurep 'xemacs)
(setq key (char-to-string (event-to-character (aref key 0)))))
(cond ((equal key "\C-g")
(keyboard-quit))
((equal key "\C-m")
@ -6411,14 +6400,9 @@ if `erc-away' is non-nil."
(funcall erc-header-line-face-method))
(t
'erc-header-line))))
(cond ((featurep 'xemacs)
(setq modeline-buffer-identification
(list (format-spec erc-mode-line-format spec)))
(setq modeline-process (list process-status)))
(t
(setq mode-line-buffer-identification
(list (format-spec erc-mode-line-format spec)))
(setq mode-line-process (list process-status))))
(setq mode-line-buffer-identification
(list (format-spec erc-mode-line-format spec)))
(setq mode-line-process (list process-status))
(when (boundp 'header-line-format)
(let ((header (if erc-header-line-format
(format-spec erc-header-line-format spec)
@ -6446,9 +6430,7 @@ if `erc-away' is non-nil."
(if face
(erc-propertize header 'face face)
header)))))))
(if (featurep 'xemacs)
(redraw-modeline)
(force-mode-line-update))))
(force-mode-line-update)))
(defun erc-update-mode-line (&optional buffer)
"Update the mode line in BUFFER.