diff options
Diffstat (limited to 'lisp/erc')
-rw-r--r-- | lisp/erc/erc-backend.el | 53 | ||||
-rw-r--r-- | lisp/erc/erc-compat.el | 6 | ||||
-rw-r--r-- | lisp/erc/erc-dcc.el | 40 | ||||
-rw-r--r-- | lisp/erc/erc-speedbar.el | 24 | ||||
-rw-r--r-- | lisp/erc/erc.el | 38 |
5 files changed, 63 insertions, 98 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 8be4894ecbb..df9efe4b0c3 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -230,7 +230,7 @@ current IRC process is still alive.") (defvar-local erc-server-lines-sent nil "Line counter.") -(defvar-local erc-server-last-peers '(nil . nil) +(defvar-local erc-server-last-peers nil "Last peers used, both sender and receiver. Those are used for /MSG destination shortcuts.") @@ -562,7 +562,7 @@ TLS (see `erc-session-client-certificate' for more details)." (setq erc-server-last-received-time time)) (setq erc-server-lines-sent 0) ;; last peers (sender and receiver) - (setq erc-server-last-peers '(nil . nil))) + (setq erc-server-last-peers (cons nil nil))) ;; we do our own encoding and decoding (when (fboundp 'set-process-coding-system) (set-process-coding-system process 'raw-text)) @@ -939,21 +939,20 @@ be used. If the target is \".\", the last person you've sent a message to will be used." (cond ((string-match "^\\s-*\\(\\S-+\\) ?\\(.*\\)" line) - (let ((tgt (match-string 1 line)) - (s (match-string 2 line))) + (let* ((tgt (match-string 1 line)) + (s (match-string 2 line)) + (server-buffer (erc-server-buffer)) + (peers (buffer-local-value 'erc-server-last-peers server-buffer))) (erc-log (format "cmd: MSG(%s): [%s] %s" message-command tgt s)) (cond ((string= tgt ",") - (if (car erc-server-last-peers) - (setq tgt (car erc-server-last-peers)) - (setq tgt nil))) + (setq tgt (car peers))) ((string= tgt ".") - (if (cdr erc-server-last-peers) - (setq tgt (cdr erc-server-last-peers)) - (setq tgt nil)))) + (setq tgt (cdr peers)))) (cond (tgt - (setcdr erc-server-last-peers tgt) + (with-current-buffer server-buffer + (setq erc-server-last-peers (cons (car peers) tgt))) (erc-server-send (format "%s %s :%s" message-command tgt s) force)) (t @@ -1012,21 +1011,15 @@ PROCs `process-buffer' is `current-buffer' when this function is called." (save-match-data (let* ((tag-list (when (eq (aref string 0) ?@) (substring string 1 - (if (>= emacs-major-version 28) - (string-search " " string) - (string-match " " string))))) + (string-search " " string)))) (msg (make-erc-response :unparsed string :tags (when tag-list (erc-parse-tags tag-list)))) (string (if tag-list - (substring string (+ 1 (if (>= emacs-major-version 28) - (string-search " " string) - (string-match " " string)))) + (substring string (+ 1 (string-search " " string))) string)) (posn (if (eq (aref string 0) ?:) - (if (>= emacs-major-version 28) - (string-search " " string) - (string-match " " string)) + (string-search " " string) 0))) (setf (erc-response.sender msg) @@ -1036,9 +1029,7 @@ PROCs `process-buffer' is `current-buffer' when this function is called." (setf (erc-response.command msg) (let* ((bposn (string-match "[^ \n]" string posn)) - (eposn (if (>= emacs-major-version 28) - (string-search " " string bposn) - (string-match " " string bposn)))) + (eposn (string-search " " string bposn))) (setq posn (and eposn (string-match "[^ \n]" string eposn))) (substring string bposn eposn))) @@ -1046,9 +1037,7 @@ PROCs `process-buffer' is `current-buffer' when this function is called." (while (and posn (not (eq (aref string posn) ?:))) (push (let* ((bposn posn) - (eposn (if (>= emacs-major-version 28) - (string-search " " string bposn) - (string-match " " string bposn)))) + (eposn (string-search " " string bposn))) (setq posn (and eposn (string-match "[^ \n]" string eposn))) (substring string bposn eposn)) @@ -1526,11 +1515,13 @@ add things to `%s' instead." (setf (erc-response.contents parsed) msg) (setq buffer (erc-get-buffer (if privp nick tgt) proc)) ;; Even worth checking for empty target here? (invalid anyway) - (unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0))) - (if (and privp msgp (not (erc-is-message-ctcp-and-not-action-p msg))) + (unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0)) + (erc-is-message-ctcp-and-not-action-p msg)) + (if privp (when erc-auto-query (let ((erc-join-buffer erc-auto-query)) (setq buffer (erc--open-target nick)))) + ;; A channel buffer has been killed but is still joined (setq buffer (erc--open-target tgt)))) (when buffer (with-current-buffer buffer @@ -1550,7 +1541,7 @@ add things to `%s' instead." (erc-process-ctcp-reply proc parsed nick login host (match-string 1 msg))))) (t - (setcar erc-server-last-peers nick) + (setq erc-server-last-peers (cons nick (cdr erc-server-last-peers))) (setq s (erc-format-privmessage (or fnick nick) msg ;; If buffer is a query buffer, @@ -1667,9 +1658,7 @@ Then display the welcome message." start (- (match-end 0) 3)) (setq start (match-end 0)))) v)) - (if (if (>= emacs-major-version 28) - (string-search "," value) - (string-match-p "," value)) + (if (string-search "," value) (split-string value ",") (list value))))) diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 16cfb15a5ae..8a00e711acd 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -25,8 +25,14 @@ ;; This mostly defines stuff that cannot be worked around easily. +;; ERC depends on the `compat' library from GNU ELPA for supporting +;; older versions of Emacs. See this discussion for additional info: +;; https://lists.gnu.org/archive/html/emacs-devel/2022-07/msg00512.html + ;;; Code: +(require 'compat nil 'noerror) + ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat") (define-obsolete-function-alias 'erc-define-minor-mode #'define-minor-mode "28.1") diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index d0e1848e0eb..977080a4de1 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -191,9 +191,7 @@ compared with `erc-nick-equal-p' which is IRC case-insensitive." test (cadr (plist-member elt prop))) ;; if the property exists and is equal, we continue, else, try the ;; next element of the list - (or (and (eq prop :nick) (if (>= emacs-major-version 28) - (string-search "!" val) - (string-match "!" val)) + (or (and (eq prop :nick) (string-search "!" val) test (string-equal test val)) (and (eq prop :nick) test val @@ -659,13 +657,7 @@ that subcommand." (define-inline erc-dcc-unquote-filename (filename) (inline-quote - (if (>= emacs-major-version 28) - (string-replace - "\\\\" "\\" - (string-replace "\\\"" "\"" ,filename)) - (replace-regexp-in-string - "\\\\\\\\" "\\" - (replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t)))) + (string-replace "\\\\" "\\" (string-replace "\\\"" "\"" ,filename)))) (defun erc-dcc-handle-ctcp-send (proc query nick login host to) "This is called if a CTCP DCC SEND subcommand is sent to the client. @@ -987,7 +979,7 @@ The contents of the BUFFER will then be erased." ;; If people really need this, we can convert it into a proper option. -(defvar erc-dcc--X-send-final-turbo-ack nil +(defvar erc-dcc--send-final-turbo-ack nil "Workaround for maverick turbo senders that only require a final ACK. The only known culprit is WeeChat, with its xfer.network.fast_send option, which is on by default. Leaving this set to nil and calling @@ -1032,7 +1024,7 @@ rather than every 1024 byte block, but nobody seems to care." ;; Some senders want us to hang up. Only observed w. TSEND. ((and (plist-get erc-dcc-entry-data :turbo) (= received-bytes (plist-get erc-dcc-entry-data :size))) - (when erc-dcc--X-send-final-turbo-ack + (when erc-dcc--send-final-turbo-ack (process-send-string proc (erc-pack-int received-bytes))) (delete-process proc)) ((not (or (plist-get erc-dcc-entry-data :turbo) @@ -1182,18 +1174,18 @@ other client." (proc (plist-get entry :peer)) (parent-proc (plist-get entry :parent))) (erc-setup-buffer buffer) - ;; buffer is now the current buffer. - (erc-dcc-chat-mode) - (setq erc-server-process parent-proc) - (setq erc-dcc-from nick) - (setq erc-dcc-entry-data entry) - (setq erc-dcc-unprocessed-output "") - (setq erc-insert-marker (point-max-marker)) - (setq erc-input-marker (make-marker)) - (erc-display-prompt buffer (point-max)) - (set-process-buffer proc buffer) - (add-hook 'kill-buffer-hook #'erc-dcc-chat-buffer-killed nil t) - (run-hook-with-args 'erc-dcc-chat-connect-hook proc) + (with-current-buffer buffer + (erc-dcc-chat-mode) + (setq erc-server-process parent-proc + erc-dcc-from nick + erc-dcc-entry-data entry + erc-dcc-unprocessed-output "" + erc-insert-marker (point-max-marker) + erc-input-marker (make-marker)) + (erc-display-prompt buffer (point-max)) + (set-process-buffer proc buffer) + (add-hook 'kill-buffer-hook #'erc-dcc-chat-buffer-killed nil t) + (run-hook-with-args 'erc-dcc-chat-connect-hook proc)) buffer)) (defun erc-dcc-chat-accept (entry parent-proc) diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el index 5b06c21612f..19113c5aad0 100644 --- a/lisp/erc/erc-speedbar.el +++ b/lisp/erc/erc-speedbar.el @@ -139,9 +139,7 @@ This will add a speedbar major display mode." t)))) (defun erc-speedbar-expand-server (text server indent) - (cond ((if (>= emacs-major-version 28) - (string-search "+" text) - (string-match "\\+" text)) + (cond ((string-search "+" text) (speedbar-change-expand-button-char ?-) (if (speedbar-with-writable (save-excursion @@ -150,9 +148,7 @@ This will add a speedbar major display mode." (speedbar-change-expand-button-char ?-) (speedbar-change-expand-button-char ??))) (;; we have to contract this node - (if (>= emacs-major-version 28) - (string-search "-" text) - (string-match "-" text)) + (string-search "-" text) (speedbar-change-expand-button-char ?+) (speedbar-delete-subblock indent)) (t (error "Ooops... not sure what to do"))) @@ -189,9 +185,7 @@ This will add a speedbar major display mode." "For the line matching TEXT, in CHANNEL, expand or contract a line. INDENT is the current indentation level." (cond - ((if (>= emacs-major-version 28) - (string-search "+" text) - (string-match "\\+" text)) + ((string-search "+" text) (speedbar-change-expand-button-char ?-) (speedbar-with-writable (save-excursion @@ -240,9 +234,7 @@ INDENT is the current indentation level." (speedbar-with-writable (dolist (entry names) (erc-speedbar-insert-user entry ?+ (1+ indent)))))))))) - ((if (>= emacs-major-version 28) - (string-search "-" text) - (string-match "-" text)) + ((string-search "-" text) (speedbar-change-expand-button-char ?+) (speedbar-delete-subblock indent)) (t (error "Ooops... not sure what to do"))) @@ -293,9 +285,7 @@ The update is only done when the channel is actually expanded already." (erc-speedbar-expand-channel "+" buffer 1))))) (defun erc-speedbar-expand-user (text token indent) - (cond ((if (>= emacs-major-version 28) - (string-search "+" text) - (string-match "\\+" text)) + (cond ((string-search "+" text) (speedbar-change-expand-button-char ?-) (speedbar-with-writable (save-excursion @@ -318,9 +308,7 @@ The update is only done when the channel is actually expanded already." nil nil nil nil info nil nil nil (1+ indent))))))) - ((if (>= emacs-major-version 28) - (string-search "-" text) - (string-match "-" text)) + ((string-search "-" text) (speedbar-change-expand-button-char ?+) (speedbar-delete-subblock indent)) (t (error "Ooops... not sure what to do"))) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 4b852b39045..151d75e7ce1 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -13,7 +13,7 @@ ;; Michael Olson (mwolson@gnu.org) ;; Kelvin White (kwhite@gnu.org) ;; Version: 5.4.1 -;; Package-Requires: ((emacs "27.1")) +;; Package-Requires: ((emacs "27.1") (compat "28.1.2.0")) ;; Keywords: IRC, chat, client, Internet ;; URL: https://www.gnu.org/software/emacs/erc.html @@ -69,6 +69,8 @@ (require 'iso8601) (eval-when-compile (require 'subr-x)) +(require 'erc-compat) + (defconst erc-version "5.4.1" "This version of ERC.") @@ -3519,9 +3521,7 @@ Without SECRET, consult auth-source, possibly passing SERVER as the "Non-nil when channel is server-local on a network that allows them." (and-let* (((eq ?& (aref channel 0))) (chan-types (erc--get-isupport-entry 'CHANTYPES 'single)) - ((if (>= emacs-major-version 28) - (string-search "&" chan-types) - (string-match-p "&" chan-types)))))) + ((string-search "&" chan-types))))) (defun erc-cmd-JOIN (channel &optional key) "Join the channel given in CHANNEL, optionally with KEY. @@ -4654,8 +4654,9 @@ a new window, but not to select it. See the documentation for (const :tag "Use current buffer" buffer) (const :tag "Use current buffer" t))) -;; FIXME either retire this or put it to use or more clearly explain -;; what it's supposed to do. It's currently only used by the obsolete +;; FIXME either retire this or put it to use after determining how +;; it's meant to work. Clearly, the doc string does not describe +;; current behavior. It's currently only used by the obsolete ;; function `erc-auto-query'. (defcustom erc-query-on-unjoined-chan-privmsg t "If non-nil create query buffer on receiving any PRIVMSG at all. @@ -7004,21 +7005,12 @@ shortened server name instead." (fill-region (point-min) (point-max)) (buffer-string)))) (setq header-line-format - (if (>= emacs-major-version 28) - (string-replace - "%" - "%%" - (if face - (propertize header 'help-echo help-echo - 'face face) - (propertize header 'help-echo help-echo))) - (replace-regexp-in-string - "%" - "%%" - (if face - (propertize header 'help-echo help-echo - 'face face) - (propertize header 'help-echo help-echo))))))) + (string-replace + "%" + "%%" + (if face + (propertize header 'help-echo help-echo 'face face) + (propertize header 'help-echo help-echo)))))) (t (setq header-line-format (if face (propertize header 'face face) @@ -7303,9 +7295,7 @@ functions." nick user host channel (if (not (string= reason "")) (format ": %s" - (if (>= emacs-major-version 28) - (string-replace "%" "%%" reason) - (replace-regexp-in-string "%" "%%" reason))) + (string-replace "%" "%%" reason)) ""))))) |