From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: F. Jason Park Newsgroups: gmane.emacs.erc.general,gmane.emacs.devel Subject: Adding 'compat' from ELPA as an optional dependency to ERC Date: Tue, 19 Jul 2022 07:43:03 -0700 Message-ID: <87fsixw4co.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26111"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Amin Bandali , Philip Kaludercic , emacs-erc@gnu.org To: emacs-devel Original-X-From: emacs-erc-bounces+sf-erc-help=m.gmane-mx.org@gnu.org Tue Jul 19 16:43:27 2022 Return-path: Envelope-to: sf-erc-help@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDoRb-0006d9-Ho for sf-erc-help@m.gmane-mx.org; Tue, 19 Jul 2022 16:43:27 +0200 Original-Received: from localhost ([::1]:50544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDoRa-0006w3-DM for sf-erc-help@m.gmane-mx.org; Tue, 19 Jul 2022 10:43:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDoRR-0006tN-HS for emacs-erc@gnu.org; Tue, 19 Jul 2022 10:43:17 -0400 Original-Received: from mail-108-mta21.mxroute.com ([136.175.108.21]:34289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDoRN-0003GX-L0 for emacs-erc@gnu.org; Tue, 19 Jul 2022 10:43:17 -0400 Original-Received: from filter006.mxroute.com ([140.82.40.27] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta21.mxroute.com (ZoneMTA) with ESMTPSA id 18216e9a6ce0000261.003 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Tue, 19 Jul 2022 14:43:07 +0000 X-Zone-Loop: 8bb85b23a6459faaba3efeeca4dcd41572170fe3171a X-Originating-IP: [140.82.40.27] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject:Cc:To:From:Sender: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=usRSTixqTddUY6BZ+dgS984zb+MAYiw/4xHwdw/mtuE=; b=W 5lXeCkwgKEoG10mYIFFiVCAvDwNOIw/M5igP1MivEvsh/xrMPV8odyKAFFy2VReBH8yfrLRSXRi1J BsmENCFUvrbsbGov02E4FeoFd8w3gzASYTTZwM7dydTXXoqGYeKb8LlmO8kOLY2hRSMy8cBPk8Q+f 8TrBHoKS68004qbEGgEH86BcmfgExgwBC7HQ4ImHBV+oUC/daA+iIj+liLMq/yWBev3dMcW96rVPi msoeXCjYpWZwawxYS0YcfYOkXU4sMtktGxuBp4UdPHNUardTFLlBy/CFx2J2/ogDsVPPTd2pnrcVG Ck1NqaAfGI3ZBHUrb3U4sb5K7HY2UTUaQ==; X-AuthUser: masked@neverwas.me Received-SPF: pass client-ip=136.175.108.21; envelope-from=jp@neverwas.me; helo=mail-108-mta21.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-erc@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General discussion about ERC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-erc-bounces+sf-erc-help=m.gmane-mx.org@gnu.org Original-Sender: "emacs-erc" Xref: news.gmane.io gmane.emacs.erc.general:1880 gmane.emacs.devel:292271 Archived-At: --=-=-= Content-Type: text/plain Hi Emacs, As an ELPA ":core" package, ERC has a life outside of the emacs.git tree, where it aims to support the two most recent major releases of Emacs: currently 27 and 28. Part of that means tending to a menagerie of adapters here on trunk. However, going forward, we'd like to offload the bulk of this upkeep to the purpose-built library 'compat'. The patch below details the changes we'd need, but the crux is really this addition here: @@ -26,6 +26,7 @@ ;; This mostly defines stuff that cannot be worked around easily. ;;; Code: +(require 'compat nil 'noerror) ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat") (define-obsolete-function-alias 'erc-define-minor-mode We bring this to your attention in hopes of addressing any concerns that may arise over its (hopefully imminent) inclusion. FWIW, occasional external dependencies crop up elsewhere within the Emacs tree. But most, like `gnus-read-ephemeral-emacs-bug-group', appear to be supplemental and integrations-focused rather than top-level affairs affecting decent swaths of code (true in our case for Emacs 27). I've Cc'd Philip, compat's author, who's far better equipped to field any nontrivial questions. Thanks, J.P. Related discussions: https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg01546.html https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg00338.html https://lists.gnu.org/archive/html/emacs-erc/2022-07/msg00006.html --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-compat-from-GNU-ELPA-as-a-soft-dependency-in-ERC.patch >From f41d13548df11ba6d947e364fb893083ecf8d2f8 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Fri, 8 Jul 2022 04:58:26 -0700 Subject: [PATCH 1/1] Add compat from GNU ELPA as a soft dependency in ERC * lisp/erc/erc-backend.el (erc-parse-server-response, erc--parse-isupport-value): Remove sub-28 compat code involving `string-search'. * lisp/erc/erc-compat.el: Require compat package, but don't error when absent. * lisp/erc/erc-dcc.el (erc-dcc-member): Remove `string-search' compat code. (erc-dcc-unquote-filename): Remove `string-replace' compat code. * lisp/erc/erc-speedbar.el (erc-speedbar-expand-server, erc-speedbar-expand-channel, erc-speedbar-expand-user): Remove `string-search' compat code. * lisp/erc/erc.el: Add compat version 28.1.2.0 to Package-Requires header and require `erc-compat' after other libraries. (erc--valid-local-channel-p): Remove `string-search' compat code. (erc-update-mode-line-buffer): Remove `string-replace' compat code. (erc-message-english-PART): Remove `string-replace' compat code. --- lisp/erc/erc-backend.el | 24 ++++++------------------ lisp/erc/erc-compat.el | 1 + lisp/erc/erc-dcc.el | 12 ++---------- lisp/erc/erc-speedbar.el | 24 ++++++------------------ lisp/erc/erc.el | 33 +++++++++++---------------------- 5 files changed, 26 insertions(+), 68 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 8be4894ecb..15ecaab76d 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1012,21 +1012,15 @@ erc-parse-server-response (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 +1030,7 @@ erc-parse-server-response (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 +1038,7 @@ erc-parse-server-response (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)) @@ -1667,9 +1657,7 @@ erc--parse-isupport-value 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 16cfb15a5a..f24fe746ef 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -26,6 +26,7 @@ ;; This mostly defines stuff that cannot be worked around easily. ;;; Code: +(require 'compat nil 'noerror) ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat") (define-obsolete-function-alias 'erc-define-minor-mode diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index d0e1848e0e..7a24acc433 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -191,9 +191,7 @@ erc-dcc-member 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 @@ erc-dcc-ctcp-query-send-regexp (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. diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el index 5b06c21612..19113c5aad 100644 --- a/lisp/erc/erc-speedbar.el +++ b/lisp/erc/erc-speedbar.el @@ -139,9 +139,7 @@ erc-speedbar-server-buttons 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 @@ erc-speedbar-expand-server (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 @@ erc-speedbar-expand-channel "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 @@ erc-speedbar-expand-channel (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 @@ erc-speedbar-update-channel (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 @@ erc-speedbar-expand-user 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 0a16831fba..33044f7fef 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 @@ erc--valid-local-channel-p "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. @@ -7004,21 +7004,12 @@ erc-update-mode-line-buffer (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 +7294,7 @@ erc-message-english-PART 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)) ""))))) -- 2.36.1 --=-=-=--