emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 4541e31 2/4: Handle argument to rcirc /part properl


From: Noam Postavsky
Subject: [Emacs-diffs] master 4541e31 2/4: Handle argument to rcirc /part properly (Bug#11157)
Date: Sat, 1 Jun 2019 20:08:33 -0400 (EDT)

branch: master
commit 4541e31d9c522df3cef6e7ab939655f6f92e7fb4
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Handle argument to rcirc /part properly (Bug#11157)
    
    * lisp/net/rcirc.el (part): Split out channel name and part reason.
    * doc/misc/rcirc.texi (rcirc commands): Clarify that channel name may
    be provided to /part.
---
 doc/misc/rcirc.texi |  7 ++++---
 lisp/net/rcirc.el   | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/doc/misc/rcirc.texi b/doc/misc/rcirc.texi
index bbcd0ed..1482a14 100644
--- a/doc/misc/rcirc.texi
+++ b/doc/misc/rcirc.texi
@@ -337,9 +337,10 @@ channel name and join that channel.  (Also @code{/join 
#emacs}.)
 @cindex disconnect from a channel
 @cindex stop talking on a channel
 @cindex kill channel buffer
-This leaves the current channel.  You can optionally provide a reason
-for parting.  When you kill a channel buffer, you automatically part the
-corresponding channel.  (Also @code{/part you are too weird!}.)
+This leaves the current channel.  You can optionally provide a
+different channel name and reason for parting.  When you kill a
+channel buffer, you automatically part the corresponding channel.
+(Also @code{/part #emacs you are too weird!}.)
 
 @item C-c C-r
 @kindex C-c C-r
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 50cab7b..b317f00 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -2185,12 +2185,21 @@ CHANNELS is a comma- or space-separated string of 
channel names."
                 (read-string "Channel: "))))
   (rcirc-send-string process (concat "INVITE " nick-channel)))
 
-;; TODO: /part #channel reason, or consider removing #channel altogether
 (defun-rcirc-command part (channel)
-  "Part CHANNEL."
+  "Part CHANNEL.
+CHANNEL should be a string of the form \"#CHANNEL-NAME REASON\".
+If omitted, CHANNEL-NAME defaults to TARGET, and REASON defaults
+to `rcirc-id-string'."
   (interactive "sPart channel: ")
-  (let ((channel (if (> (length channel) 0) channel target)))
-    (rcirc-send-string process (concat "PART " channel " :" rcirc-id-string))))
+  (let ((channel (if (> (length channel) 0) channel target))
+        (msg rcirc-id-string))
+    (when (string-match "\\`\\([&#+!]\\S-+\\)?\\s-*\\(.+\\)?\\'" channel)
+      (when (match-beginning 2)
+        (setq msg (match-string 2 channel)))
+      (setq channel (if (match-beginning 1)
+                        (match-string 1 channel)
+                      target)))
+    (rcirc-send-string process (concat "PART " channel " :" msg))))
 
 (defun-rcirc-command quit (reason)
   "Send a quit message to server with REASON."



reply via email to

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