Function: org-pushnew-to-end

org-pushnew-to-end is a macro defined in org-macs.el.

Signature

(org-pushnew-to-end VAL VAR)

Documentation

Like cl-pushnew but pushes to the end of the list.

Uses equal for comparisons.

Beware: this performs O(N) memory allocations, so if you use it in a loop, you get an unnecessary O(N²) space complexity, so you're usually better off using cl-pushnew (with a final reverse if you care about the order of elements).

Source Code

;; Defined in ~/.emacs.d/elpa/org-9.8.2/org-macs.el
(defmacro org-pushnew-to-end (val var)
  "Like `cl-pushnew' but pushes to the end of the list.
Uses `equal' for comparisons.

Beware: this performs O(N) memory allocations, so if you use it in a loop, you
get an unnecessary O(N²) space complexity, so you're usually better off using
`cl-pushnew' (with a final `reverse' if you care about the order of elements)."
  (declare (debug (form gv-place)))
  (let ((v (make-symbol "v")))
    `(let ((,v ,val))
       (unless (member ,v ,var)
         (setf ,var (append ,var (list ,v)))))))