From: Emanuel Berg <moasenwood@zoho.eu>
To: erc-discuss@gnu.org
Cc: help-gnu-emacs@gnu.org
Subject: Re: erc-kill-buffer-stay
Date: Tue, 26 Feb 2019 21:50:20 +0100 [thread overview]
Message-ID: <865zt6uveb.fsf@zoho.eu> (raw)
In-Reply-To: 2392751551213795@iva1-4ad1e49a78b2.qloud-c.yandex.net
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
next prev parent reply other threads:[~2019-02-26 20:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-26 19:13 erc-kill-buffer-stay Emanuel Berg
2019-02-26 19:38 ` erc-kill-buffer-stay Bob Proulx
2019-02-27 8:58 ` erc-kill-buffer-stay Emanuel Berg
2019-03-01 16:33 ` erc-kill-buffer-stay Emanuel Berg
2019-02-26 20:43 ` erc-kill-buffer-stay Bad Blue Bull
2019-02-26 20:50 ` Emanuel Berg [this message]
2019-02-26 22:31 ` erc-kill-buffer-stay Bad Blue Bull
2019-02-27 8:59 ` erc-kill-buffer-stay Emanuel Berg
2019-03-13 20:33 ` erc-kill-buffer-stay Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=865zt6uveb.fsf@zoho.eu \
--to=moasenwood@zoho.eu \
--cc=erc-discuss@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).