[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 0a84a7c219 48/84: Add add-display-text-property
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 0a84a7c219 48/84: Add add-display-text-property from Emacs 29 |
Date: |
Tue, 3 Jan 2023 08:57:35 -0500 (EST) |
branch: externals/compat
commit 0a84a7c2195f5dee275072a74b4957fe2ac51774
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Add add-display-text-property from Emacs 29
---
compat-29.el | 43 +++++++++++++++++++++++++++++++++++++++++++
compat.texi | 10 ++++++++++
2 files changed, 53 insertions(+)
diff --git a/compat-29.el b/compat-29.el
index 0fcd3ad0d6..34b21d6070 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -437,6 +437,49 @@ be marked unmodified, effectively ignoring those changes."
(equal ,hash (buffer-hash)))
(restore-buffer-modified-p nil))))))))
+;;* UNTESTED
+(compat-defun add-display-text-property (start end prop value
+ &optional object)
+ "Add display property PROP with VALUE to the text from START to END.
+If any text in the region has a non-nil `display' property, those
+properties are retained.
+
+If OBJECT is non-nil, it should be a string or a buffer. If nil,
+this defaults to the current buffer."
+ :feature 'subr-x
+ (let ((sub-start start)
+ (sub-end 0)
+ disp)
+ (while (< sub-end end)
+ (setq sub-end (next-single-property-change sub-start 'display object
+ (if (stringp object)
+ (min (length object) end)
+ (min end (point-max)))))
+ (if (not (setq disp (get-text-property sub-start 'display object)))
+ ;; No old properties in this range.
+ (put-text-property sub-start sub-end 'display (list prop value))
+ ;; We have old properties.
+ (let ((vector nil))
+ ;; Make disp into a list.
+ (setq disp
+ (cond
+ ((vectorp disp)
+ (setq vector t)
+ (seq-into disp 'list))
+ ((not (consp (car disp)))
+ (list disp))
+ (t
+ disp)))
+ ;; Remove any old instances.
+ (when-let ((old (assoc prop disp)))
+ (setq disp (delete old disp)))
+ (setq disp (cons (list prop value) disp))
+ (when vector
+ (setq disp (seq-into disp 'vector)))
+ ;; Finally update the range.
+ (put-text-property sub-start sub-end 'display disp)))
+ (setq sub-start sub-end))))
+
;;;; Defined in files.el
(compat-defun file-parent-directory (filename)
diff --git a/compat.texi b/compat.texi
index 1c9f1fea94..cb89595c4f 100644
--- a/compat.texi
+++ b/compat.texi
@@ -2289,6 +2289,16 @@ Properties,Examining
Properties,,elisp,}).
@end defun
+@c copied from lisp/subr-x.el
+@defun add-display-text-property start end prop value &optional object
+Add display property @var{prop} with @var{value} to the text from
+@var{start} to @var{end}. If any text in the region has a non-nil
+@code{display} property, those properties are retained.
+
+If @var{object} is non-@code{nil}, it should be a string or a buffer.
+If @code{nil}, this defaults to the current buffer.
+@end defun
+
@c copied from lispref/lists.texi
@defun take n list
This function returns the @var{n} first elements of @var{list}. Essentially,
- [elpa] externals/compat bb86f3aa3b 37/84: Simplify compat--generate-testable, (continued)
- [elpa] externals/compat bb86f3aa3b 37/84: Simplify compat--generate-testable, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 282f2dc6a7 41/84: Call install-fn in compat--generate-testable, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 3f3f2e44d5 43/84: Split compat-insert-into-buffer into multiple tests, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 933d6fdf80 24/84: Add buffer-match-p from Emacs 29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 8d17ffdd88 29/84: Add file-has-changed-p from Emacs 29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 252d33e897 31/84: Fix incompatible function calls in compat-29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 9e0eb5b72f 33/84: Add compat-declare-version to compat-29.el, ELPA Syncer, 2023/01/03
- [elpa] externals/compat fdae099b00 34/84: Move if-let and related function from subr-x to subr, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 6ac6ed2a99 36/84: Use make-symbol instead of gensym in function-alias-p tests, ELPA Syncer, 2023/01/03
- [elpa] externals/compat ef5246cf55 38/84: Fix issues related to 'expect' tests, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 0a84a7c219 48/84: Add add-display-text-property from Emacs 29,
ELPA Syncer <=
- [elpa] externals/compat e6d279af18 14/84: Extend byte-compile-docstring-max-column to 100, ELPA Syncer, 2023/01/03
- [elpa] externals/compat c177ff5e83 17/84: Reuse ntake in take definition, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 0de389aca6 19/84: Add string-equal-ignore-case from Emacs 29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat ff331f6c29 22/84: Add prefixed plist-put from Emacs 29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 9aac0f55d1 23/84: Add prefixed plist-member from Emacs 29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 9ab3081959 26/84: Add string-pixel-width from Emacs 29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat d375504e3c 27/84: Add with-buffer-unmodified-if-unchanged from Emacs 29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat ded0f01036 40/84: Revert "Fix gv-expander for compat-alist-get", ELPA Syncer, 2023/01/03
- [elpa] externals/compat 878221eabd 44/84: Update the commentary section for compat-29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 4a56adbcdf 42/84: Remove references to the deleted "Emacs 24.5" node, ELPA Syncer, 2023/01/03