branch: externals/mpdired
commit d7c42d2e6d64eab4feedc8ef2826506057788c44
Author: Manuel Giraud <[email protected]>
Commit: Manuel Giraud <[email protected]>
kill the global process
Now everything is done through the process of the communication
buffer.
---
mpdired.el | 55 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 25 deletions(-)
diff --git a/mpdired.el b/mpdired.el
index 76ebd3e37e..0ef1de167d 100644
--- a/mpdired.el
+++ b/mpdired.el
@@ -101,38 +101,43 @@
(unless (string-search "connection broken" event)
(message "Process: %s had the event '%s'" process event)))
-(defvar mpdired-process nil)
-
-(defun mpdired-local-p (host)
+(defun mpdired--local-p (host)
;; Hack: if the `expand-file-name' of host leads to an existing
;; file, that should be our Unix socket.
(file-exists-p (expand-file-name host)))
-(defun mpdired--maybe-init ()
- ;; Always reparse host should the user have changed it.
- (let* ((localp (mpdired-local-p mpdired-host))
- (host (if localp (expand-file-name mpdired-host) mpdired-host))
- (service (if localp host mpdired-port)))
- (with-current-buffer (get-buffer-create "*mpdired-work*")
- (setq-local buffer-read-only nil)
- (erase-buffer)
+(defun mpdired--comm-name (host service localp)
+ (if localp
+ (format "*mpdired-%s" host)
+ (format "*mpdired-%s:%s" host service)))
+
+(defun mpdired--maybe-init (host service localp)
+ (with-current-buffer (get-buffer-create (mpdired--comm-name host service
localp))
+ (setq-local buffer-read-only nil)
+ (erase-buffer)
+ (let ((process (get-buffer-process (current-buffer))))
;; Create a new connection if needed
- (unless (and mpdired-process
- (eq (process-status mpdired-process) 'open))
- (setq mpdired-process (make-network-process :name "mpdired"
- :buffer (current-buffer)
- :host host
- :service service
- :family (if localp 'local)
- :coding 'utf-8
- :filter 'my-filter
- :sentinel 'msg-me))))))
+ (unless (and process
+ (eq (process-status process) 'open))
+ (set-process-buffer (make-network-process :name "mpdired"
+ :buffer (current-buffer)
+ :host host
+ :service service
+ :family (if localp 'local)
+ :coding 'utf-8
+ :filter 'my-filter
+ :sentinel 'msg-me)
+ (current-buffer))))))
(defun mpdired-listall (path)
- (mpdired--maybe-init)
- (with-current-buffer "*mpdired-work*"
- (setq-local mpdired--last-command 'listall)
- (process-send-string mpdired-process (format "listall \"%s\"\n" path))))
+ ;; Always reparse host should the user have changed it.
+ (let* ((localp (mpdired--local-p mpdired-host))
+ (host (if localp (expand-file-name mpdired-host) mpdired-host))
+ (service (if localp host mpdired-port)))
+ (mpdired--maybe-init host service localp)
+ (with-current-buffer (mpdired--comm-name host service localp)
+ (setq-local mpdired--last-command 'listall)
+ (process-send-string (get-buffer-process (current-buffer)) (format
"listall \"%s\"\n" path)))))
(defun mpdired-test-me ()
(interactive)