Function: define-modify-macro

define-modify-macro is a macro defined in cl.el.gz.

Signature

(define-modify-macro NAME ARGLIST FUNC &optional DOC)

Documentation

Define a setf-like modify macro.

If NAME is called, it combines its PLACE argument with the other arguments from ARGLIST using FUNC. For example:

  (define-modify-macro incf (&optional (n 1)) +)

You can replace this macro with gv-letplace.

View in manual

Probably introduced at or before Emacs version 24.3.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/cl.el.gz
(defmacro define-modify-macro (name arglist func &optional doc)
  "Define a `setf'-like modify macro.
If NAME is called, it combines its PLACE argument with the other
arguments from ARGLIST using FUNC.  For example:

  (define-modify-macro incf (&optional (n 1)) +)

You can replace this macro with `gv-letplace'."
  (declare (debug
            (&define name cl-lambda-list ;; should exclude &key
                     symbolp &optional stringp))
           (indent defun))
  (if (memq '&key arglist)
      (error "&key not allowed in define-modify-macro"))
  (require 'cl-macs)                    ;For cl--arglist-args.
  (let ((place (make-symbol "--cl-place--")))
    `(cl-defmacro ,name (,place ,@arglist)
       ,doc
       (,(if (memq '&rest arglist) #'cl-list* #'list)
        #'cl-callf ',func ,place
        ,@(cl--arglist-args arglist)))))