Signed-off-by: Gustav Hållberg <gustav@virtutech.com>
Signed-off-by: Karl Hasselström <kha@treskal.com>
(require 'git nil t)
(defun stgit (dir)
(require 'git nil t)
(defun stgit (dir)
+ "Manage StGit patches for the tree in DIR."
(interactive "DDirectory: \n")
(switch-to-stgit-buffer (git-get-top-dir dir))
(stgit-reload))
(interactive "DDirectory: \n")
(switch-to-stgit-buffer (git-get-top-dir dir))
(stgit-reload))
(car (split-string cdup "\n"))))))
(defun switch-to-stgit-buffer (dir)
(car (split-string cdup "\n"))))))
(defun switch-to-stgit-buffer (dir)
- "Switch to a (possibly new) buffer displaying StGit patches for DIR"
+ "Switch to a (possibly new) buffer displaying StGit patches for DIR."
(setq dir (file-name-as-directory dir))
(let ((buffers (buffer-list)))
(while (and buffers
(setq dir (file-name-as-directory dir))
(let ((buffers (buffer-list)))
(while (and buffers
buf))
(defmacro stgit-capture-output (name &rest body)
buf))
(defmacro stgit-capture-output (name &rest body)
- "Capture StGit output and show it in a window at the end"
+ "Capture StGit output and show it in a window at the end."
`(let ((output-buf (get-buffer-create ,(or name "*StGit output*")))
(stgit-dir default-directory)
(inhibit-read-only t))
`(let ((output-buf (get-buffer-create ,(or name "*StGit output*")))
(stgit-dir default-directory)
(inhibit-read-only t))
(message "Running stg %s...done" msgcmd)))
(defun stgit-reload ()
(message "Running stg %s...done" msgcmd)))
(defun stgit-reload ()
- "Update the contents of the stgit buffer"
+ "Update the contents of the StGit buffer."
(interactive)
(let ((inhibit-read-only t)
(curline (line-number-at-pos))
(interactive)
(let ((inhibit-read-only t)
(curline (line-number-at-pos))
(setq stgit-marked-patches (nreverse marked)))))
(defun stgit-quit ()
(setq stgit-marked-patches (nreverse marked)))))
(defun stgit-quit ()
- "Hide the stgit buffer"
+ "Hide the stgit buffer."
(interactive)
(bury-buffer))
(defun stgit-git-status ()
(interactive)
(bury-buffer))
(defun stgit-git-status ()
- "Show status using `git-status'"
+ "Show status using `git-status'."
(interactive)
(unless (fboundp 'git-status)
(error "stgit-git-status requires git-status"))
(interactive)
(unless (fboundp 'git-status)
(error "stgit-git-status requires git-status"))
(mapcar 'symbol-name stgit-marked-patches))
(defun stgit-patch-at-point ()
(mapcar 'symbol-name stgit-marked-patches))
(defun stgit-patch-at-point ()
- "Return the patch name on the current line"
+ "Return the patch name on the current line."
(save-excursion
(beginning-of-line)
(if (looking-at "[>+-][ *]\\([^ ]*\\)")
(save-excursion
(beginning-of-line)
(if (looking-at "[>+-][ *]\\([^ ]*\\)")
'()))))
(defun stgit-goto-patch (patch)
'()))))
(defun stgit-goto-patch (patch)
- "Move point to the line containing PATCH"
+ "Move point to the line containing PATCH."
(let ((p (point)))
(goto-char (point-min))
(if (re-search-forward (concat "^[>+-][ *]" (regexp-quote patch) " ") nil t)
(let ((p (point)))
(goto-char (point-min))
(if (re-search-forward (concat "^[>+-][ *]" (regexp-quote patch) " ") nil t)
nil)))
(defun stgit-init ()
nil)))
(defun stgit-init ()
(interactive)
(stgit-capture-output nil
(stgit-run "init"))
(stgit-reload))
(defun stgit-mark ()
(interactive)
(stgit-capture-output nil
(stgit-run "init"))
(stgit-reload))
(defun stgit-mark ()
- "Mark the patch under point"
+ "Mark the patch under point."
(interactive)
(let ((patch (stgit-patch-at-point)))
(stgit-add-mark patch)
(interactive)
(let ((patch (stgit-patch-at-point)))
(stgit-add-mark patch)
(next-line))
(defun stgit-unmark-up ()
(next-line))
(defun stgit-unmark-up ()
- "Remove mark from the patch on the previous line"
+ "Remove mark from the patch on the previous line."
(interactive)
(forward-line -1)
(stgit-remove-mark (stgit-patch-at-point))
(stgit-reload))
(defun stgit-unmark-down ()
(interactive)
(forward-line -1)
(stgit-remove-mark (stgit-patch-at-point))
(stgit-reload))
(defun stgit-unmark-down ()
- "Remove mark from the patch on the current line"
+ "Remove mark from the patch on the current line."
(interactive)
(stgit-remove-mark (stgit-patch-at-point))
(forward-line)
(stgit-reload))
(defun stgit-rename (name)
(interactive)
(stgit-remove-mark (stgit-patch-at-point))
(forward-line)
(stgit-reload))
(defun stgit-rename (name)
- "Rename the patch under point"
+ "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
(interactive (list (read-string "Patch name: " (stgit-patch-at-point))))
(let ((old-name (stgit-patch-at-point)))
(unless old-name
(stgit-goto-patch name)))
(defun stgit-repair ()
(stgit-goto-patch name)))
(defun stgit-repair ()
(interactive)
(stgit-capture-output nil
(stgit-run "repair"))
(interactive)
(stgit-capture-output nil
(stgit-run "repair"))
(looking-at "[>+]")))
(defun stgit-push-or-pop ()
(looking-at "[>+]")))
(defun stgit-push-or-pop ()
- "Push or pop the patch on the current line"
+ "Push or pop the patch on the current line."
(interactive)
(let ((patch (stgit-patch-at-point))
(applied (stgit-applied-at-point)))
(interactive)
(let ((patch (stgit-patch-at-point))
(applied (stgit-applied-at-point)))
(stgit-reload)))
(defun stgit-goto ()
(stgit-reload)))
(defun stgit-goto ()
- "Go to the patch on the current line"
+ "Go to the patch on the current line."
(interactive)
(let ((patch (stgit-patch-at-point)))
(stgit-capture-output nil
(interactive)
(let ((patch (stgit-patch-at-point)))
(stgit-capture-output nil
(stgit-reload)))
(defun stgit-show ()
(stgit-reload)))
(defun stgit-show ()
- "Show the patch on the current line"
+ "Show the patch on the current line."
(interactive)
(stgit-capture-output "*StGit patch*"
(stgit-run "show" (stgit-patch-at-point))
(interactive)
(stgit-capture-output "*StGit patch*"
(stgit-run "show" (stgit-patch-at-point))
(diff-mode))))
(defun stgit-edit ()
(diff-mode))))
(defun stgit-edit ()
- "Edit the patch on the current line"
+ "Edit the patch on the current line."
(interactive)
(let ((patch (stgit-patch-at-point))
(edit-buf (get-buffer-create "*StGit edit*"))
(interactive)
(let ((patch (stgit-patch-at-point))
(edit-buf (get-buffer-create "*StGit edit*"))
(stgit-reload))))
(defun stgit-new ()
(stgit-reload))))
(defun stgit-new ()
(interactive)
(let ((edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(interactive)
(let ((edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(t patch))))
(defun stgit-delete (patch-names)
(t patch))))
(defun stgit-delete (patch-names)
- "Delete the named patches"
+ "Delete the named patches."
(interactive (list (stgit-patches-marked-or-at-point)))
(if (zerop (length patch-names))
(error "No patches to delete")
(interactive (list (stgit-patches-marked-or-at-point)))
(if (zerop (length patch-names))
(error "No patches to delete")
(stgit-reload))))
(defun stgit-coalesce (patch-names)
(stgit-reload))))
(defun stgit-coalesce (patch-names)
- "Run stg coalesce on the named patches"
+ "Run stg coalesce on the named patches."
(interactive (list (stgit-marked-patches)))
(let ((edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(interactive (list (stgit-marked-patches)))
(let ((edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(defun stgit-refresh (&optional arg)
"Run stg refresh.
(defun stgit-refresh (&optional arg)
"Run stg refresh.
-With prefix argument, refresh the patch under point."
+With prefix argument, refresh the marked patch or the patch under point."
(interactive "P")
(let ((patchargs (if arg
(let ((patches (stgit-patches-marked-or-at-point)))
(interactive "P")
(let ((patchargs (if arg
(let ((patches (stgit-patches-marked-or-at-point)))