]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle argument to rcirc /part properly (Bug#11157)
authorNoam Postavsky <npostavs@gmail.com>
Mon, 27 May 2019 00:17:38 +0000 (20:17 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Sun, 2 Jun 2019 00:01:43 +0000 (20:01 -0400)
* 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
lisp/net/rcirc.el

index bbcd0ed4620144257a98ab92773a58772483ee3a..1482a14fad5265a99a55fbf95f4977f3034ab7cd 100644 (file)
@@ -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
index 50cab7bd160aa7a7537235409d604099f4036764..b317f002ee99802bfbf1410d0d1facad5fe9f2ce 100644 (file)
@@ -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."