Skip to content

Commit

Permalink
Merge pull request 'Fixes related to cl.el -> cl-lib.el' (legoscia#24)…
Browse files Browse the repository at this point in the history
… from hdasch/emacs-jabber:illiterate into illiterate

Reviewed-on: https://codeberg.org/emacs-jabber/emacs-jabber/pulls/24
  • Loading branch information
contrapunctus committed Jun 13, 2023
2 parents 7bb78a3 + 42986cc commit d50dd76
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion elisp/jabber-activity.el
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private MUC conversations, return the user's nickname."
(defun jabber-activity-common-prefix (s1 s2)
"Return length of common prefix string shared by S1 and S2."
(let ((len (min (length s1) (length s2))))
(or (dotimes (i len)
(or (cl-dotimes (i len)
(when (not (eq (aref s1 i) (aref s2 i)))
(cl-return i)))
;; Substrings, equal, nil, or empty ("")
Expand Down
8 changes: 4 additions & 4 deletions elisp/jabber-alert.el
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Examples:
(when title
(let* ((case-fold-search t)
(bare-jid (jabber-jid-user from))
(sound-file (or (dolist (entry jabber-alert-message-wave-alist)
(sound-file (or (cl-dolist (entry jabber-alert-message-wave-alist)
(when (string-match (car entry) bare-jid)
(cl-return (cdr entry))))
jabber-alert-message-wave)))
Expand Down Expand Up @@ -415,7 +415,7 @@ This function is not called directly, but can be used as the value for
(when proposed-alert
(let* ((case-fold-search t)
(bare-jid (symbol-name who))
(sound-file (or (dolist (entry jabber-alert-presence-wave-alist)
(sound-file (or (cl-dolist (entry jabber-alert-presence-wave-alist)
(when (string-match (car entry) bare-jid)
(cl-return (cdr entry))))
jabber-alert-presence-wave)))
Expand Down Expand Up @@ -496,7 +496,7 @@ Answer automaticaly when incoming text match the first element of
`jabber-autoanswer-alist'"
(when (and from buffer text proposed-alert jabber-autoanswer-alist)
(let ((message
(dolist (entry jabber-autoanswer-alist)
(cl-dolist (entry jabber-autoanswer-alist)
(when (string-match (car entry) text)
(cl-return (cdr entry))))))
(if message
Expand All @@ -509,7 +509,7 @@ Answer automaticaly when incoming text match first element
of `jabber-autoanswer-alist'."
(when (and nick group buffer text proposed-alert jabber-autoanswer-alist)
(let ((message
(dolist (entry jabber-autoanswer-alist)
(cl-dolist (entry jabber-autoanswer-alist)
(when (string-match (car entry) text)
(cl-return (cdr entry))))))
(if message
Expand Down
2 changes: 1 addition & 1 deletion elisp/jabber-bookmarks.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ immediately, and return nil if it is not in the cache."
(funcall cont jc entry)))))))

(defun jabber-get-conference-data-internal (result conference-jid key)
(let ((entry (dolist (node result)
(let ((entry (cl-dolist (node result)
(when (and (eq (jabber-xml-node-name node) 'conference)
(string= (jabber-xml-get-attribute node 'jid) conference-jid))
(cl-return (jabber-parse-conference-bookmark node))))))
Expand Down
2 changes: 1 addition & 1 deletion elisp/jabber-fallback-lib/srv.el
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ of the list. The list is empty if no SRV records were found."
;; running sum is greater than or equal to this number.
(while weight-order
(let* ((r (random (1+ weight-acc)))
(next-entry (dolist (a weight-order)
(next-entry (cl-dolist (a weight-order)
(if (>= (car a) r)
(cl-return a)))))
(push (cdr next-entry) weighted-result)
Expand Down
2 changes: 1 addition & 1 deletion elisp/jabber-muc.el
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ JC is the Jabber connection."
XML-DATA is the parsed tree data from the stream (stanzas)
obtained from `xml-parse-region'."
(dolist (x (jabber-xml-get-children xml-data 'x))
(cl-dolist (x (jabber-xml-get-children xml-data 'x))
(when (string= (jabber-xml-get-attribute x 'xmlns) "http://jabber.org/protocol/muc#user")
(let ((invitation (car (jabber-xml-get-children x 'invite))))
(when invitation
Expand Down
2 changes: 1 addition & 1 deletion elisp/jabber-presence.el
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Show status properties from highest-priority resource."
(defun jabber-count-connected-resources (buddy)
"Return the number of connected resources for BUDDY."
(let ((resource-alist (get buddy 'resources))
(count 0))
(cl-count 0))
(dolist (resource resource-alist)
(if (plist-get (cdr resource) 'connected)
(setq count (1+ count))))
Expand Down
40 changes: 20 additions & 20 deletions elisp/jabber-socks5.el
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ proxies have answered."
(setq jabber-socks5-proxies-data
(delq existing-entry jabber-socks5-proxies-data))))

(destructuring-bind (callback successp) closure-data
(cl-destructuring-bind (callback successp) closure-data
(when successp
(setq jabber-socks5-proxies-data
(cons (cons from streamhosts)
Expand Down Expand Up @@ -188,15 +188,15 @@ set; the target waits for one."
(fsm-debug-output "got disco event")
;; Count the response.
(plist-put state-data :remaining-info (1- (plist-get state-data :remaining-info)))
(unless (eq (first (third event)) 'error)
(let ((identities (first (third event))))
(unless (eq (cl-first (cl-third event)) 'error)
(let ((identities (cl-first (cl-third event))))
;; Is it a bytestream proxy?
(when (dolist (identity identities)
(when (cl-dolist (identity identities)
(when (and (string= (aref identity 1) "proxy")
(string= (aref identity 2) "bytestreams"))
(return t)))
(cl-return t)))
;; Yes, it is. Add it to the list.
(push (second event) jabber-socks5-proxies))))
(push (cl-second event) jabber-socks5-proxies))))

;; Wait for more responses, if any are to be expected.
(if (zerop (plist-get state-data :remaining-info))
Expand Down Expand Up @@ -281,10 +281,10 @@ set; the target waits for one."
(id (jabber-xml-get-attribute xml-data 'id))
(query (jabber-iq-query xml-data))
(sid (jabber-xml-get-attribute query 'sid))
(session (dolist (pending-session jabber-socks5-pending-sessions)
(session (cl-dolist (pending-session jabber-socks5-pending-sessions)
(when (and (equal sid (nth 0 pending-session))
(equal jid (nth 1 pending-session)))
(return pending-session)))))
(cl-return pending-session)))))
;; check that we really are expecting this session
(unless session
(jabber-signal-error "auth" 'not-acceptable))
Expand Down Expand Up @@ -332,7 +332,7 @@ set; the target waits for one."

;; Incoming IQ
((eq (car-safe event) :iq)
(let ((xml-data (second event)))
(let ((xml-data (cl-second event)))
;; This is either type "set" (with a list of streamhosts to
;; use), or a "result" (indicating the streamhost finally used
;; by the other party).
Expand Down Expand Up @@ -418,7 +418,7 @@ set; the target waits for one."
(fsm state-data event callback)
(cond
((eq (car-safe event) :sentinel)
(let ((string (third event)))
(let ((string (cl-third event)))
(cond
;; Connection succeeded
((string= (substring string 0 4) "open")
Expand All @@ -440,14 +440,14 @@ set; the target waits for one."
"Receive response to authenticate command."
(cond
((eq (car-safe event) :filter)
(let ((string (third event)))
(let ((string (cl-third event)))
;; should return:
;; version: 5. auth method to use: none
(if (string= string (string 5 0))
;; Authenticated. Send connect command.
(list 'connect state-data nil)
;; Authentication failed...
(delete-process (second event))
(delete-process (cl-second event))
(list 'fail state-data nil))))

((eq (car-safe event) :sentinel)
Expand All @@ -471,7 +471,7 @@ set; the target waits for one."
"Receive response to connect command."
(cond
((eq (car-safe event) :filter)
(let ((string (third event)))
(let ((string (cl-third event)))
(if (string= (substring string 0 2) (string 5 0))
;; connection established
(progn
Expand Down Expand Up @@ -505,7 +505,7 @@ set; the target waits for one."
(fsm state-data event callback)
(cond
((eq (car-safe event) :connected)
(destructuring-bind (ignored connection streamhost-jid) event
(cl-destructuring-bind (ignored connection streamhost-jid) event
(setq state-data (plist-put state-data :connection connection))
;; If we are expected to tell which streamhost we chose, do so.
(let ((iq-id (plist-get state-data :iq-id)))
Expand Down Expand Up @@ -552,7 +552,7 @@ set; the target waits for one."
;; Stray events from earlier state
((eq (car-safe event) :connected)
;; We just close the connection
(delete-process (second event))
(delete-process (cl-second event))
(list 'wait-for-activation state-data :keep))
((eq event :not-connected)
(list 'wait-for-activation state-data :keep))))
Expand Down Expand Up @@ -587,28 +587,28 @@ set; the target waits for one."
(jid (plist-get state-data :jid)))
(cond
((eq (car-safe event) :send)
(process-send-string connection (second event))
(process-send-string connection (cl-second event))
(list 'stream-activated state-data nil))

((eq (car-safe event) :filter)
;; Pass data from connection to profile data function
;; If the data function requests it, tear down the connection.
(unless (funcall profile-data-function jc jid sid (third event))
(fsm-send fsm (list :sentinel (second event) "shutdown")))
(unless (funcall profile-data-function jc jid sid (cl-third event))
(fsm-send fsm (list :sentinel (cl-second event) "shutdown")))

(list 'stream-activated state-data nil))

((eq (car-safe event) :sentinel)
;; Connection terminated. Shuffle together the remaining data,
;; and kill the buffer.
(delete-process (second event))
(delete-process (cl-second event))
(funcall profile-data-function jc jid sid nil)
(list 'closed nil nil))

;; Stray events from earlier state
((eq (car-safe event) :connected)
;; We just close the connection
(delete-process (second event))
(delete-process (cl-second event))
(list 'stream-activated state-data nil))
((eq event :not-connected)
(list 'stream-activated state-data nil)))))
Expand Down
4 changes: 2 additions & 2 deletions elisp/jabber-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ binding."
(defun jabber-find-connection (bare-jid)
"Find the connection to the account named by BARE-JID.
Return nil if none found."
(dolist (jc jabber-connections)
(cl-dolist (jc jabber-connections)
(when (string= bare-jid (jabber-connection-bare-jid jc))
(cl-return jc))))

Expand Down Expand Up @@ -603,7 +603,7 @@ See secton 9.3, Stanza Errors, of XMPP Core, and XEP-0086, Legacy Errors."
"Return the condition of a <stream:error/> tag."
;; as we don't know the node name of the condition, we have to
;; search for it.
(dolist (node (jabber-xml-node-children error-xml))
(cl-dolist (node (jabber-xml-node-children error-xml))
(when (and (string= (jabber-xml-get-attribute node 'xmlns)
"urn:ietf:params:xml:ns:xmpp-streams")
(assq (jabber-xml-node-name node)
Expand Down
9 changes: 4 additions & 5 deletions elisp/jabber-xml.el
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,10 @@ Return nil if the attribute was not found."
;; of xml.el. It will also be more correct.
;; Now, it only matches explicit namespace declarations.
(setq node
(cl-block dolist-loop
(dolist (x (jabber-xml-get-children node (intern (cdr step))))
(when (string= (jabber-xml-get-attribute x 'xmlns)
(car step))
(cl-return-from dolist-loop x))))))
(cl-dolist (x (jabber-xml-get-children node (intern (cdr step))))
(when (string= (jabber-xml-get-attribute x 'xmlns)
(car step))
(cl-return x)))))
((stringp step)
(setq node (car (jabber-xml-node-children node)))
(unless (stringp node)
Expand Down
2 changes: 1 addition & 1 deletion elisp/jabber.org
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,7 @@ what kind of chat buffer is being created.")
:END:
#+BEGIN_SRC emacs-lisp
(defun jabber-mode-line-count-contacts (&rest _ignore)
(let ((count (list (cons "chat" 0)
(let ((cl-count (list (cons "chat" 0)
(cons "" 0)
(cons "away" 0)
(cons "xa" 0)
Expand Down

0 comments on commit d50dd76

Please sign in to comment.