Skip to content

Commit

Permalink
Merged PR legoscia#2
Browse files Browse the repository at this point in the history
  • Loading branch information
cngimenez committed May 18, 2022
2 parents 7e082f6 + deb4406 commit 35bdcf8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
23 changes: 11 additions & 12 deletions jabber.el
Original file line number Diff line number Diff line change
Expand Up @@ -10559,18 +10559,17 @@ Optional argument GROUP to look."
;; [[file:jabber.org::#sort-nicks][jabber-sort-nicks:1]]
(defun jabber-sort-nicks (nicks group)
"Return list of NICKS in GROUP, sorted."
(let ((times (cdr (assoc group *jabber-muc-participant-last-speaking*))))
(flet ((fetch-time (nick) (or (assoc nick times) (cons nick 0)))
(cmp (nt1 nt2)
(let ((t1 (cdr nt1))
(t2 (cdr nt2)))
(if (and (zerop t1) (zerop t2))
(string<
(car nt1)
(car nt2))
(> t1 t2)))))
(mapcar 'car (sort (mapcar #'fetch-time nicks)
'cmp)))))
(cl-letf* ((times (cdr (assoc group *jabber-muc-participant-last-speaking*)))
((symbol-function 'fetch-time) (lambda (nick) (or (assoc nick times)
(cons nick 0))))
((symbol-function 'cmp) (lambda (nt1 nt2)
(let ((t1 (cdr nt1))
(t2 (cdr nt2)))
(if (and (zerop t1) (zerop t2))
(string< (car nt1)
(car nt2))
(> t1 t2))))))
(mapcar #'car (sort (mapcar #'fetch-time nicks) #'cmp))))
;; jabber-sort-nicks:1 ends here

;; [[file:jabber.org::#muc-beginning-of-line][jabber-muc-beginning-of-line:1]]
Expand Down
27 changes: 13 additions & 14 deletions jabber.org
Original file line number Diff line number Diff line change
Expand Up @@ -13100,20 +13100,19 @@ Optional argument GROUP to look."
:CUSTOM_ID: sort-nicks
:END:
#+BEGIN_SRC emacs-lisp
(defun jabber-sort-nicks (nicks group)
"Return list of NICKS in GROUP, sorted."
(let ((times (cdr (assoc group *jabber-muc-participant-last-speaking*))))
(flet ((fetch-time (nick) (or (assoc nick times) (cons nick 0)))
(cmp (nt1 nt2)
(let ((t1 (cdr nt1))
(t2 (cdr nt2)))
(if (and (zerop t1) (zerop t2))
(string<
(car nt1)
(car nt2))
(> t1 t2)))))
(mapcar 'car (sort (mapcar #'fetch-time nicks)
'cmp)))))
(defun jabber-sort-nicks (nicks group)
"Return list of NICKS in GROUP, sorted."
(cl-letf* ((times (cdr (assoc group *jabber-muc-participant-last-speaking*)))
((symbol-function 'fetch-time) (lambda (nick) (or (assoc nick times)
(cons nick 0))))
((symbol-function 'cmp) (lambda (nt1 nt2)
(let ((t1 (cdr nt1))
(t2 (cdr nt2)))
(if (and (zerop t1) (zerop t2))
(string< (car nt1)
(car nt2))
(> t1 t2))))))
(mapcar #'car (sort (mapcar #'fetch-time nicks) #'cmp))))
#+END_SRC

*** jabber-muc-beginning-of-line :function:
Expand Down

0 comments on commit 35bdcf8

Please sign in to comment.