X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/e8faa44b9a8771490b14044bbb99fa2538d0f42e..84e1850a7cb61f9afa61eda5fa75ca14f672eadf:/contrib/stgit.el diff --git a/contrib/stgit.el b/contrib/stgit.el index 6248cd9..d3d518d 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -14,6 +14,7 @@ (require 'git nil t) (require 'cl) +(require 'comint) (require 'ewoc) (require 'easymenu) (require 'format-spec) @@ -943,7 +944,6 @@ file for (applied) copies and renames." (unless stgit-mode-map (let ((diff-map (make-sparse-keymap)) (toggle-map (make-sparse-keymap))) - (suppress-keymap diff-map) (mapc (lambda (arg) (define-key diff-map (car arg) (cdr arg))) '(("b" . stgit-diff-base) ("c" . stgit-diff-combined) @@ -951,7 +951,6 @@ file for (applied) copies and renames." ("o" . stgit-diff-ours) ("r" . stgit-diff-range) ("t" . stgit-diff-theirs))) - (suppress-keymap toggle-map) (mapc (lambda (arg) (define-key toggle-map (car arg) (cdr arg))) '(("n" . stgit-toggle-patch-names) ("t" . stgit-toggle-worktree) @@ -1495,9 +1494,16 @@ If ALL is not nil, also return non-stgit branches." ((not (string-match stgit-allowed-branch-name-re branch)) (error "Invalid branch name")) ((yes-or-no-p (format "Create branch \"%s\"? " branch)) - (stgit-capture-output nil (stgit-run "branch" "--create" "--" - branch)) - t)) + (let ((branch-point (completing-read + "Branch from (default current branch): " + (stgit-available-branches)))) + (stgit-capture-output nil + (apply 'stgit-run + `("branch" "--create" "--" + ,branch + ,@(unless (zerop (length branch-point)) + (list branch-point))))) + t))) (stgit-reload))) (defun stgit-available-refs (&optional omit-stgit) @@ -2225,6 +2231,19 @@ deepest patch had before the squash." (stgit-reload))) (funcall old-sentinel process sentinel))) +(defun stgit-execute-process-filter (process output) + (with-current-buffer (process-buffer process) + (let* ((old-point (point)) + (pmark (process-mark process)) + (insert-at (marker-position pmark)) + (at-pmark (= insert-at old-point))) + (goto-char insert-at) + (insert-before-markers output) + (comint-carriage-motion insert-at (point)) + (set-marker pmark (point)) + (unless at-pmark + (goto-char old-point))))) + (defun stgit-execute () "Prompt for an stg command to execute in a shell. @@ -2263,7 +2282,10 @@ When the command has finished, reload the stgit buffer." (process-sentinel process)) (set (make-local-variable 'stgit-buffer) old-buffer) + (set-process-filter process 'stgit-execute-process-filter) (set-process-sentinel process 'stgit-execute-process-sentinel)))) + (with-current-buffer buffer + (comint-carriage-motion (point-min) (point-max))) (shrink-window-if-larger-than-buffer (get-buffer-window buffer)) (stgit-reload))))