unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* erc-kill-buffer-stay
@ 2019-02-26 19:13 Emanuel Berg
  2019-02-26 19:38 ` erc-kill-buffer-stay Bob Proulx
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Emanuel Berg @ 2019-02-26 19:13 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: erc-discuss

Is something like this already present in ERC?
If so I didn't find it, and I think it is very
handy. 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) )))))


More ERC stuff:

    http://user.it.uu.se/~embe8573/emacs-init/erc-my.el

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  2019-02-26 19:13 erc-kill-buffer-stay Emanuel Berg
@ 2019-02-26 19:38 ` 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 22:31 ` erc-kill-buffer-stay Bad Blue Bull
  2 siblings, 2 replies; 9+ messages in thread
From: Bob Proulx @ 2019-02-26 19:38 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  2019-02-26 19:13 erc-kill-buffer-stay Emanuel Berg
  2019-02-26 19:38 ` erc-kill-buffer-stay Bob Proulx
@ 2019-02-26 20:43 ` Bad Blue Bull
  2019-02-26 20:50   ` erc-kill-buffer-stay Emanuel Berg
  2019-02-26 22:31 ` erc-kill-buffer-stay Bad Blue Bull
  2 siblings, 1 reply; 9+ messages in thread
From: Bad Blue Bull @ 2019-02-26 20:43 UTC (permalink / raw)
  To: ERC Discussion; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/html, Size: 1715 bytes --]

[-- Attachment #2: Type: text/plain, Size: 144 bytes --]

_______________________________________________
Erc-discuss mailing list
Erc-discuss@gnu.org
https://lists.gnu.org/mailman/listinfo/erc-discuss

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  2019-02-26 20:43 ` erc-kill-buffer-stay Bad Blue Bull
@ 2019-02-26 20:50   ` Emanuel Berg
  0 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2019-02-26 20:50 UTC (permalink / raw)
  To: erc-discuss; +Cc: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  2019-02-26 19:13 erc-kill-buffer-stay Emanuel Berg
  2019-02-26 19:38 ` erc-kill-buffer-stay Bob Proulx
  2019-02-26 20:43 ` erc-kill-buffer-stay Bad Blue Bull
@ 2019-02-26 22:31 ` 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
  2 siblings, 2 replies; 9+ messages in thread
From: Bad Blue Bull @ 2019-02-26 22:31 UTC (permalink / raw)
  To: ERC Discussion; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/html, Size: 2345 bytes --]

[-- Attachment #2: Type: text/plain, Size: 144 bytes --]

_______________________________________________
Erc-discuss mailing list
Erc-discuss@gnu.org
https://lists.gnu.org/mailman/listinfo/erc-discuss

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  2019-02-26 19:38 ` erc-kill-buffer-stay Bob Proulx
@ 2019-02-27  8:58   ` Emanuel Berg
  2019-03-01 16:33   ` erc-kill-buffer-stay Emanuel Berg
  1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2019-02-27  8:58 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: erc-discuss

Bob Proulx 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.

OK, thank you, I'll add it. Just need to
identify the exact line that does it...

Anything else you see in `erc-cmd-PART' that
should be added for formal/technical reasons?

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  2019-02-26 22:31 ` erc-kill-buffer-stay Bad Blue Bull
@ 2019-02-27  8:59   ` Emanuel Berg
  2019-03-13 20:33   ` erc-kill-buffer-stay Emanuel Berg
  1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2019-02-27  8:59 UTC (permalink / raw)
  To: erc-discuss; +Cc: help-gnu-emacs

Bad Blue Bull wrote:

> I don't know, see erc.el:
>  
> (defcustom erc-kill-buffer-on-part nil
>   "Kill the channel buffer on PART.
> This variable should probably stay nil, as ERC can reuse buffers if
> you rejoin them later."
>   :group 'erc-quit-and-part
>   :type 'boolean)
>  
> But I don't see this variable to be used in
> the source  (despite it's value is changed to
> t somewhere in my Emacs session).  But if
> I part a channel and evaluate length of
> buffer-list get's decreased.

I'm not following 100% what you are
saying/suggesting here?
>
-- 
underground experts united
http://user.it.uu.se/~embe8573


_______________________________________________
Erc-discuss mailing list
Erc-discuss@gnu.org
https://lists.gnu.org/mailman/listinfo/erc-discuss

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  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   ` Emanuel Berg
  1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2019-03-01 16:33 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: erc-discuss

> Are you counting on erc-kill-channel-hook to
> contain erc-kill-channel (by default it does)
> to have it leave /PART the channel?

OK, I replaced `kill-buffer' with
`erc-kill-channel'!

I also made a check for an ERC process
(`erc-server-process-alive') so if there is no
process, it won't bother asking whether one
would like to "remain" in the channel.

(defun erc-kill-buffer-cycle ()
  (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 (erc-kill-channel)
                  (switch-to-buffer b)
                  (cl-return) ))))

(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-process-alive))
            (= ?y (read-char "press `y' to leave the channel")))
    (erc-kill-buffer-cycle) ))


Source and more ERC stuff:

    http://user.it.uu.se/~embe8573/emacs-init/erc-my.el

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: erc-kill-buffer-stay
  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   ` Emanuel Berg
  1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2019-03-13 20:33 UTC (permalink / raw)
  To: erc-discuss; +Cc: help-gnu-emacs

I fixed some bugs, but now I'm not going to
report here on every change. If this idea
appeals to anyone, check out

    http://user.it.uu.se/~embe8573/emacs-init/erc-my.el

Keep it unreal.

-- 
underground experts united
http://user.it.uu.se/~embe8573

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-03-13 20:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` erc-kill-buffer-stay Emanuel Berg
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

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).