emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/compat ed62b776b8 6/7: Add image-property


From: ELPA Syncer
Subject: [elpa] externals/compat ed62b776b8 6/7: Add image-property
Date: Mon, 11 Apr 2022 18:57:23 -0400 (EDT)

branch: externals/compat
commit ed62b776b85636fe0ef89a26a8d11539bf2f56f2
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Add image-property
---
 MANUAL       |  4 ++++
 compat-26.el | 27 +++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/MANUAL b/MANUAL
index 42168891f4..7402ddbec4 100644
--- a/MANUAL
+++ b/MANUAL
@@ -232,6 +232,10 @@ provided by Compat by default:
 - Function: file-local-name :: See [[info:elisp#Magic File Names][(elisp) 
Magic File Names]].
 - Function: file-name-quoted-p :: See [[info:elisp#File Name 
Expansion][(elisp) File Name Expansion]].
 - Function: file-name-quote :: See [[info:elisp#File Name Expansion][(elisp) 
File Name Expansion]].
+- Function: image-property :: Defined in ~image.el~.
+
+  This function can also be used as a generalised variable.  To use
+  this you need to explicitly require ~compat-26~.
 
 These functions are prefixed with ~compat~ prefix, and are only loaded
 when ~compat-26~ is required:
diff --git a/compat-26.el b/compat-26.el
index 4b8114fb69..739a9683ae 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -432,5 +432,32 @@ are non-nil, then the result is non-nil."
   (declare (indent 1) (debug if-let*))
   `(when-let* ,varlist ,@(or body '(t))))
 
+;;;; Defined in image.el
+
+;;* UNTESTED
+(compat-defun image-property (image property)
+  "Return the value of PROPERTY in IMAGE.
+Properties can be set with
+
+  (setf (image-property IMAGE PROPERTY) VALUE)
+
+If VALUE is nil, PROPERTY is removed from IMAGE."
+  (plist-get (cdr image) property))
+
+;;* UNTESTED
+(gv-define-simple-setter
+ image-property
+ (lambda (image property value)
+   (if (null value)
+       (while (cdr image)
+         ;; IMAGE starts with the symbol `image', and the rest is a
+         ;; plist.  Decouple plist entries where the key matches
+         ;; the property.
+         (if (eq (cadr image) property)
+             (setcdr image (cdddr image))
+           (setq image (cddr image))))
+     ;; Just enter the new value.
+     (setcdr image (plist-put (cdr image) property value)))))
+
 (provide 'compat-26)
 ;;; compat-26.el ends here



reply via email to

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