* [Q] How to make text invisible without modifying the buffer?
@ 2021-08-13 23:39 Rodrigo Morales
2021-08-14 0:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 6:03 ` Eli Zaretskii
0 siblings, 2 replies; 4+ messages in thread
From: Rodrigo Morales @ 2021-08-13 23:39 UTC (permalink / raw)
To: help-gnu-emacs
* Epilogue
I'm writing a mode for reading logs from the weechat IRC client.
Here's an example of a log file from weechat.
#+BEGIN_EXAMPLE
00:04:20 <-- user8 has quit (Quit: leaving)
00:05:06 user1 foo
00:05:29 --> user4 has joined #foo
00:06:11 <-- user5 has quit (Quit: Client closed)
00:06:24 <-- user6 has quit
00:06:28 --> user7 has joined #foo
00:06:31 user2 bar
00:07:05 user3 fizz
#+END_EXAMPLE
Note that a tab character is used as the delimiter for timestamps,
user names and the actual message.
I would like to hide those lines that present information of a user
logging in or logging out. That is, those lines that matches the
following regular expression (the regex has been enclosed in double
quotes have been used to indicate that the last character is a tab
character)
#+BEGIN_EXAMPLE
"^[0-9]{2}:[0-9]{2}:[0-9]{2} (-->|<--) "
#+END_EXAMPLE
* The question
To begin writing this mode, I was wondering: How to make a line
invisible? and came up with the following expression which accomplishes
that
#+BEGIN_SRC elisp
(put-text-property (point-at-bol) (+ (point-at-eol) 1) 'invisible t)
#+END_SRC
The problem with this expression is the fact that it modifies the
current buffer and I don't want this to happen, so my question is: How
to make a line invisible without making the buffer to think that a
modification has been performed?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Q] How to make text invisible without modifying the buffer?
2021-08-13 23:39 [Q] How to make text invisible without modifying the buffer? Rodrigo Morales
@ 2021-08-14 0:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
[not found] ` <87im0824b4.fsf@gmail.com>
2021-08-14 6:03 ` Eli Zaretskii
1 sibling, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-14 0:01 UTC (permalink / raw)
To: help-gnu-emacs
Rodrigo Morales wrote:
> To begin writing this mode, I was wondering: How to make
> a line invisible? and came up with the following expression
> which accomplishes that
>
> #+BEGIN_SRC elisp (put-text-property (point-at-bol) (+
> (point-at-eol) 1) 'invisible t) #+END_SRC
>
> The problem with this expression is the fact that it
> modifies the current buffer and I don't want this to happen
`narrow-to-region'?
Restrict editing in this buffer to the current region.
The rest of the text becomes temporarily invisible and
untouchable but is not deleted; if you save the buffer in
a file, the invisible text is included in the file. C-x
n w makes all visible again.
Flirting with not disaster perhaps but ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Q] How to make text invisible without modifying the buffer?
[not found] ` <87im0824b4.fsf@gmail.com>
@ 2021-08-14 3:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-14 3:29 UTC (permalink / raw)
To: help-gnu-emacs
Rodrigo Morales wrote:
> I can look into how to make narrow-to-region to work into
> multiple regions but that would prensent the XY problem,
> where X is "How to hide entire lines without modifying the
> current buffer" and Y being "How to make narrow-to-region
> work in separated regions"?
https://www.emacswiki.org/emacs/HideLines
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Q] How to make text invisible without modifying the buffer?
2021-08-13 23:39 [Q] How to make text invisible without modifying the buffer? Rodrigo Morales
2021-08-14 0:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-14 6:03 ` Eli Zaretskii
1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2021-08-14 6:03 UTC (permalink / raw)
To: help-gnu-emacs
> From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
> Date: Fri, 13 Aug 2021 18:39:57 -0500
>
> #+BEGIN_SRC elisp
> (put-text-property (point-at-bol) (+ (point-at-eol) 1) 'invisible t)
> #+END_SRC
>
> The problem with this expression is the fact that it modifies the
> current buffer and I don't want this to happen, so my question is: How
> to make a line invisible without making the buffer to think that a
> modification has been performed?
The usual method is to wrap your code in with-silent-modifications.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-14 6:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-13 23:39 [Q] How to make text invisible without modifying the buffer? Rodrigo Morales
2021-08-14 0:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
[not found] ` <87im0824b4.fsf@gmail.com>
2021-08-14 3:29 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-14 6:03 ` Eli Zaretskii
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).