(require 'git nil t)
(require 'cl)
+(require 'comint)
(require 'ewoc)
(require 'easymenu)
(require 'format-spec)
(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)
("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)
((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)
(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.
(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))))