From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.erc.general,gmane.emacs.help Subject: Re: erc-kill-buffer-stay Date: Tue, 26 Feb 2019 21:50:20 +0100 Message-ID: <865zt6uveb.fsf@zoho.eu> References: <86ef7uuzvv.fsf@zoho.eu> <2392751551213795@iva1-4ad1e49a78b2.qloud-c.yandex.net> Reply-To: ERC Discussion Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="76093"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: erc-discuss@gnu.org Original-X-From: erc-discuss-bounces+sf-erc-help=m.gmane.org@gnu.org Tue Feb 26 22:03:03 2019 Return-path: Envelope-to: sf-erc-help@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 1gyjsT-000Jdt-Fs for sf-erc-help@m.gmane.org; Tue, 26 Feb 2019 22:03:01 +0100 Original-Received: from localhost ([127.0.0.1]:33193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyjsS-0002vz-A8 for sf-erc-help@m.gmane.org; Tue, 26 Feb 2019 16:03:00 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyjgX-0001QZ-TP for erc-discuss@gnu.org; Tue, 26 Feb 2019 15:50:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyjgW-0003o4-Rb for erc-discuss@gnu.org; Tue, 26 Feb 2019 15:50:41 -0500 Original-Received: from [195.159.176.226] (port=41508 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyjgW-0003kB-Ju for erc-discuss@gnu.org; Tue, 26 Feb 2019 15:50:40 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1gyjgQ-0005FH-F4 for erc-discuss@gnu.org; Tue, 26 Feb 2019 21:50:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: erc-discuss@gnu.org Original-Followup-To: gmane.emacs.help Mail-Copies-To: never Cancel-Lock: sha1:LSc2a6qm4sLenqQsLxTl1QPM19M= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: erc-discuss@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: ERC Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: erc-discuss-bounces+sf-erc-help=m.gmane.org@gnu.org Original-Sender: "Erc-discuss" Xref: news.gmane.org gmane.emacs.erc.general:1457 gmane.emacs.help:119535 Archived-At: Bad Blue Bull wrote: > how it's diffirent from "/part" ? Here is /part: (defun erc-cmd-PART (line) "When LINE is an empty string, leave the current channel. Otherwise leave the channel indicated by LINE." (cond ((string-match "^\\s-*\\([&#+!]\\S-+\\)\\s-?\\(.*\\)$" line) (let* ((ch (match-string 1 line)) (msg (match-string 2 line)) (reason (funcall erc-part-reason (if (equal msg "") nil msg)))) (erc-log (format "cmd: PART: %s: %s" ch reason)) (erc-server-send (if (string= reason "") (format "PART %s" ch) (format "PART %s :%s" ch reason)) nil ch)) t) ((string-match "^\\s-*\\(.*\\)$" line) (let* ((ch (erc-default-target)) (msg (match-string 1 line)) (reason (funcall erc-part-reason (if (equal msg "") nil msg)))) (if (and ch (erc-channel-p ch)) (progn (erc-log (format "cmd: PART: %s: %s" ch reason)) (erc-server-send (if (string= reason "") (format "PART %s" ch) (format "PART %s :%s" ch reason)) nil ch)) (erc-display-message nil 'error (current-buffer) 'no-target))) t) (t nil))) And here is my function: (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) ))))) -- underground experts united http://user.it.uu.se/~embe8573