From: Michael Heerdegen <michael_heerdegen@web.de>
To: Samuel Wales <samologist@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: buffer substring of only visible text
Date: Thu, 22 Sep 2022 11:14:54 +0200 [thread overview]
Message-ID: <87tu4zahyp.fsf@web.de> (raw)
In-Reply-To: <CAJcAo8t_+GAgS-jyv=yd=-VFVYJJ5cwqrDvkJtMNOba2t+OU_g@mail.gmail.com> (Samuel Wales's message of "Tue, 20 Sep 2022 18:08:03 -0700")
Samuel Wales <samologist@gmail.com> writes:
> i want to copy visible text from a region in a buffer, into
> a string.
>
> if any invisible regions are in the region, i want them to
> not be in the string.
Not a complicated task - and it seems that `backtrace--filter-visible'
is implementing exactly that:
#+begin_src emacs-lisp
(defun backtrace--filter-visible (beg end &optional _delete)
"Return the visible text between BEG and END."
(let ((result ""))
(while (< beg end)
(let ((next (next-single-char-property-change beg 'invisible)))
(unless (get-char-property beg 'invisible)
(setq result (concat result (buffer-substring beg (min end next)))))
(setq beg next)))
result))
#+end_src
If you don't want to rely on an internal function you might just copy
these few lines.
Michael.
prev parent reply other threads:[~2022-09-22 9:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 1:08 buffer substring of only visible text Samuel Wales
2022-09-21 1:34 ` Emanuel Berg
2022-09-21 11:34 ` Felix Dietrich
2022-09-21 22:57 ` Samuel Wales
2022-09-28 17:59 ` Felix Dietrich
2022-09-22 9:14 ` Michael Heerdegen [this message]
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=87tu4zahyp.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@gnu.org \
--cc=samologist@gmail.com \
/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).