From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: [PATCHv2] erc: fix erc-reuse-buffers behavior Date: Mon, 27 Jul 2020 15:33:43 +0300 Message-ID: <87o8o1t9w8.fsf@tcd.ie> References: <87mu3p4bwm.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4508"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: bandali@gnu.org, emacs-devel@gnu.org To: "Mingde (Matthew) Zeng" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 27 14:34:42 2020 Return-path: Envelope-to: ged-emacs-devel@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 1k02L4-00014i-6q for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Jul 2020 14:34:42 +0200 Original-Received: from localhost ([::1]:47582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k02L3-0004kV-9L for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Jul 2020 08:34:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k02KH-0003tm-Ft for emacs-devel@gnu.org; Mon, 27 Jul 2020 08:33:53 -0400 Original-Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:36414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k02KF-0007cG-1F for emacs-devel@gnu.org; Mon, 27 Jul 2020 08:33:53 -0400 Original-Received: by mail-wm1-x330.google.com with SMTP id 3so7655431wmi.1 for ; Mon, 27 Jul 2020 05:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=krLVikpGo59Je6wUnksamb8RwzGPtHMf/EPcX06hWNw=; b=xLZ6DeR8/+XLYP3cu9YOdvsAush7gBsrAJX95NnHm9n0V7Xu7pj1CQCrgoITDDHtqL mV2ywBsi566wymzaUOm+Bjk7ApcFzG3r6zgEKllK/QyDGZ1esJ4M68SAnEGdobtStq5K L71dJkEZtQ/NzQcTrJ+NpOQ1gkBWF09/OMQmwtjsoL6gpR5AAYZb5zxDExwIiqD8txnc 0IJO0rXCEkXyi0cg02kVLSqXJwqvTeCrdjQ4nVKCqVS+e8zZNGE+kmkdVp5kGrQCjYhn w47HUYTEmb9o+gWr49RQOUWC4g/11xqwKqGMGLlDxAnM7gyIVNm+nGZLjxzlRuuvTZHz oFfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=krLVikpGo59Je6wUnksamb8RwzGPtHMf/EPcX06hWNw=; b=p1UTe2RUQlW15P951Owt/gIJf21IsfoXdiTcSLtGuj2R0pVtpxCHkKUYdg8i7/Yd0V JujBKqRp+C7xcW3fJeC2h9/xOOS5a0qj5VpZboUtkS9Oypkm6rZ0ZVFvwN3qBoDHHSE1 s2v9+A0ZEV1aUQFHQq4n0EyVb0Cxme0v188uJkKOHtTdjGcoAPyAYHZbdabfUYT8cEbh koybhX7TLdVBAXirtIqLPQectcHj0JyhjH8mvcNxPiK4SIM3GqID0CxlMwv8dm26YUzs OBHakch3HhL3gozB44hif/3mn42GSSqFJzWcNniFPSuiZvZRqvdTrwPK7BOQX8t5mWvw iTNQ== X-Gm-Message-State: AOAM530NTgAG7OxUGbpvOVepKFr1rBLlvsQookhHIr0ReAN/sE1VhxX0 +YhZo+3FP1dF4XG6Mmbroaz5PQ== X-Google-Smtp-Source: ABdhPJz/mBA4mwuPnNpAqS3VCQvGt2Bnrto3UEfxpbcAQw08UOB218eo9xo3svXw4srnaDfPc3xRmg== X-Received: by 2002:a1c:6007:: with SMTP id u7mr21046850wmb.32.1595853227822; Mon, 27 Jul 2020 05:33:47 -0700 (PDT) Original-Received: from localhost ([80.233.34.202]) by smtp.gmail.com with ESMTPSA id h23sm17049581wmb.3.2020.07.27.05.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 05:33:46 -0700 (PDT) In-Reply-To: <87mu3p4bwm.fsf@gmail.com> (Mingde (Matthew) Zeng's message of "Fri, 24 Jul 2020 03:20:25 -0400") Received-SPF: none client-ip=2a00:1450:4864:20::330; envelope-from=contovob@tcd.ie; helo=mail-wm1-x330.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:253286 Archived-At: Just some minor nits from me. > diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el > index 280d6bfe0f..c59f7118d1 100644 > --- a/lisp/erc/erc-join.el > +++ b/lisp/erc/erc-join.el > @@ -153,18 +153,20 @@ This function is run from `erc-nickserv-identified-hook'." > 'erc-autojoin-channels-delayed > server nick (current-buffer)))) > ;; `erc-autojoin-timing' is `connect': > - (dolist (l erc-autojoin-channels-alist) > - (when (string-match (car l) server) > - (let ((server (or erc-session-server erc-server-announced-name))) > + (let ((server (or erc-session-server erc-server-announced-name))) > + (dolist (l erc-autojoin-channels-alist) > + (when (string-match (car l) server) Can this and other occurrences of string-match be replaced with string-match-p? > diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el > index 3880778794..2b2cc578d9 100644 > --- a/lisp/erc/erc.el > +++ b/lisp/erc/erc.el > @@ -1606,33 +1606,45 @@ symbol, it may have these values: > (defun erc-generate-new-buffer-name (server port target) > "Create a new buffer name based on the arguments." > (when (numberp port) (setq port (number-to-string port))) > - (let ((buf-name (or target > - (or (let ((name (concat server ":" port))) > - (when (> (length name) 1) > - name)) > - ;; This fallback should in fact never happen > - "*erc-server-buffer*"))) > - buffer-name) > + (let* ((buf-name (or target > + (or (let ((name (concat server ":" port))) > + (when (> (length name) 1) > + name)) > + ;; This fallback should in fact never happen > + "*erc-server-buffer*"))) Isn't (or A (or B C)) the same as (or A B C)? Please also end sentences with a full stop. > + (full-buf-name (concat buf-name "/" server)) > + (dup-buf-name (car (mapcar #'(lambda (chanbuf) > + (buffer-name chanbuf)) > + (erc-channel-list nil)))) AKA (buffer-name (car (erc-channel-list nil)))? FWIW, #' is redundant on (lambda ...) in Elisp. > + buffer-name) > ;; Reuse existing buffers, but not if the buffer is a connected server > ;; buffer and not if its associated with a different server than the > ;; current ERC buffer. > ;; if buf-name is taken by a different connection (or by something !erc) > ;; then see if "buf-name/server" meets the same criteria > - (dolist (candidate (list buf-name (concat buf-name "/" server))) > - (if (and (not buffer-name) > - erc-reuse-buffers > - (or (not (get-buffer candidate)) > - (or target > - (with-current-buffer (get-buffer candidate) > - (and (erc-server-buffer-p) > - (not (erc-server-process-alive))))) > - (with-current-buffer (get-buffer candidate) > - (and (string= erc-session-server server) > - (erc-port-equal erc-session-port port))))) > - (setq buffer-name candidate))) > + (if (and dup-buf-name (string-match (concat buf-name "/") dup-buf-name)) > + (setq buffer-name full-buf-name) ; already exists erc buffer with the full name The comment is a bit unclear - should it instead say "ERC buffer with the full name already exists."? > + (dolist (candidate (list buf-name full-buf-name)) > + (if (and (not buffer-name) > + erc-reuse-buffers > + (or (not (get-buffer candidate)) > + (with-current-buffer (get-buffer candidate) > + (and (erc-server-buffer-p) > + (not (erc-server-process-alive)))) > + (with-current-buffer (get-buffer candidate) > + (and (string= erc-session-server server) > + (erc-port-equal erc-session-port port))))) > + (setq buffer-name candidate) > + (when (and (not buffer-name) (get-buffer buf-name) erc-reuse-buffers) > + ;; a new buffer will be created with the name buf-name/server, rename > + ;; the existing name-duplicated buffer with the same format as well Ditto re: starting sentences with a capital letter and ending with a full stop. Thanks, -- Basil