Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow commands to filter arguments from popup #1243

Merged
merged 2 commits into from
Feb 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions magit-popup.el
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -277,6 +277,21 @@ that without users being aware of it could lead to tears.
(defvar magit-current-popup nil) (defvar magit-current-popup nil)
(defvar magit-current-popup-args nil) (defvar magit-current-popup-args nil)


(defun magit-current-popup-args (&rest filter)
(let ((-compare-fn (lambda (a b) (magit-popup-arg-match b a))))
(-filter (if (eq (car filter) :not)
(lambda (arg) (not (-contains? (cdr filter) arg)))
(when (eq (car filter) :only)
(pop filter))
(lambda (arg) (-contains? filter arg)))
magit-current-popup-args)))

(defun magit-popup-arg-match (pattern string)
(if (or (string-match-p "=$" pattern)
(string-match-p "^-[A-Z]$" pattern))
(string-match (format "^%s\\(.*\\)$" pattern) string)
(string-equal string pattern)))

(cl-defstruct magit-popup-event key dsc arg fun use val) (cl-defstruct magit-popup-event key dsc arg fun use val)


(defun magit-popup-event-keydsc (ev) (defun magit-popup-event-keydsc (ev)
Expand Down