From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: buffer segments, uniform and automatic (was: Re: [Elisp: 8 out of 10 problems] I think the last one! (point))
Date: Tue, 13 Aug 2024 15:13:01 +0200 [thread overview]
Message-ID: <87jzgkftwi.fsf_-_@dataswamp.org> (raw)
In-Reply-To: 87ikw7xnji.fsf@dataswamp.org
> Okay, I can make out 'begin' and 'length'. Without looking,
> I do not understand at all what 'reg' is supposed to mean.
> region? regexp? register?
I came up with an idea how to do this!
It is based on this policy:
1. Everything has a beginning and an end.
2. Everything belongs to something else.
3. The only standard worth its name isn't the one that comes
from ISO, or the one in a manual, it isn't even the one the
best programmers (almost) always stick to - it is the one
created by a computer program.
So as for the segments in a text mode buffer, as for
point (2), it would look something like:
[ buffer [ paragraphs [ sentences [words] ] ] ]
Definitions of each has to be setup manually and individually,
as for (1), so for example for word it could be
(list (progn (forward-word) (forward-word -1) (point))
(progn (forward-word) (point)))
Then the program will define a set of functions for each
segment type, the same for each.
Note that so many common operations can be defined from the
definition, i.e. the (BEG END) pair:
-len is (- END BEG)
-reg is (BEG END)
-beg is BEG
-end is END
-cur is (buffer-substring-no-properties BEG END)
...
Everything else is then based on combinations of those:
-prev of -beg and -cur
-next of -end and -cur
...
And it goes on:
-all of -cur and -next (for some outer BEG END)
-count of `length' and -all (for some outer BEG and END)
I'm working on it now!
PS. Change of subject line as I think the previous one with
[square brackets] hindered the thread from being
archived online.
--
underground experts united
https://dataswamp.org/~incal
next prev parent reply other threads:[~2024-08-13 13:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-11 0:14 [Elisp: 8 out of 10 problems] I think the last one! (point) Emanuel Berg
2024-08-11 4:46 ` Emanuel Berg
2024-08-11 5:43 ` Eli Zaretskii
2024-08-11 5:22 ` Eli Zaretskii
2024-08-11 7:44 ` Yuri Khan
2024-08-11 9:06 ` Emanuel Berg
2024-08-11 12:16 ` Emanuel Berg
2024-08-13 13:13 ` Emanuel Berg [this message]
2024-08-13 14:10 ` buffer segments, uniform and automatic (was: Re: [Elisp: 8 out of 10 problems] I think the last one! (point)) Ihor Radchenko
2024-08-13 17:10 ` Emanuel Berg
2024-08-13 18:07 ` Emanuel Berg
2024-08-14 20:02 ` Emanuel Berg
2024-08-15 5:39 ` Emanuel Berg
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=87jzgkftwi.fsf_-_@dataswamp.org \
--to=incal@dataswamp.org \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).