contrib/vim: Add vim syntax highlighting for StGit commit messages
[stgit] / contrib / stgit.el
index 286d7c3..c71df4b 100644 (file)
@@ -34,13 +34,6 @@ reload all StGit buffers."
   :link '(function-link stgit)
   :link '(url-link "http://www.procode.org/stgit/"))
 
-(defcustom stgit-abbreviate-copies-and-renames t
-  "If non-nil, abbreviate copies and renames as \"dir/{old -> new}/file\"
-instead of \"dir/old/file -> dir/new/file\"."
-  :type 'boolean
-  :group 'stgit
-  :set 'stgit-set-default)
-
 (defcustom stgit-default-show-worktree t
   "Set to non-nil to by default show the working tree in a new stgit buffer.
 
@@ -68,6 +61,34 @@ setting in an already-started StGit buffer."
   :group 'stgit
   :link '(variable-link stgit-show-ignored))
 
+(defcustom stgit-default-show-patch-names t
+  "If non-nil, default to showing patch names in a new stgit buffer.
+
+Use \\<stgit-mode-map>\\[stgit-toggle-patch-names] \
+to toggle the this setting in an already-started StGit buffer."
+  :type 'boolean
+  :group 'stgit
+  :link '(variable-link stgit-show-patch-names))
+
+(defcustom stgit-default-show-committed nil
+  "Set to nil to inhibit showing of historical git commits by default.
+
+Use \\<stgit-mode-map>\\[stgit-toggle-committed] \
+to toggle this setting and to control how many commits are
+shown."
+  :type 'boolean
+  :group 'stgit
+  :link '(variable-link stgit-default-committed-count)
+  :link '(variable-link stgit-show-committed))
+
+(defcustom stgit-default-committed-count 5
+  "The number of historical commits to show when `stgit-show-committed'
+is enabled."
+  :type 'number
+  :group 'stgit
+  :link '(variable-link stgit-default-show-committed)
+  :link '(variable-link stgit-committed-count))
+
 (defcustom stgit-default-show-svn t
   "Set to non-nil to by default show subversion information in a
 new stgit buffer.
@@ -78,6 +99,13 @@ setting in an already-started StGit buffer."
   :group 'stgit
   :link '(variable-link stgit-show-worktree))
 
+(defcustom stgit-abbreviate-copies-and-renames t
+  "If non-nil, abbreviate copies and renames as \"dir/{old -> new}/file\"
+instead of \"dir/old/file -> dir/new/file\"."
+  :type 'boolean
+  :group 'stgit
+  :set 'stgit-set-default)
+
 (defcustom stgit-find-copies-harder nil
   "Try harder to find copied files when listing patches.
 
@@ -136,33 +164,6 @@ The alternate form is used when the patch name is hidden."
   :group 'stgit
   :set 'stgit-set-default)
 
-(defcustom stgit-default-show-committed nil
-  "Set to nil to inhibit showing of historical git commits by default.
-
-Use \\<stgit-mode-map>\\[stgit-toggle-committed] \
-to toggle this setting and to control how many commits are
-shown."
-  :type 'boolean
-  :group 'stgit
-  :link '(variable-link stgit-default-committed-count)
-  :link '(variable-link stgit-show-committed))
-
-(defcustom stgit-default-committed-count 5
-  "The number of historical commits to show when `stgit-show-committed'
-is enabled."
-  :type 'number
-  :link '(variable-link stgit-default-show-committed)
-  :link '(variable-link stgit-committed-count))
-
-(defcustom stgit-default-show-patch-names t
-  "If non-nil, default to showing patch names in a new stgit buffer.
-
-Use \\<stgit-mode-map>\\[stgit-toggle-patch-names] \
-to toggle the this setting in an already-started StGit buffer."
-  :type 'boolean
-  :group 'stgit
-  :link '(variable-link stgit-show-patch-names))
-
 (defcustom stgit-file-line-format "    %-11s %-2m %n   %c"
   "The format string used to format file lines.
 The format string is passed to `format-spec' and the following
@@ -179,62 +180,76 @@ format characters are recognized:
   :group 'stgit
   :set 'stgit-set-default)
 
+(defcustom stgit-git-program "git"
+  "The program used by `stgit-mode' to run git."
+  :type 'string
+  :group 'stgit)
+
+(defcustom stgit-stg-program "stg"
+  "The program used by `stgit-mode' to run StGit."
+  :type 'string
+  :group 'stgit)
+
+(defgroup stgit-faces nil
+  "Faces for `stgit-mode'."
+  :group 'stgit)
+
 (defface stgit-branch-name-face
   '((t :inherit bold))
   "The face used for the StGit branch name"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-top-patch-face
   '((((background dark)) (:weight bold :foreground "yellow"))
     (((background light)) (:weight bold :foreground "purple"))
     (t (:weight bold)))
   "The face used for the top patch names"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-applied-patch-face
   '((((background dark)) (:foreground "light yellow"))
     (((background light)) (:foreground "purple"))
     (t ()))
   "The face used for applied patch names"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-unapplied-patch-face
   '((((background dark)) (:foreground "gray80"))
     (((background light)) (:foreground "orchid"))
     (t ()))
   "The face used for unapplied patch names"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-committed-patch-face
   '((((background dark)) (:foreground "gray50"))
     (((background light)) (:foreground "gray50"))
     (t ()))
   "The face used for already committed patch names"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-description-face
   '((((background dark)) (:foreground "tan"))
     (((background light)) (:foreground "dark red")))
   "The face used for StGit descriptions"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-index-work-tree-title-face
   '((((supports :slant italic)) :slant italic)
     (t :inherit bold))
   "StGit mode face used for the \"Index\" and \"Work tree\" titles"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-unmerged-file-face
   '((((class color) (background light)) (:foreground "red" :bold t))
     (((class color) (background dark)) (:foreground "red" :bold t)))
   "StGit mode face used for unmerged file status"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-unknown-file-face
   '((((class color) (background light)) (:foreground "goldenrod" :bold t))
     (((class color) (background dark)) (:foreground "goldenrod" :bold t)))
   "StGit mode face used for unknown file status"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-ignored-file-face
   '((((class color) (background light)) (:foreground "grey60"))
@@ -245,13 +260,13 @@ format characters are recognized:
   '((((class color) (background light)) (:foreground "green" :bold t))
     (((class color) (background dark)) (:foreground "green" :bold t)))
   "StGit mode face used for permission changes."
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defface stgit-modified-file-face
   '((((class color) (background light)) (:foreground "purple"))
     (((class color) (background dark)) (:foreground "salmon")))
   "StGit mode face used for modified file status"
-  :group 'stgit)
+  :group 'stgit-faces)
 
 (defun stgit (dir)
   "Manage StGit patches for the tree in DIR.
@@ -271,7 +286,7 @@ See `stgit-mode' for commands available."
     (let ((cdup (with-output-to-string
                   (with-current-buffer standard-output
                     (cd dir)
-                    (unless (eq 0 (call-process "git" nil t nil
+                    (unless (eq 0 (call-process stgit-git-program nil t nil
                                                 "rev-parse" "--show-cdup"))
                       (error "Cannot find top-level git tree for %s" dir))))))
       (expand-file-name (concat (file-name-as-directory dir)
@@ -422,11 +437,11 @@ See also `stgit-message'.")
 
 (defun stgit-run (&rest args)
   (setq args (stgit-make-run-args args))
-  (let ((msgcmd (mapconcat #'identity args " ")))
-    (stgit-message "Running stg %s..." msgcmd)
+  (let ((msgcmd (mapconcat #'identity (cons stgit-stg-program args) " ")))
+    (stgit-message "Running %s..." msgcmd)
     (prog1
-        (apply 'call-process "stg" nil standard-output nil args)
-      (stgit-message "Running stg %s...done" msgcmd))))
+        (apply 'call-process stgit-stg-program nil standard-output nil args)
+      (stgit-message "Running %s...done" msgcmd))))
 
 (defun stgit-run-silent (&rest args)
   (let ((stgit-inhibit-messages t))
@@ -434,11 +449,11 @@ See also `stgit-message'.")
 
 (defun stgit-run-git (&rest args)
   (setq args (stgit-make-run-args args))
-  (let ((msgcmd (mapconcat #'identity args " ")))
-    (stgit-message "Running git %s..." msgcmd)
+  (let ((msgcmd (mapconcat #'identity (cons stgit-git-program args) " ")))
+    (stgit-message "Running %s..." msgcmd)
     (prog1
-        (apply 'call-process "git" nil standard-output nil args)
-      (stgit-message "Running git %s...done" msgcmd))))
+        (apply 'call-process stgit-git-program nil standard-output nil args)
+      (stgit-message "Running %s...done" msgcmd))))
 
 (defun stgit-run-git-silent (&rest args)
   (let ((stgit-inhibit-messages t))
@@ -2553,13 +2568,16 @@ When the command has finished, reload the stgit buffer."
                    (stgit-patches-marked-or-at-point nil 'allow-committed)))
          (patch-names (mapcar 'symbol-name patches))
          (hyphens (find-if (lambda (s) (string-match "^-" s)) patch-names))
+         (program (if git-mode stgit-git-program stgit-stg-program))
          (defaultcmd (if patches
-                         (concat (if git-mode "git" "stg") "  "
+                         (concat program
+                                 "  "
                                  (and hyphens "-- ")
                                  (mapconcat (if git-mode 'stgit-id 'identity)
                                             patch-names " "))
-                       "stg "))
-         (cmd (read-from-minibuffer "Shell command: " (cons defaultcmd 5)
+                       (concat stgit-stg-program " ")))
+         (cmd (read-from-minibuffer "Shell command: "
+                                    (cons defaultcmd (+ (length program) 2))
                                     nil nil 'shell-command-history))
          (async (string-match "&[ \t]*\\'" cmd))
          (buffer (get-buffer-create