Function: erc-cmd-TOPIC

erc-cmd-TOPIC is a byte-compiled function defined in erc.el.gz.

Signature

(erc-cmd-TOPIC TOPIC)

Documentation

Set or request the topic for a channel.

LINE has the format: "#CHANNEL TOPIC", "#CHANNEL", "TOPIC" or the empty string.

If no #CHANNEL is given, the default channel is used. If TOPIC is given, the channel topic is modified, otherwise the current topic will be displayed.

Aliases

erc-cmd-T

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-cmd-TOPIC (topic)
  "Set or request the topic for a channel.
LINE has the format: \"#CHANNEL TOPIC\", \"#CHANNEL\", \"TOPIC\"
or the empty string.

If no #CHANNEL is given, the default channel is used.  If TOPIC is
given, the channel topic is modified, otherwise the current topic will
be displayed."
  (cond
   ;; /topic #channel TOPIC
   ((string-match "^\\s-*\\([&#+!]\\S-+\\)\\s-\\(.*\\)$" topic)
    (let ((ch (match-string 1 topic))
          (topic (match-string 2 topic)))
      ;; Ignore all-whitespace topics.
      (unless (equal (string-trim topic) "")
	(erc-log (format "cmd: TOPIC [%s]: %s" ch topic))
	(erc-server-send (format "TOPIC %s :%s" ch topic) nil ch)))
    t)
   ;; /topic #channel
   ((string-match "^\\s-*\\([&#+!]\\S-+\\)" topic)
    (let ((ch (match-string 1 topic)))
      (erc-server-send (format "TOPIC %s" ch) nil ch)
      t))
   ;; /topic
   ((string-match "^\\s-*$" topic)
    (let ((ch (erc-default-target)))
      (erc-server-send (format "TOPIC %s" ch) nil ch)
      t))
   ;; /topic TOPIC
   ((string-match "^\\s-*\\(.*\\)$" topic)
    (let ((ch (erc-default-target))
          (topic (match-string 1 topic)))
      (if (and ch (erc-channel-p ch))
          (progn
            (erc-log (format "cmd: TOPIC [%s]: %s" ch topic))
            (erc-server-send (format "TOPIC %s :%s" ch topic) nil ch))
        (erc-display-message nil 'error (current-buffer) 'no-target)))
    t)
   (t nil)))