Subject: bug#21187: erc-kill-channel-hook sometimes is not run during /QUIT

From: Fran Litterio <[email-masked]>
Date: Tue, 4 Aug 2015 17:56:23 +0000 (UTC)

Using Emacs built from the latest sources, when variable
erc-kill-queries-on-quit is t (which causes ERC to kill channel
buffers when quitting -- yes, the name is misleading), a /QUIT
does not run the hooks on erc-kill-channel-hook, because
erc-default-target returns nil due to the server being
disconnected.

This patch fixes that by falling back to examining the buffer
name, which should be safe to do since we know the major mode is
erc-mode.
--
Fran
flitterio <at> gmail.com

--- erc.el.orig	2015-08-04 13:38:04.602900800 -0400
+++ erc.el	2015-08-04 13:38:56.538768600 -0400
@@ -6698,7 +6698,7 @@
     (cond
      ((eq (erc-server-buffer) (current-buffer))
       (run-hooks 'erc-kill-server-hook))
-     ((erc-channel-p (erc-default-target))
+     ((erc-channel-p (or (erc-default-target) (buffer-name)))
       (run-hooks 'erc-kill-channel-hook))
      (t
       (run-hooks 'erc-kill-buffer-hook)))))