Signed-off-by: Gustav Hållberg <gustav@virtutech.com>
Signed-off-by: Karl Hasselström <kha@treskal.com>
"Return the names of the marked patches."
(mapcar 'symbol-name stgit-marked-patches))
"Return the names of the marked patches."
(mapcar 'symbol-name stgit-marked-patches))
-(defun stgit-patch-at-point ()
- "Return the patch name on the current line."
+(defun stgit-patch-at-point (&optional cause-error)
+ "Return the patch name on the current line. If CAUSE-ERROR is
+not nil, signal an error if none found."
(save-excursion
(beginning-of-line)
(save-excursion
(beginning-of-line)
- (if (looking-at "[>+-][ *]\\([^ ]*\\)")
- (match-string-no-properties 1)
- nil)))
+ (cond ((looking-at "[>+-][ *]\\([^ ]*\\)")
+ (match-string-no-properties 1))
+ (cause-error
+ (error "No patch on this line")))))
(defun stgit-patches-marked-or-at-point ()
"Return the names of the marked patches, or the patch on the current line."
(defun stgit-patches-marked-or-at-point ()
"Return the names of the marked patches, or the patch on the current line."
(defun stgit-mark ()
"Mark the patch under point."
(interactive)
(defun stgit-mark ()
"Mark the patch under point."
(interactive)
- (let ((patch (stgit-patch-at-point)))
+ (let ((patch (stgit-patch-at-point t)))
(stgit-add-mark patch)
(stgit-reload))
(next-line))
(stgit-add-mark patch)
(stgit-reload))
(next-line))
"Remove mark from the patch on the previous line."
(interactive)
(forward-line -1)
"Remove mark from the patch on the previous line."
(interactive)
(forward-line -1)
- (stgit-remove-mark (stgit-patch-at-point))
+ (stgit-remove-mark (stgit-patch-at-point t))
(stgit-reload))
(defun stgit-unmark-down ()
"Remove mark from the patch on the current line."
(interactive)
(stgit-reload))
(defun stgit-unmark-down ()
"Remove mark from the patch on the current line."
(interactive)
- (stgit-remove-mark (stgit-patch-at-point))
+ (stgit-remove-mark (stgit-patch-at-point t))
(forward-line)
(stgit-reload))
(defun stgit-rename (name)
(forward-line)
(stgit-reload))
(defun stgit-rename (name)
- "Rename the patch under point."
- (interactive (list (read-string "Patch name: " (stgit-patch-at-point))))
- (let ((old-name (stgit-patch-at-point)))
- (unless old-name
- (error "No patch on this line"))
+ "Rename the patch under point to NAME."
+ (interactive (list (read-string "Patch name: " (stgit-patch-at-point t))))
+ (let ((old-name (stgit-patch-at-point t)))
(stgit-capture-output nil
(stgit-run "rename" old-name name))
(stgit-reload)
(stgit-capture-output nil
(stgit-run "rename" old-name name))
(stgit-reload)
(defun stgit-push-or-pop ()
"Push or pop the patch on the current line."
(interactive)
(defun stgit-push-or-pop ()
"Push or pop the patch on the current line."
(interactive)
- (let ((patch (stgit-patch-at-point))
+ (let ((patch (stgit-patch-at-point t))
(applied (stgit-applied-at-point)))
(stgit-capture-output nil
(stgit-run (if applied "pop" "push") patch))
(applied (stgit-applied-at-point)))
(stgit-capture-output nil
(stgit-run (if applied "pop" "push") patch))
(defun stgit-goto ()
"Go to the patch on the current line."
(interactive)
(defun stgit-goto ()
"Go to the patch on the current line."
(interactive)
- (let ((patch (stgit-patch-at-point)))
+ (let ((patch (stgit-patch-at-point t)))
(stgit-capture-output nil
(stgit-run "goto" patch))
(stgit-reload)))
(stgit-capture-output nil
(stgit-run "goto" patch))
(stgit-reload)))
"Show the patch on the current line."
(interactive)
(stgit-capture-output "*StGit patch*"
"Show the patch on the current line."
(interactive)
(stgit-capture-output "*StGit patch*"
- (stgit-run "show" (stgit-patch-at-point))
+ (stgit-run "show" (stgit-patch-at-point t))
(with-current-buffer standard-output
(goto-char (point-min))
(diff-mode))))
(with-current-buffer standard-output
(goto-char (point-min))
(diff-mode))))
(defun stgit-edit ()
"Edit the patch on the current line."
(interactive)
(defun stgit-edit ()
"Edit the patch on the current line."
(interactive)
- (let ((patch (stgit-patch-at-point))
+ (let ((patch (stgit-patch-at-point t))
(edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(log-edit 'stgit-confirm-edit t nil edit-buf)
(edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(log-edit 'stgit-confirm-edit t nil edit-buf)