summaryrefslogtreecommitdiffstats
path: root/emacs
diff options
context:
space:
mode:
authorGravatar Tom Willemse2015-12-18 01:38:31 +0100
committerGravatar Tom Willemse2015-12-18 01:38:31 +0100
commit1b942fbcf187f033a79e0dfa5eab36707fd5929a (patch)
treea0d793804ba7a74eba5b496ccccedd35ef8f5d79 /emacs
parent636c985bdd9268052d30393211de85656b49f927 (diff)
downloaddotfiles-1b942fbcf187f033a79e0dfa5eab36707fd5929a.tar.gz
dotfiles-1b942fbcf187f033a79e0dfa5eab36707fd5929a.zip
Move request pull to git library
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init.el29
-rw-r--r--emacs/.emacs.d/site-lisp/oni-git.el60
2 files changed, 60 insertions, 29 deletions
diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el
index 0336fc8..c7f21bc 100644
--- a/emacs/.emacs.d/init.el
+++ b/emacs/.emacs.d/init.el
@@ -141,35 +141,6 @@ MODE1 is enabled and vice-versa."
"Set the `disabled' property for each item in FUNCTIONS to nil."
(mapc #'(lambda (f) (put f 'disabled nil)) functions))
-(defun oni:request-pull ()
- "Start a mail to request pulling from a git repository."
- (interactive)
- (let* ((default-directory
- (expand-file-name
- (or (locate-dominating-file default-directory ".git")
- (magit-read-top-dir nil))))
- (refs (magit-list-interesting-refs magit-uninteresting-refs))
- (from (cdr (assoc (completing-read "From: " refs) refs)))
- (url (read-from-minibuffer "Pull URL: "))
- (to (symbol-name (read-from-minibuffer "Up to (HEAD): "
- nil nil t nil "HEAD")))
- (patchp (and current-prefix-arg (listp current-prefix-arg))))
- (message "Requesting pull for %s from %s to %s at %s with%s patch"
- default-directory from to url (if patchp "" "out"))
-
- (compose-mail
- nil (concat
- "Requesting pull for "
- (file-name-base (directory-file-name default-directory))))
-
- (save-excursion
- (goto-char (point-max))
- (insert
- (shell-command-to-string
- (concat "git --git-dir='" default-directory ".git' --work-tree='"
- default-directory "' request-pull " (when patchp "-p ")
- from " " url " " to))))))
-
(defun oni:reset-default-directory ()
"Reset `default-directory' to HOME."
(setq default-directory (getenv "HOME")))
diff --git a/emacs/.emacs.d/site-lisp/oni-git.el b/emacs/.emacs.d/site-lisp/oni-git.el
new file mode 100644
index 0000000..6435faa
--- /dev/null
+++ b/emacs/.emacs.d/site-lisp/oni-git.el
@@ -0,0 +1,60 @@
+;;; oni-git.el --- Extra git functions and commands -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015 Tom Willemse
+
+;; Author: Tom Willemse <tom@ryuslash.org>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Here are some extra commands and functions for git.
+
+;;; Code:
+
+(require 'magit)
+
+;;;###autoload
+(defun oni:request-pull ()
+ "Start a mail to request pulling from a git repository."
+ (interactive)
+ (let* ((default-directory
+ (expand-file-name
+ (or (locate-dominating-file default-directory ".git")
+ (magit-read-repository))))
+ (refs (magit-list-refs))
+ (from (cdr (assoc (completing-read "From: " refs) refs)))
+ (url (read-from-minibuffer "Pull URL: "))
+ (to (symbol-name (read-from-minibuffer "Up to (HEAD): "
+ nil nil t nil "HEAD")))
+ (patchp (and current-prefix-arg (listp current-prefix-arg))))
+ (message "Requesting pull for %s from %s to %s at %s with%s patch"
+ default-directory from to url (if patchp "" "out"))
+
+ (compose-mail
+ nil (concat
+ "Requesting pull for "
+ (file-name-base (directory-file-name default-directory))))
+
+ (save-excursion
+ (goto-char (point-max))
+ (insert
+ (shell-command-to-string
+ (concat "git --git-dir='" default-directory ".git' --work-tree='"
+ default-directory "' request-pull " (when patchp "-p ")
+ from " " url " " to))))))
+
+(provide 'oni-git)
+;;; oni-git.el ends here