murk-contexts)))
(defun murk-context->string (ctx)
+ (concat
(if (murk-network-context-p ctx)
- (concat "[" (murk-context-network ctx) "]")
- (concat (murk-context-channel ctx) "@"
- (murk-context-network ctx))))
+ ""
+ (concat (murk-context-channel ctx) "@"))
+ (murk-context-network ctx)))
(defun murk-string->context (string)
(if (not (string-prefix-p "#" string))
(setq murk-contexts
(let* ((new-head (memq ctx murk-contexts))
(new-tail (take (- (length murk-contexts)
- (length new-head)))))
+ (length new-head))
+ murk-contexts)))
(append new-head new-tail))))
(defun murk-add-context-users (ctx users)
("CONNECT" "Connect to an IRC network." murk-command-connect murk-network-completions)
("QUIT" "Disconnect from current network." murk-command-quit)
("JOIN" "Join one or more channels." murk-command-join)
- ("PART" "Leave channel." murk-command-part murk-context-completions)
+ ("PART" "Leave channel." murk-command-part murk-channel-completions)
+ ("SWITCHCONTEXT" "Switch current context" murk-command-switch-context murk-context-completions)
("NICK" "Change nick." murk-command-nick)
("LIST" "Display details of one or more channels." murk-command-list)
("TOPIC" "Set/query topic for current channel." murk-command-topic)
- ("USERS" "List nicks of users in current context." murk-command-users)
+ ("USERS" "List nicks of users in current channel." murk-command-users)
("MSG" "Send private message to user." murk-command-msg murk-nick-completions)
("ME" "Display action." murk-command-me)
("VERSION" "Request version of another user's client via CTCP." murk-command-version murk-nick-completions)
(defun murk-network-completions ()
(mapcar (lambda (row) (car row)) murk-networks))
+(defun murk-help-completions ()
+ (mapcar (lambda (row) (car row)) murk-command-table))
+
+(defun murk-channel-completions ()
+ (mapcar (lambda (ctx)
+ (murk-context->string ctx))
+ (seq-filter (lambda (ctx)
+ (not (murk-network-context-p ctx)))
+ murk-contexts)))
+
+(defun murk-context-completions ()
+ (mapcar (lambda (ctx) (murk-context->string ctx)) murk-contexts))
+
(defun murk-command-help (params)
(if params
(let* ((cmd-str (upcase (car params)))
(murk-display-notice nil "Usage: /join channel [channel2 ...]")))
(defun murk-command-part (params)
- (let* ((network (murk-context-network (murk-current-context)))
- (channel (if params
- (car params)
- (murk-context-channel (murk-current-context)))))
- (if channel
- (murk-send-msg network (murk-msg nil nil "PART" channel))
- (murk-display-error "No current channel to leave"))))
+ (let ((ctx (cond
+ ((not params) (murk-current-context))
+ ((seq-contains (car params) "@") (murk-string->context (car params)))
+ (t (list (murk-context-network (murk-current-context)) (car params))))))
+ (let ((network (murk-context-network ctx))
+ (channel (murk-context-channel ctx)))
+ (if channel
+ (murk-send-msg network (murk-msg nil nil "PART" channel))
+ (murk-display-error "Specify which channel to leave")))))
+
+(defun murk-command-switch-context (params)
+ (if (not params)
+ (murk-display-notice nil "Usage: /switchcontext #channel@network")
+ (let ((ctx (murk-string->context (car params))))
+ (murk-switch-to-context ctx)
+ (murk-highlight-current-context)
+ (murk-render-prompt)
+ (if murk-zoomed
+ (murk-zoom-in (murk-current-context))))))
(defun murk-command-nick (params)
(if params