 (require 'easymenu)
 
 ;;; user setable variables
-(defvar svn-status-verbose t
-  "*Add '-v' to svn status call.")
-(defvar svn-log-edit-file-name "++svn-log++"
+(defcustom svn-status-verbose t
+  "*Add '-v' to svn status call."
+  :type 'boolean
+  :group 'psvn)
+(defcustom svn-log-edit-file-name "++svn-log++"
   "*Name of a saved log file.
 This can be either absolute, or relative to the default directory
-of the *svn-log-edit* buffer.")
-(defvar svn-log-edit-insert-files-to-commit t
-  "*Insert the filelist to commit in the *svn-log* buffer")
-(defvar svn-log-edit-use-log-edit-mode
+of the *svn-log-edit* buffer."
+  :type 'file
+  :group 'psvn)
+(defcustom svn-log-edit-insert-files-to-commit t
+  "*Insert the filelist to commit in the *svn-log* buffer"
+  :type 'boolean
+  :group 'psvn)
+(defcustom svn-log-edit-use-log-edit-mode
   (and (condition-case nil (require 'log-edit) (error nil)) t)
   "*Use log-edit-mode as base for svn-log-edit-mode
-This variable takes effect only when psvn.el is being loaded.")
-(defvar svn-status-hide-unknown nil
+This variable takes effect only when psvn.el is being loaded."
+  :type 'boolean
+  :group 'psvn)
+(defcustom svn-status-hide-unknown nil
   "*Hide unknown files in `svn-status-buffer-name' buffer.
-This can be toggled with \\[svn-status-toggle-hide-unknown].")
-(defvar svn-status-hide-unmodified nil
+This can be toggled with \\[svn-status-toggle-hide-unknown]."
+  :type 'boolean
+  :group 'psvn)
+(defcustom svn-status-hide-unmodified nil
   "*Hide unmodified files in `svn-status-buffer-name' buffer.
-This can be toggled with \\[svn-status-toggle-hide-unmodified].")
-(defvar svn-status-sort-status-buffer t
+This can be toggled with \\[svn-status-toggle-hide-unmodified]."
+  :type 'boolean
+  :group 'psvn)
+(defcustom svn-status-sort-status-buffer t
   "Sort the `svn-status-buffer-name' buffer.
 Setting this variable to nil speeds up M-x svn-status.
 However, it is possible, that the sorting is wrong in this case.
-This can be toggled with \\[svn-status-toggle-sort-status-buffer].")
-
-(defvar svn-status-unmark-files-after-list '(commit revert)
+This can be toggled with \\[svn-status-toggle-sort-status-buffer]."
+  :type 'boolean
+  :group 'psvn)
+
+(defcustom svn-status-unmark-files-after-list '(commit revert)
   "*List of operations after which all user marks will be removed.
-Possible values are: commit, revert.")
-
-(defvar svn-status-negate-meaning-of-arg-commands '()
+Possible values are: commit, revert."
+  :type '(set (const commit)
+              (const revert))
+  :group 'psvn)
+
+(defcustom svn-status-negate-meaning-of-arg-commands '()
   "*List of operations that should use a negated meaning of the prefix argument.
-The supported functions are `svn-status' and `svn-status-set-user-mark'.")
-
-(defvar svn-status-svn-executable "svn"
+The supported functions are `svn-status' and `svn-status-set-user-mark'."
+  :type '(set (function-item svn-status)
+              (function-item svn-status-set-user-mark))
+  :group 'psvn)
+
+(defcustom svn-status-svn-executable "svn"
   "*The name of the svn executable.
-This can be either absolute or looked up on `exec-path'.")
+This can be either absolute or looked up on `exec-path'."
+  ;; Don't use (file :must-match t).  It doesn't know about `exec-path'.
+  :type 'file
+  :group 'psvn)
 
 ;; TODO: bind `process-environment' instead of running env?
 ;; That would probably work more reliably in Windows.
-(defvar svn-status-svn-environment-var-list '()
+(defcustom svn-status-svn-environment-var-list '()
   "*A list of environment variables that should be set for that svn process.
 If you set that variable, svn is called with that environment variables set.
 That is done via the env program.
 
-You could set it for example to '(\"LANG=C\")")
-
-(defvar svn-browse-url-function nil
+You could set it for example to '(\"LANG=C\")"
+  :type '(repeat (string :valid-regexp "=" :value "LANG=C"))
+  :group 'psvn)
+
+(defcustom svn-browse-url-function nil
   ;; If the user hasn't changed `svn-browse-url-function', then changing
   ;; `browse-url-browser-function' should affect psvn even after it has
   ;; been loaded.
   "Function to display a Subversion related WWW page in a browser.
 So far, this is used only for \"trac\" issue tracker integration.
 By default, this is nil, which means use `browse-url-browser-function'.
-Any non-nil value overrides that variable, with the same syntax.")
-
-(defvar svn-status-window-alist
+Any non-nil value overrides that variable, with the same syntax."
+  ;; It would be nice to show the full list of browsers supported by
+  ;; browse-url, but (custom-variable-type 'browse-url-browser-function)
+  ;; returns just `function' if browse-url has not yet been loaded,
+  ;; and there seems to be no easy way to autoload browse-url when
+  ;; the custom-type of svn-browse-url-function is actually needed.
+  ;; So I'll only offer enough choices to cover all supported types.
+  :type `(choice (const :tag "Specified by `browse-url-browser-function'" nil)
+                 (function :value browse-url-default-browser
+                           ;; In XEmacs 21.4.17, the `function' widget matches
+                           ;; all objects.  Constrain it here so that alists
+                           ;; fall through to the next choice.  Accept either
+                           ;; a symbol (fbound or not) or a lambda expression.
+                           :match ,(lambda (widget value)
+                                     (or (symbolp value) (functionp value))))
+                 (svn-alist :tag "Regexp/function association list"
+                            :key-type regexp :value-type function
+                            :value (("." . browse-url-default-browser))))
+  :link '(emacs-commentary-link "browse-url")
+  :group 'psvn)
+
+(defcustom svn-status-window-alist
   '((diff "*svn-diff*") (log "*svn-log*") (info t) (blame t) (proplist t) (update t))
   "An alist to specify which windows should be used for svn command outputs.
 The following keys are supported: diff, log, info, blame, proplist, update.

      nil ;; great
    (defsubst match-string-no-properties (match)
      (buffer-substring-no-properties (match-beginning match) (match-end match)))))

(defvar svn-global-keymap nil "Global keymap for psvn.el.
To bind this to a different key, customize `svn-status-prefix-key'.")


In either case the mark gets the face
`svn-status-update-available-face', and will only be visible if
`\\[svn-status-update]' is run with a prefix argument"
  :type '(choice (const :tag "Short \"**\"" t)
                 (const :tag "Long \"(Update Available)\"" nil))
  :group 'psvn)

(defvar svn-status-debug-level 0 "The psvn.el debugging verbosity level.
The higher the number, the more debug messages are shown.
