erc-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Erc-discuss] erc-kill-buffer-stay


From: Emanuel Berg
Subject: Re: [Erc-discuss] erc-kill-buffer-stay
Date: Tue, 26 Feb 2019 21:50:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]