From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Bob Proulx Newsgroups: gmane.emacs.help Subject: Re: erc-kill-buffer-stay Date: Tue, 26 Feb 2019 12:38:39 -0700 Message-ID: <20190226122219763066763@bob.proulx.com> References: <86ef7uuzvv.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="265861"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 26 20:42:10 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyicC-001729-DY for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Feb 2019 20:42:08 +0100 Original-Received: from localhost ([127.0.0.1]:60344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyicA-00081X-AQ for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Feb 2019 14:42:06 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyiZG-0005oB-Bt for help-gnu-emacs@gnu.org; Tue, 26 Feb 2019 14:39:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyiZC-0002lR-W2 for help-gnu-emacs@gnu.org; Tue, 26 Feb 2019 14:39:06 -0500 Original-Received: from havoc.proulx.com ([96.88.95.61]:37450) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyiZ4-0002Sm-V9 for help-gnu-emacs@gnu.org; Tue, 26 Feb 2019 14:38:59 -0500 Original-Received: from joseki.proulx.com (localhost [127.0.0.1]) by havoc.proulx.com (Postfix) with ESMTP id C1D301FC for ; Tue, 26 Feb 2019 12:38:40 -0700 (MST) Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 9DA4721241 for ; Tue, 26 Feb 2019 12:38:39 -0700 (MST) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id 7A3102DC7C; Tue, 26 Feb 2019 12:38:39 -0700 (MST) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <86ef7uuzvv.fsf@zoho.eu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 96.88.95.61 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119533 Archived-At: Emanuel Berg wrote: > Is something like this already present in ERC? > If so I didn't find it, and I think it is very > handy. I don't know but wanted to ask about not seeing a channel PART in the routine. > Also feel free to suggest improvements to the code, as alays. > (defun erc-kill-buffer-stay () > "Close the current ERC buffer (i.e., leave the channel) > but stay in ERC." > (interactive) > (when (or (not (erc-server-buffer-live-p)) > (= ?y (read-char "press `y' to leave the channel")) ) > (let ((erc-buffers (erc-buffer-list))) > (if (= 1 (length erc-buffers)) (kill-buffer) > (cl-loop for b in erc-buffers > when (neq b (current-buffer)) > do (kill-buffer) > (switch-to-buffer b) > (cl-return) ))))) Are you counting on erc-kill-channel-hook to contain erc-kill-channel (by default it does) to have it leave /PART the channel? AFAIK erc-kill-buffer-function calls erc-kill-channel-hook which by default contains erc-kill-channel function. https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/erc/erc.el#n6724 https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/erc/erc.el#n6761 I found that behavior of channel parting incompatible when using an irc bouncer proxy as the entire purpose of the proxy is to remain connected when the client disconnects. Therefore when using an irc bouncer such as ZNC or others one *must* remove erc-kill-channel from erc-kill-channel-hook or nothing works as desired. I think for robustness it should explicitly erc-cmd-PART in there somewhere. Try it with the hook removed to see what I mean. (remove-hook 'erc-kill-channel-hook 'erc-kill-channel) ; or (setq erc-kill-channel-hook nil) Bob