Function: mpc-reorder
mpc-reorder is a byte-compiled function defined in mpc.el.gz.
Signature
(mpc-reorder &optional NODEACTIVATE)
Documentation
Reorder entries based on the currently active selections.
I.e. split the current browser buffer into a first part containing the entries included in the selection, then a separator, and then the entries not included in the selection. Return non-nil if a selection was deactivated.
Source Code
;; Defined in /usr/src/emacs/lisp/mpc.el.gz
(defun mpc-reorder (&optional nodeactivate)
"Reorder entries based on the currently active selections.
I.e. split the current browser buffer into a first part containing the
entries included in the selection, then a separator, and then the entries
not included in the selection.
Return non-nil if a selection was deactivated."
(mpc-select-save
(let ((constraints (mpc-constraints-get-current (current-buffer)))
(active 'all))
;; (unless (equal constraints mpc-constraints)
;; (setq-local mpc-constraints constraints)
(dolist (cst constraints)
(let ((vals (apply #'mpc-union
(mapcar (lambda (val)
(mpc-cmd-list mpc-tag (car cst) val))
(cdr cst)))))
(setq active
(if (listp active) (seq-intersection active vals) vals))))
(when (listp active)
;; Remove the selections if they are all in conflict with
;; other constraints.
(let ((deactivate t))
(dolist (sel selection)
(when (member sel active) (setq deactivate nil)))
(when deactivate
;; Variable declared/used by `mpc-select-save'.
(when selection
(setq mpc--changed-selection t))
(unless nodeactivate
(setq selection nil)
(mapc #'delete-overlay mpc-select)
(setq mpc-select nil)
(mpc-tagbrowser-all-select))))
;; Don't bother splitting the "active" elements to the first part if
;; they're the same as the selection.
(when (equal (sort (copy-sequence active) #'string-lessp)
(sort (copy-sequence selection) #'string-lessp))
(setq active 'all)))
;; FIXME: This `mpc-sort' takes a lot of time. Maybe we should
;; be more clever and presume the buffer is mostly sorted already.
(mpc-sort (if (listp active) active))
(mpc-separator (if (listp active) active)))))