The Lambda Lab
/
projects
/
lurk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5d44f82
)
Added context switching primitives.
author
plugd
<plugd@thelambdalab.xyz>
Mon, 20 May 2024 12:35:33 +0000
(14:35 +0200)
committer
plugd
<plugd@thelambdalab.xyz>
Sun, 26 May 2024 19:14:04 +0000
(21:14 +0200)
murk.el
patch
|
blob
|
history
diff --git
a/murk.el
b/murk.el
index
e15bc84
..
64bc81d
100644
(file)
--- a/
murk.el
+++ b/
murk.el
@@
-53,7
+53,8
@@
'(("debug" "localhost" 6697)
("libera" "irc.libera.chat" 6697)
("tilde" "tilde.chat" 6697)
'(("debug" "localhost" 6697)
("libera" "irc.libera.chat" 6697)
("tilde" "tilde.chat" 6697)
- ("freenode" "chat.freenode.net" 6697))
+ ("freenode" "chat.freenode.net" 6697)
+ ("mbr" "mbrserver.com" 6667 :notls))
"IRC networks."
:type '(alist :key-type string))
"IRC networks."
:type '(alist :key-type string))
@@
-312,12
+313,20
@@
The head of this list is always the current context.")
(equal (seq-take c1 2)
(seq-take c2 2)))))
(equal (seq-take c1 2)
(seq-take c2 2)))))
-(defun murk-context-server (ctx) (elt ctx 0))
-(defun murk-context-channel (ctx) (elt ctx 1))
-(defun murk-context-users (ctx) (elt ctx 2))
+(defun murk-context-server (ctx)
+ (elt ctx 0))
+
+(defun murk-context-channel (ctx)
+ (elt ctx 1))
+
+(defun murk-context-users (ctx)
+ (elt ctx 2))
+
(defun murk-set-context-users (ctx users)
(setcar (cddr ctx) users))
(defun murk-set-context-users (ctx users)
(setcar (cddr ctx) users))
-(defun murk-server-context-p (ctx) (not (cdr ctx)))
+
+(defun murk-server-context-p (ctx)
+ (not (cdr ctx)))
(defun murk-add-context (ctx)
(add-to-list 'murk-contexts ctx))
(defun murk-add-context (ctx)
(add-to-list 'murk-contexts ctx))
@@
-340,9
+349,17
@@
The head of this list is always the current context.")
(concat (murk-context-channel ctx) "@"
(murk-context-server ctx))))
(concat (murk-context-channel ctx) "@"
(murk-context-server ctx))))
-(defun murk-get-context (server &optional name)
- (if name
- (let ((test-ctx (list server name)))
+(defun murk-string->context (string)
+ (if (not (string-prefix-p "#" string))
+ (murk-get-context string)
+ (let* ((parts (string-split string "@"))
+ (channel (elt parts 0))
+ (server (elt parts 1)))
+ (murk-get-context server channel))))
+
+(defun murk-get-context (server &optional channel)
+ (if channel
+ (let ((test-ctx (list server channel)))
(seq-find (lambda (ctx)
(equal (seq-take ctx 2) test-ctx))
murk-contexts))
(seq-find (lambda (ctx)
(equal (seq-take ctx 2) test-ctx))
murk-contexts))
@@
-357,6
+374,13
@@
The head of this list is always the current context.")
(seq-take murk-contexts nminus1)))
(append (cdr murk-contexts) (list (car murk-contexts))))))
(seq-take murk-contexts nminus1)))
(append (cdr murk-contexts) (list (car murk-contexts))))))
+(defun murk-switch-to-context (ctx)
+ (setq murk-contexts
+ (let* ((new-head (memq ctx murk-contexts))
+ (new-tail (take (- (length murk-contexts)
+ (length new-head)))))
+ (append new-head new-tail))))
+
(defun murk-add-context-users (ctx users)
(murk-set-context-users
ctx
(defun murk-add-context-users (ctx users)
(murk-set-context-users
ctx