Commit c51075b5 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit--format-popup-variable:choices: new function

This function used to be part of Magit-Popup
under the name `magit-popup-format-variable'.
parent e95550cd
......@@ -747,7 +747,8 @@ is used instead. It defaults to `false'."
(defun magit-format-branch*rebase ()
(let ((branch (magit-branch-config-branch)))
(magit-popup-format-variable (format "branch.%s.rebase" branch)
(format "branch.%s.rebase" branch)
'("true" "false")
"false" "pull.rebase"
(+ (length branch) 20))))
......@@ -772,7 +773,8 @@ which by default it is not."
(defun magit-format-branch*pushRemote ()
(let ((branch (magit-branch-config-branch)))
(magit-popup-format-variable (format "branch.%s.pushRemote" branch)
(format "branch.%s.pushRemote" branch)
nil "remote.pushDefault"
(+ (length branch) 20))))
......@@ -791,7 +793,8 @@ When `false' (the default) then pulling is done by merging."
(magit--set-popup-variable "pull.rebase" '("true" "false") "false"))
(defun magit-format-pull.rebase ()
(magit-popup-format-variable "pull.rebase" '("true" "false") "false" nil 19))
"pull.rebase" '("true" "false") "false" nil 19))
(defun magit-cycle-remote.pushDefault ()
......@@ -804,8 +807,8 @@ using the Git variable `branch.<name>.pushRemote'."
(magit--set-popup-variable "remote.pushDefault" (magit-list-remotes)))
(defun magit-format-remote.pushDefault ()
(magit-popup-format-variable "remote.pushDefault"
(magit-list-remotes) nil nil 19))
"remote.pushDefault" (magit-list-remotes) nil nil 19))
(defun magit-cycle-branch*autoSetupMerge ()
......@@ -831,8 +834,8 @@ When `false' then the variables are never set."
'("always" "true" "false") "true"))
(defun magit-format-branch*autoSetupMerge ()
(magit-popup-format-variable "branch.autoSetupMerge"
'("always" "true" "false") "true" nil 23))
"branch.autoSetupMerge" '("always" "true" "false") "true" nil 23))
(defun magit-cycle-branch*autoSetupRebase ()
......@@ -857,7 +860,8 @@ When `never' (the default) then the variable is never set."
'("always" "local" "remote" "never") "never"))
(defun magit-format-branch*autoSetupRebase ()
(magit-popup-format-variable "branch.autoSetupRebase"
'("always" "local" "remote" "never")
"never" nil 23))
......@@ -1837,7 +1837,54 @@ the reference is used. The first regexp submatch becomes the
(message "%s %s" variable
(magit-popup-format-variable variable choices default other)))
variable choices default other)))
(defun magit--format-popup-variable:choices
(variable choices &optional default other width)
(concat variable
(if width (make-string (- width (length variable)) ?\s) " ")
variable choices default other)))
(defun magit--format-popup-variable:choices*
(variable choices &optional default other)
(let ((local (magit-git-string "config" "--local" variable))
(global (magit-git-string "config" "--global" variable)))
(when other
(setq other (--when-let (magit-get other)
(concat other ":" it))))
(propertize "[" 'face 'magit-popup-disabled-argument)
(lambda (choice)
(propertize choice 'face (if (equal choice local)
(propertize "|" 'face 'magit-popup-disabled-argument))
(when (or global other default)
(propertize "|" 'face 'magit-popup-disabled-argument)
(cond (global
(propertize (concat "global:" global)
'face (cond (local
((member global choices)
(propertize other
'face (if local
(propertize (concat "default:" default)
'face (if local
(propertize "]" 'face 'magit-popup-disabled-argument))))
(provide 'magit-git)
;;; magit-git.el ends here
......@@ -296,7 +296,8 @@ Delete the symbolic-ref \"refs/remotes/<remote>/HEAD\"."
(defun magit-format-remote*tagOpt ()
(let ((remote (magit-remote-config--remote)))
(magit-popup-format-variable (format "remote.%s.tagOpts" remote)
(format "remote.%s.tagOpts" remote)
'("--no-tags" "--tags") nil nil
(+ (length remote) 16))))
......@@ -508,8 +509,8 @@ missing. To add them use something like:
:max-action-columns 1)
(defun magit-pull-format-branch*rebase ()
(magit-popup-format-variable (format "branch.%s.rebase"
(or (magit-get-current-branch) "<name>"))
(format "branch.%s.rebase" (or (magit-get-current-branch) "<name>"))
'("true" "false")
"false" "pull.rebase"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment