Function: push

push is a macro defined in subr.el.gz.

Signature

(push NEWELT PLACE)

Documentation

Add NEWELT to the list stored in the generalized variable PLACE.

This is morally equivalent to (setf PLACE (cons NEWELT PLACE)), except that PLACE is evaluated only once (after NEWELT).

Other relevant functions are documented in the list group.

View in manual

Probably introduced at or before Emacs version 21.1.

Shortdoc

;; list
(push 'a list)
    -> [it depends]

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro push (newelt place)
  "Add NEWELT to the list stored in the generalized variable PLACE.
This is morally equivalent to (setf PLACE (cons NEWELT PLACE)),
except that PLACE is evaluated only once (after NEWELT)."
  (declare (debug (form gv-place)))
  (if (symbolp place)
      ;; Important special case, to avoid triggering GV too early in
      ;; the bootstrap.
      (list 'setq place
            (list 'cons newelt place))
    (require 'macroexp)
    (macroexp-let2 macroexp-copyable-p x newelt
      (gv-letplace (getter setter) place
        (funcall setter `(cons ,x ,getter))))))