[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Better ways to inspect text properties?
From: |
Emanuel Berg |
Subject: |
Re: Better ways to inspect text properties? |
Date: |
Thu, 27 Oct 2022 17:05:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Eduardo Ochs wrote:
> (defun ee-string-intervals (str)
> "This is similar to `object-intervals', but uses another output format."
> (let ((pair< (lambda (pair1 pair2)
> (string< (symbol-name (car pair1))
> (symbol-name (car pair2))))))
> (cl-loop for (b e props) in (object-intervals str)
> for s = (substring-no-properties str b e)
> for pairs = (cl-loop for (x y) on props by 'cddr
> collect (list x y))
> collect (list s (sort pairs pair<)))))
A Common Lisp-style loop with three clauses - the first one
a for loop, the second one an assignment to a variable, and
the third one an assignment to a variable the result of a for
loop - which makes a collection based on certain aspects as
explicitely extracted - and then it is all sorted according to
a user-defined anonymous function to impose a total order.
Hm ... maybe we can use this piece of code in our next book
aimed at absolute beginners, maybe to replace the initial
"hello world" example?
--
underground experts united
https://dataswamp.org/~incal