Questions tagged [setf]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
51 views

How to find if an Emacs lisp function is setf-able?

Emacs Lisp setf macro allows you to set generalized variables. You can, for example change the size of the current window with the following form: (setf (window-height) 10) The macro will translate ...
1
vote
2answers
356 views

setf + alist-get but with "equal" instead of "eq"?

I got a suggestion to use setf to replace value in an alist: Replace element in a list / add in case of absence, with custom test/key functions The example was provided, but it doesn't work if key is ...
2
votes
1answer
45 views

`cl-incf` returns inconsistent values

(setq ali '()) >>> nil (cl-incf (alist-get 'a ali 0)) >>> ((a . 1)) (setf (alist-get 'b ali) 0) >>> ((b . 0) (a . 1)) (cl-incf (alist-get 'b ali 0)) >>> 1 As you ...
2
votes
1answer
245 views

How can I make `setf` work with `plist-get`?

There's no built-in setter for plist-get. Example: (let ((pl '(:what (one)))) (push 'two (plist-get pl :what)) pl) Error: let*: Symbol’s function definition is void: \(setf\ plist-get\) How can I ...
2
votes
0answers
20 views

Is there a generalized setter for buffer-modified-p?

It is very simple to define a simple generalized setter for buffer-modified-p: (gv-define-simple-setter buffer-modified-p set-buffer-modified-p) That enables constructs like: (with-current-buffer "...
0
votes
3answers
109 views

How do I remove :width and :height from an image created with create-image?

I am trying to make jabber.el support images sent from e.g. Conversations. I download the image using url-retrieve-synchonously and call create-image to get an image which I can then use with insert-...
7
votes
1answer
449 views

Setf weird expansion

Trying to understand what setf can do, I called (macroexpand '(setf (aref vec i) val)) ⇒ (let* ((v vec) (v i)) (aset v v val)) This seems obviously wrong. However I couldn't create an actual ...