help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q] How to make text invisible without modifying the buffer?


From: Rodrigo Morales
Subject: [Q] How to make text invisible without modifying the buffer?
Date: Fri, 13 Aug 2021 18:39:57 -0500

* 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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]