chiark / gitweb /
stgit.el: Improve use of def{group,custom,face}
authorGustav Hållberg <gustav@virtutech.com>
Sat, 8 Aug 2009 22:24:45 +0000 (00:24 +0200)
committerGustav Hållberg <gustav@virtutech.com>
Sat, 8 Aug 2009 22:40:23 +0000 (00:40 +0200)
 * Reorder calls to defcustom and defface to be more user-friendly
 * Use the :link tag where applicable
 * Add a :set handler to reload all stgit buffers when custom values
   are set

Signed-off-by: Gustav Hållberg <gustav@virtutech.com>
contrib/stgit.el

index 827b139f3d8fdc3382b537028118d1876fad3c41..6cb0f1e6bd7159b808a2335e5916197b738b2b0e 100644 (file)
@@ -272,17 +272,58 @@ (defun stgit-reload ()
       (goto-line curline)))
   (stgit-refresh-git-status))
 
+(defun stgit-set-default (symbol value)
+  "Set default value of SYMBOL to VALUE using `set-default' and
+reload all StGit buffers."
+  (set-default symbol value)
+  (dolist (buf (buffer-list))
+    (with-current-buffer buf
+      (when (eq major-mode 'stgit-mode)
+        (stgit-reload)))))
+
 (defgroup stgit nil
-  "A user interface for the StGit patch maintenance tool.
+  "A user interface for the StGit patch maintenance tool."
+  :group 'tools
+  :link '(function-link stgit)
+  :link '(url-link "http://www.procode.org/stgit/"))
 
-See `stgit-mode' for more information."
-  :group 'tools)
+(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)
 
-(defface stgit-description-face
-  '((((background dark)) (:foreground "tan"))
-    (((background light)) (:foreground "dark red")))
-  "The face used for StGit descriptions"
-  :group 'stgit)
+(defcustom stgit-default-show-worktree t
+  "Set to non-nil to by default show the working tree in a new stgit buffer.
+
+Use \\<stgit-mode-map>\\[stgit-toggle-worktree] to toggle the this setting in an already-started StGit buffer."
+  :type 'boolean
+  :group 'stgit
+  :link '(variable-link stgit-show-worktree))
+
+(defcustom stgit-find-copies-harder nil
+  "Try harder to find copied files when listing patches.
+
+When not nil, runs git diff-tree with the --find-copies-harder
+flag, which reduces performance."
+  :type 'boolean
+  :group 'stgit
+  :set 'stgit-set-default)
+
+(defcustom stgit-show-worktree-mode 'center
+  "This variable controls where the \"Index\" and \"Work tree\"
+will be shown on in the buffer.
+
+It can be set to 'top (above all patches), 'center (show between
+applied and unapplied patches), and 'bottom (below all patches)."
+  :type '(radio (const :tag "above all patches (top)" top)
+                (const :tag "between applied and unapplied patches (center)"
+                       center)
+                (const :tag "below all patches (bottom)" bottom))
+  :group 'stgit
+  :link '(variable-link stgit-show-worktree)
+  :set 'stgit-set-default)
 
 (defface stgit-branch-name-face
   '((t :inherit bold))
@@ -310,10 +351,16 @@ (defface stgit-unapplied-patch-face
   "The face used for unapplied patch names"
   :group 'stgit)
 
-(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"
+(defface stgit-description-face
+  '((((background dark)) (:foreground "tan"))
+    (((background light)) (:foreground "dark red")))
+  "The face used for StGit descriptions"
+  :group 'stgit)
+
+(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)
 
 (defface stgit-unmerged-file-face
@@ -339,20 +386,10 @@ (defface stgit-file-permission-face
   "StGit mode face used for permission changes."
   :group 'stgit)
 
-(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)
-
-
-(defcustom stgit-find-copies-harder
-  nil
-  "Try harder to find copied files when listing patches.
-
-When not nil, runs git diff-tree with the --find-copies-harder
-flag, which reduces performance."
-  :type 'boolean
+(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)
 
 (defconst stgit-file-status-code-strings
@@ -1608,28 +1645,6 @@ (defun stgit-refresh (&optional arg)
     (stgit-refresh-git-status))
   (stgit-reload))
 
-(defcustom stgit-show-worktree-mode 'center
-  "This variable controls where the \"Index\" and \"Work tree\"
-will be shown on in the buffer.
-
-It can be set to 'top (above all patches), 'center (show between
-applied and unapplied patches), and 'bottom (below all patches).
-
-See also `stgit-show-worktree'."
-  :type '(radio (const :tag "above all patches (top)" top)
-                (const :tag "between applied and unapplied patches (center)"
-                       center)
-                (const :tag "below all patches (bottom)" bottom))
-  :group 'stgit)
-
-(defcustom stgit-default-show-worktree
-  t
-  "Set to non-nil to by default show the working tree in a new stgit buffer.
-
-This value is used as the default value for `stgit-show-worktree'."
-  :type 'boolean
-  :group 'stgit)
-
 (defvar stgit-show-worktree nil
   "If nil, inhibit showing work tree and index in the stgit buffer.
 
@@ -1680,11 +1695,4 @@ (defun stgit-toggle-unknown (&optional arg)
           (not stgit-show-unknown)))
   (stgit-reload))
 
-(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)
-
 (provide 'stgit)