From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Better ways to inspect text properties?
Date: Thu, 27 Oct 2022 17:05:38 +0200 [thread overview]
Message-ID: <87ilk5johp.fsf@dataswamp.org> (raw)
In-Reply-To: CADs++6g5vacg5s66PNETT9nq39WqsH2kavc6JqKvQ_oEmmuHnQ@mail.gmail.com
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
next prev parent reply other threads:[~2022-10-27 15:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 23:19 Better ways to inspect text properties? Eduardo Ochs
2022-10-27 2:54 ` Emanuel Berg
2022-10-27 5:46 ` Eli Zaretskii
2022-10-27 6:45 ` Eduardo Ochs
2022-10-27 7:25 ` Emanuel Berg
2022-10-27 14:03 ` Eduardo Ochs
2022-10-27 15:05 ` Emanuel Berg [this message]
2022-10-28 15:19 ` Eduardo Ochs
2022-10-29 23:46 ` Samuel Wales
2022-10-30 1:08 ` Eduardo Ochs
2022-10-30 4:51 ` Samuel Wales
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ilk5johp.fsf@dataswamp.org \
--to=incal@dataswamp.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).