From 49da19f67a7d502563af92f60a43af846b69112f Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Mon, 21 Jun 2021 12:01:51 +0200 Subject: [PATCH] Improved PART handling. --- lirc.el | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lirc.el b/lirc.el index 0767a46..5244c2f 100644 --- a/lirc.el +++ b/lirc.el @@ -379,10 +379,12 @@ portion of the source component of the message, as LIRC doesn't use this.") ((and "PART" (guard (equal lirc-nick (lirc-msg-src msg)))) - (lirc-display-notice "Left channel " lirc-current-channel) - (setq lirc-current-channel nil) - (lirc-del-channel (car (lirc-msg-params msg))) - (lirc-render-prompt)) + (let ((channel (car (lirc-msg-params msg)))) + (lirc-display-notice "Left channel " channel) + (lirc-del-channel (car (lirc-msg-params msg))) + (when (equal lirc-current-channel channel) + (setq lirc-current-channel nil) + (lirc-render-prompt)))) ("PART" (let ((channel (car (lirc-msg-params msg))) @@ -470,8 +472,12 @@ portion of the source component of the message, as LIRC doesn't use this.") (list nick "\01VERSION\01"))) (lirc-display-notice "CTCP version request sent to " nick)) - ((rx "PART") - (lirc-send-msg (lirc-msg nil nil "PART" lirc-current-channel))) + ((rx "PART" (opt (: " " (let channel (* not-newline))))) + (if (or lirc-current-channel channel) + (lirc-send-msg (lirc-msg nil nil "PART" (if channel + channel + lirc-current-channel))) + (lirc-display-error "No current channel to leave."))) ((rx "MSG " (let target (* (not whitespace))) @@ -488,8 +494,11 @@ portion of the source component of the message, as LIRC doesn't use this.") nil))))) (unless (string-empty-p string) - (lirc-send-msg (lirc-msg nil nil "PRIVMSG" lirc-current-channel string)) - (lirc-display-message lirc-current-channel lirc-nick string)))) + (if lirc-current-channel + (progn + (lirc-send-msg (lirc-msg nil nil "PRIVMSG" lirc-current-channel string)) + (lirc-display-message lirc-current-channel lirc-nick string)) + (lirc-display-error "No current channel."))))) (defun lirc-enter () "Enter current contents of line after prompt." -- 2.20.1