From a897cd4e8b7d5de4b1b4bc0ab6eb721b78131010 Mon Sep 17 00:00:00 2001 From: defanor Date: Sat, 23 Oct 2021 16:23:23 +0300 Subject: Add xmpp-restart into xmpp.el For restarting the rexmpp_xml_interface process (e.g., switching to a newer version) without killing corresponding buffers. --- emacs/xmpp.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 -- cgit v1.2.3