Skip to content

Commit

Permalink
Use seq-keep instead of delq and mapcar
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Sep 21, 2023
1 parent ae7f5e9 commit 84eaa20
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 47 deletions.
2 changes: 1 addition & 1 deletion default.mk
Expand Up @@ -121,7 +121,7 @@ LIBGIT_VERSION = 0
MAGIT_VERSION = $(VERSION)
MAGIT_LIBGIT_VERSION = $(VERSION)
MAGIT_SECTION_VERSION = $(VERSION)
SEQ_VERSION = 2.23
SEQ_VERSION = 2.24
TRANSIENT_VERSION = 0.3.6
WITH_EDITOR_VERSION = 3.0.5

Expand Down
31 changes: 15 additions & 16 deletions lisp/magit-git.el
Expand Up @@ -2364,22 +2364,21 @@ and this option only controls what face is used.")
(magit-branch-remote (push name remotes))
(t (push name other)))))
(setq remotes
(delq nil
(mapcar
(lambda (name)
(if (string-match "\\`\\([^/]*\\)/\\(.*\\)\\'" name)
(let ((r (match-string 1 name))
(b (match-string 2 name)))
(and (not (equal b "HEAD"))
(if (equal (concat "refs/remotes/" name)
(magit-git-string
"symbolic-ref"
(format "refs/remotes/%s/HEAD" r)))
(magit--propertize-face
name 'magit-branch-remote-head)
name)))
name))
remotes)))
(seq-keep
(lambda (name)
(if (string-match "\\`\\([^/]*\\)/\\(.*\\)\\'" name)
(let ((r (match-string 1 name))
(b (match-string 2 name)))
(and (not (equal b "HEAD"))
(if (equal (concat "refs/remotes/" name)
(magit-git-string
"symbolic-ref"
(format "refs/remotes/%s/HEAD" r)))
(magit--propertize-face
name 'magit-branch-remote-head)
name)))
name))
remotes))
(let* ((current (magit-get-current-branch))
(target (magit-get-upstream-branch current)))
(dolist (name branches)
Expand Down
2 changes: 1 addition & 1 deletion lisp/magit-pkg.el
Expand Up @@ -5,7 +5,7 @@
(dash "20221013")
(git-commit "20230101")
(magit-section "20230101")
(seq "2.23")
(seq "2.24")
(transient "20230201")
(with-editor "20230118"))
:homepage "https://magit.vc"
Expand Down
14 changes: 7 additions & 7 deletions lisp/magit-refs.el
Expand Up @@ -623,17 +623,17 @@ line is inserted at all."
(magit-make-margin-overlay nil t)))

(defun magit-refs--format-local-branches ()
(let ((lines (delq nil (mapcar #'magit-refs--format-local-branch
(magit-git-lines
"for-each-ref"
(concat "--format=\
(let ((lines (seq-keep #'magit-refs--format-local-branch
(magit-git-lines
"for-each-ref"
(concat "--format=\
%(HEAD)%00%(refname:short)%00%(refname)%00\
%(upstream:short)%00%(upstream)%00%(upstream:track)%00"
(if magit-refs-show-push-remote "\
(if magit-refs-show-push-remote "\
%(push:remotename)%00%(push)%00%(push:track)%00%(subject)"
"%00%00%00%(subject)"))
"refs/heads"
magit-buffer-arguments)))))
"refs/heads"
magit-buffer-arguments))))
(unless (magit-get-current-branch)
(push (magit-refs--format-local-branch
(concat "*\0\0\0\0\0\0\0\0" (magit-rev-format "%s")))
Expand Down
38 changes: 17 additions & 21 deletions lisp/magit-submodule.el
Expand Up @@ -659,27 +659,23 @@ These sections can be expanded to show the respective commits."

(defun magit-submodule-list-refresh ()
(setq tabulated-list-entries
;; Backport version 2.23 of seq lacks seq-keep. Once that is
;; available trace this commment to find more instances where
;; it should be used.
(delq nil
(mapcar
(lambda (module)
(let ((default-directory
(expand-file-name (file-name-as-directory module))))
(and (file-exists-p ".git")
(or (not magit-submodule-list-predicate)
(funcall magit-submodule-list-predicate module))
(list module
(vconcat
(mapcar (pcase-lambda (`(,title ,width ,fn ,props))
(or (funcall fn `((:path ,module)
(:title ,title)
(:width ,width)
,@props))
""))
magit-repolist-columns))))))
(magit-list-module-paths))))
(seq-keep
(lambda (module)
(let ((default-directory
(expand-file-name (file-name-as-directory module))))
(and (file-exists-p ".git")
(or (not magit-submodule-list-predicate)
(funcall magit-submodule-list-predicate module))
(list module
(vconcat
(mapcar (pcase-lambda (`(,title ,width ,fn ,props))
(or (funcall fn `((:path ,module)
(:title ,title)
(:width ,width)
,@props))
""))
magit-repolist-columns))))))
(magit-list-module-paths)))
(message "Listing submodules...")
(tabulated-list-init-header)
(tabulated-list-print t)
Expand Down
2 changes: 1 addition & 1 deletion lisp/magit.el
Expand Up @@ -24,7 +24,7 @@
;; (dash "2.19.1")
;; (git-commit "3.3.0")
;; (magit-section "3.3.0")
;; (seq "2.23")
;; (seq "2.24")
;; (transient "0.3.6")
;; (with-editor "3.0.5"))

Expand Down

0 comments on commit 84eaa20

Please sign in to comment.