2012-10-16 22:47:48 +02:00
|
|
|
;;; gitto.el --- Gitto in emacs
|
|
|
|
|
2013-05-20 23:42:31 +02:00
|
|
|
;; Copyright (C) 2012 Tom Willemse
|
2012-10-16 22:47:48 +02:00
|
|
|
|
2013-05-20 23:42:31 +02:00
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
2012-10-16 22:47:48 +02:00
|
|
|
;; Keywords: convenience
|
2013-10-13 00:42:54 +02:00
|
|
|
;; Package-Version: 0.2.1
|
2012-10-16 22:47:48 +02:00
|
|
|
|
|
|
|
;; 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:
|
|
|
|
|
2012-10-17 23:48:13 +02:00
|
|
|
;; Small interface between gitto and Emacs.
|
2012-10-16 22:47:48 +02:00
|
|
|
|
2012-10-17 01:45:16 +02:00
|
|
|
;; Right now it only offers the `gitto-register' command which lets
|
2012-10-17 23:48:13 +02:00
|
|
|
;; you register repositories from within Emacs. When called
|
2012-10-17 01:45:16 +02:00
|
|
|
;; interactively this command will try to register the git directory
|
|
|
|
;; of the file of the current buffer.
|
|
|
|
|
2012-10-16 22:47:48 +02:00
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(defgroup gitto nil
|
|
|
|
"Gitto settings."
|
|
|
|
:group 'applications)
|
|
|
|
|
|
|
|
(defcustom gitto-program "gitto"
|
|
|
|
"The gitto executable."
|
|
|
|
:group 'gitto
|
|
|
|
:type 'string)
|
|
|
|
|
2012-10-17 23:46:31 +02:00
|
|
|
;;;###autoload
|
|
|
|
(defun gitto-registered-p (dir)
|
|
|
|
"Check if DIR is a registered repository."
|
|
|
|
(not (string-match-p "not registered"
|
|
|
|
(shell-command-to-string
|
2013-10-13 00:42:54 +02:00
|
|
|
(concat gitto-program " check " dir)))))
|
2012-10-17 23:46:31 +02:00
|
|
|
|
2012-10-16 22:47:48 +02:00
|
|
|
;;;###autoload
|
|
|
|
(defun gitto-register (dir)
|
2012-10-17 23:46:31 +02:00
|
|
|
"Register DIR with gitto."
|
2012-10-16 22:47:48 +02:00
|
|
|
(interactive (list (locate-dominating-file (buffer-file-name) ".git")))
|
|
|
|
(unless dir
|
2012-10-17 23:48:13 +02:00
|
|
|
(error "Not a git repository"))
|
2012-10-16 22:47:48 +02:00
|
|
|
|
2013-10-13 00:42:54 +02:00
|
|
|
(shell-command (concat gitto-program " add " dir)))
|
2012-10-16 22:47:48 +02:00
|
|
|
|
2012-10-17 23:46:31 +02:00
|
|
|
;;;###autoload
|
|
|
|
(defun gitto-unregister (dir)
|
|
|
|
"Unregister DIR with gitto."
|
|
|
|
(interactive (list (locate-dominating-file (buffer-file-name) ".git")))
|
|
|
|
(unless (and dir (gitto-registered-p dir))
|
2012-10-17 23:48:13 +02:00
|
|
|
(error "Not a registered git repository"))
|
2012-10-17 23:46:31 +02:00
|
|
|
|
2013-10-13 00:42:54 +02:00
|
|
|
(shell-command (concat gitto-program " remove " dir)))
|
2012-10-17 23:46:31 +02:00
|
|
|
|
2012-10-16 22:47:48 +02:00
|
|
|
(provide 'gitto)
|
|
|
|
;;; gitto.el ends here
|