help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easy to add with push but not to the end of a list


From: Emanuel Berg
Subject: Re: Easy to add with push but not to the end of a list
Date: Sat, 31 Dec 2022 23:09:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Heerdegen wrote:

>> How do you do a `pushlast' macro?
>
> I would start with `push' and change the definition so that
> the expansion uses an according `append' call.

Like this?

A lot of unfamiliar stuff it that code ...

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/list.el

(defmacro pushlast (newelt place)
  (declare (debug (form gv-place)))
  (if (symbolp place)
      (list 'setq place
            (list 'append place (list 'cons newelt nil)) )
    (macroexp-let2 macroexp-copyable-p x newelt
      (gv-letplace (getter setter) place
        (funcall setter `(append ,getter (cons ,x nil))) ))))

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]