diff options
author | Kyle Meyer <kyle@kyleam.com> | 2020-06-05 20:27:59 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2020-06-06 11:20:49 -0400 |
commit | d557be18da6cd61dd2830677bbc08b06d39f0eac (patch) | |
tree | b196a0e888739e5dbc08574a8da496e9decfdf1a | |
parent | 5631f6d6371c243b85c54c20f3baa5a44b40c5c3 (diff) | |
download | piem-d557be18da6cd61dd2830677bbc08b06d39f0eac.tar.gz |
b4: Drop custom process buffer
Directing all piem-related output to one buffer should be sufficient,
for now at least.
-rw-r--r-- | piem-b4.el | 18 | ||||
-rw-r--r-- | piem.el | 44 |
2 files changed, 29 insertions, 33 deletions
@@ -66,8 +66,6 @@ the following information about the patch series: ;;;; Internals -(defconst piem-b4-output-buffer "*piem-b4-output*") - (defun piem-b4--series-info (cover patches) "Collect information for a patch series. COVER is an mbox with the cover letter, and PATCHES is an @@ -167,8 +165,7 @@ in `piem-b4-default-branch-function'." (setq custom-p t)))) ;; Move to the coderepo so that we pick up any b4 configuration ;; from there. - (apply #'piem-process-call piem-b4-output-buffer coderepo - piem-b4-b4-executable "am" + (apply #'piem-process-call coderepo piem-b4-b4-executable "am" (and custom-p (concat "--use-local-mbox=" mbox-thread)) (concat "--outdir=" outdir) @@ -189,16 +186,15 @@ in `piem-b4-default-branch-function'." (defun piem-b4-am-ready-from-mbox (mbox &optional args) (interactive (list (read-file-name "mbox: ") (transient-args 'piem-b4-am))) - (apply #'piem-process-start piem-b4-output-buffer nil - piem-b4-b4-executable "am" + (apply #'piem-process-start nil piem-b4-b4-executable "am" (cons (concat "--use-local-mbox=" mbox) args))) ;;;###autoload (defun piem-b4-am-ready-from-mid (mid &optional args) (interactive (list (read-string "Message ID: " nil nil (piem-mid)) (transient-args 'piem-b4-am))) - (apply #'piem-process-start piem-b4-output-buffer nil - piem-b4-b4-executable "am" (append args (list mid)))) + (apply #'piem-process-start nil piem-b4-b4-executable "am" + (append args (list mid)))) ;;;###autoload (defun piem-b4-am-from-mid (mid &optional args) @@ -238,14 +234,12 @@ in `piem-b4-default-branch-function'." (magit-list-local-branch-names))) (base (plist-get info :base-commit))) (if base (cons base cands) cands))))) - (apply #'piem-process-call piem-b4-output-buffer nil - piem-git-executable "checkout" + (apply #'piem-process-call nil piem-git-executable "checkout" (append (if (string-empty-p new-branch) (list "--detach") (list "-b" new-branch)) (list base)))) - (piem-process-call piem-b4-output-buffer nil - piem-git-executable "am" "--scissors" + (piem-process-call nil piem-git-executable "am" "--scissors" mbox-file) (if (and piem-use-magit (fboundp 'magit-status-setup-buffer)) @@ -152,6 +152,8 @@ intended to be used by libraries implementing a function for line-end) (0 font-lock-comment-face)))) +(defconst piem-process-output-buffer "*piem-process-output*") + (define-derived-mode piem-process-mode nil "piem-process" "Major mode for displaying processes created by piem." :group 'piem @@ -164,33 +166,33 @@ intended to be used by libraries implementing a function for (defvar-local piem--buffer-process nil) -(defun piem--process-go (buffer dir program program-args fn) +(defun piem--process-go (dir program program-args fn) (setq dir (or dir default-directory)) - (setq buffer (get-buffer-create buffer)) - (with-current-buffer buffer - (when (and piem--buffer-process - (process-live-p piem--buffer-process)) - (user-error "Buffer %s already has an active process: %s" - (current-buffer) piem--buffer-process)) - (unless (derived-mode-p 'piem-process-mode) - (piem-process-mode)) - (setq default-directory (file-name-as-directory dir)) - (display-buffer buffer) - (let ((inhibit-read-only t)) - (insert (format " + (let ((buffer (get-buffer-create piem-process-output-buffer))) + (with-current-buffer buffer + (when (and piem--buffer-process + (process-live-p piem--buffer-process)) + (user-error "Buffer %s already has an active process: %s" + (current-buffer) piem--buffer-process)) + (unless (derived-mode-p 'piem-process-mode) + (piem-process-mode)) + (setq default-directory (file-name-as-directory dir)) + (display-buffer buffer) + (let ((inhibit-read-only t)) + (insert (format " %s ;;; process: %S ;;; directory: %s " - (char-to-string 12) ; form feed - (cons program program-args) - default-directory)) - (funcall fn)))) + (char-to-string 12) ; form feed + (cons program program-args) + default-directory)) + (funcall fn))))) -(defun piem-process-start (buffer dir program &rest program-args) +(defun piem-process-start (dir program &rest program-args) (setq program-args (remq nil program-args)) (piem--process-go - buffer dir program program-args + dir program program-args (lambda () (setq piem--buffer-process (apply #'start-process @@ -198,10 +200,10 @@ intended to be used by libraries implementing a function for (current-buffer) program program-args))))) -(defun piem-process-call (buffer dir program &rest program-args) +(defun piem-process-call (dir program &rest program-args) (setq program-args (remq nil program-args)) (piem--process-go - buffer dir program program-args + dir program program-args (lambda () (unless (= 0 (apply #'call-process program nil t nil program-args)) (signal 'piem-error |