gitto/emacs/gitto.el

69 lines
2.1 KiB
EmacsLisp
Raw Normal View History

;;; gitto.el --- Gitto in emacs
2013-05-20 23:42:31 +02:00
;; Copyright (C) 2012 Tom Willemse
2013-05-20 23:42:31 +02:00
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: convenience
;; Package-Version: 0.2.1
;; 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-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.
;;; Code:
(defgroup gitto nil
"Gitto settings."
:group 'applications)
(defcustom gitto-program "gitto"
"The gitto executable."
:group 'gitto
:type 'string)
;;;###autoload
(defun gitto-registered-p (dir)
"Check if DIR is a registered repository."
(not (string-match-p "not registered"
(shell-command-to-string
(concat gitto-program " check " dir)))))
;;;###autoload
(defun gitto-register (dir)
"Register DIR with gitto."
(interactive (list (locate-dominating-file (buffer-file-name) ".git")))
(unless dir
2012-10-17 23:48:13 +02:00
(error "Not a git repository"))
(shell-command (concat gitto-program " add " dir)))
;;;###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"))
(shell-command (concat gitto-program " remove " dir)))
(provide 'gitto)
;;; gitto.el ends here