summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2021-10-23 16:23:23 +0300
committerdefanor <defanor@uberspace.net>2021-10-23 16:23:23 +0300
commita897cd4e8b7d5de4b1b4bc0ab6eb721b78131010 (patch)
treef94370c4a7ccf1454016752a77fe61ce5ae8e749
parent2e667698024e85fe1a9ae44181af9e38141176eb (diff)
Add xmpp-restart into xmpp.el
For restarting the rexmpp_xml_interface process (e.g., switching to a newer version) without killing corresponding buffers.
-rw-r--r--emacs/xmpp.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/emacs/xmpp.el b/emacs/xmpp.el
index 9700546..3f53104 100644
--- a/emacs/xmpp.el
+++ b/emacs/xmpp.el
@@ -494,6 +494,27 @@ its printing--which doesn't handle namespaces--can be used too."
(with-current-buffer xmpp-log-buffer
(setq-local xmpp-proc new-proc))))))
+(defun xmpp-restart (&optional proc)
+ "Restarts an XMPP process."
+ (interactive)
+ (let* ((cur-proc (or proc xmpp-proc))
+ (proc-buf (process-buffer cur-proc)))
+ (when (and cur-proc (process-live-p cur-proc))
+ (xmpp-stop cur-proc))
+ (with-current-buffer proc-buf
+ (setq-local xmpp-active-requests nil)
+ (setq-local xmpp-proc
+ (make-process :name "xmpp"
+ :command (list xmpp-command xmpp-jid)
+ :buffer proc-buf
+ :filter 'xmpp-filter))
+ (let ((new-proc xmpp-proc))
+ (mapcar (lambda (b)
+ (with-current-buffer b (setq-local xmpp-proc new-proc)))
+ (append (list xmpp-console-buffer xmpp-xml-buffer xmpp-log-buffer)
+ (mapcar 'cdr xmpp-query-buffers)
+ (mapcar 'cdr xmpp-muc-buffers)))))))
+
(defun xmpp-insert (args)
(save-excursion
(when (and xmpp-truncate-buffer-at