all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* invisible text and navigation commands
@ 2017-10-01 19:21 Paul Pogonyshev
  2017-10-02 13:50 ` Robert Weiner
  2017-10-02 16:20 ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Pogonyshev @ 2017-10-01 19:21 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

Hi,

My mode implements filtering in a read-only buffer by attaching `invisible'
property to text chunks and then modifying `buffer-invsibility-spec'
variable. This way I can hide/show large pieces of text pretty much
instantly and without modifying anything. However, I noticed that commands
like M-f etc. still "see through" the hidden text and will stop at points
where something is hidden.

Question: is it somehow possible to make M-f and so on (of course, for
interactive use only) ignore invisible text completely, as if it was not
there at all? If not, could such a feature be implemented in future?

Paul

[-- Attachment #2: Type: text/html, Size: 726 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: invisible text and navigation commands
  2017-10-01 19:21 invisible text and navigation commands Paul Pogonyshev
@ 2017-10-02 13:50 ` Robert Weiner
  2017-10-02 17:15   ` Paul Pogonyshev
  2017-10-02 16:20 ` Eli Zaretskii
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Weiner @ 2017-10-02 13:50 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

On Sun, Oct 1, 2017 at 3:21 PM, Paul Pogonyshev <pogonyshev@gmail.com>
wrote:

> Hi,
>
> My mode implements filtering in a read-only buffer by attaching
> `invisible' property to text chunks and then modifying
> `buffer-invsibility-spec' variable. This way I can hide/show large pieces
> of text pretty much instantly and without modifying anything. However, I
> noticed that commands like M-f etc. still "see through" the hidden text and
> will stop at points where something is hidden.
>

​If you use Emacs outline-mode or the GNU Hyperbole package's Koutliner
mode, you'll see they both move past invisible *lines* of text all at
once.  Each Emacs buffer contains a buffer-display-table with a
display-table slot that handles invisible lines.  See the doc. for
buffer-display-table.​

​​
> Question: is it somehow possible to make M-f and so on (of course, for
> interactive use only) ignore invisible text completely, as if it was not
> there at all? If not, could such a feature be implemented in future?
>
​​
​​If you want this to work for invisible fields rather than lines, I think
you'll have to write your own mode which overlays all the movement
commands.  Hyperbole's Koutline mode does this too, so you can use that as
an example, see:

   https://git.savannah.gnu.org/cgit/hyperbole.git/tree/kotl/kotl-mode.el

It is involved to get this right.

Bob

[-- Attachment #2: Type: text/html, Size: 3167 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: invisible text and navigation commands
  2017-10-01 19:21 invisible text and navigation commands Paul Pogonyshev
  2017-10-02 13:50 ` Robert Weiner
@ 2017-10-02 16:20 ` Eli Zaretskii
  2017-10-02 17:21   ` Paul Pogonyshev
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2017-10-02 16:20 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: emacs-devel

> From: Paul Pogonyshev <pogonyshev@gmail.com>
> Date: Sun, 1 Oct 2017 21:21:12 +0200
> 
> My mode implements filtering in a read-only buffer by attaching `invisible' property to text chunks and then
> modifying `buffer-invsibility-spec' variable. This way I can hide/show large pieces of text pretty much instantly
> and without modifying anything. However, I noticed that commands like M-f etc. still "see through" the hidden
> text and will stop at points where something is hidden.
> 
> Question: is it somehow possible to make M-f and so on (of course, for interactive use only) ignore invisible
> text completely, as if it was not there at all? If not, could such a feature be implemented in future?

You didn't show an example, but I'm guessing that your invisible
property causes "words" to appear on display which are made up from
parts of words in the buffer text.  IOW, you have something like this
in the buffer:

   word1bla yak-yak word2

and then you make the middle part of the text invisible such that
what's displayed is this:

  word1word2

and you then want M-f to move all the way to after '2', but what you
see instead is that it stops at 'w' after '1'.  Is that correct?

Emacs already moves point to the first visible character after some
command ends up with point on invisible text, but it never moves more
than to the closest visible character.  So for C-f and C-b you should
already have what you want, but M-f and M-b is not covered, and you
will have to write code similar to forward-visible-line.

Note that there's a caveat here: when invisible text splices parts of
words into "display words", the definition of what is a word for this
purpose is not trivial.  You should decide what exactly do you want to
do before writing the code.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: invisible text and navigation commands
  2017-10-02 13:50 ` Robert Weiner
@ 2017-10-02 17:15   ` Paul Pogonyshev
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Pogonyshev @ 2017-10-02 17:15 UTC (permalink / raw)
  To: rswgnu; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

> If you use Emacs outline-mode or the GNU Hyperbole package's Koutliner
mode, you'll see they both move past invisible *lines* of text all at once.

As far as I see, they still create overlays that span the hidden lines and
convey `invisible' property. So I don't really see how anything depends on
it being complete lines (in my cases that's also the case) or not...

> Each Emacs buffer contains a buffer-display-table with a display-table
slot that handles invisible lines.  See the doc. for buffer-display-table.

I checked this variable and it's also nil in an Outline buffer. Besides,
its documentation says it's about characters, so it doesn't seem relevant
to me.

Paul

[-- Attachment #2: Type: text/html, Size: 764 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: invisible text and navigation commands
  2017-10-02 16:20 ` Eli Zaretskii
@ 2017-10-02 17:21   ` Paul Pogonyshev
  2017-10-03  0:44     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Pogonyshev @ 2017-10-02 17:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs developers

> You didn't show an example

Sorry, I just thought there could be no misunderstandings. Your example
shows exactly what I meant, sort of confirming that.

> So for C-f and C-b you should
> already have what you want, but M-f and M-b is not covered, and you
> will have to write code similar to forward-visible-line.

That answers my question, though not in a way I'd hoped for :(  It's
an overkill to
write a customized command for all of M-f, M-a and so on. I just wanted to
know if Emacs already has some variable like `ignore-invisible-text-when-moving'
which I could just bind to t in my mode and be done.

Paul

On 2 October 2017 at 18:20, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Paul Pogonyshev <pogonyshev@gmail.com>
>> Date: Sun, 1 Oct 2017 21:21:12 +0200
>>
>> My mode implements filtering in a read-only buffer by attaching `invisible' property to text chunks and then
>> modifying `buffer-invsibility-spec' variable. This way I can hide/show large pieces of text pretty much instantly
>> and without modifying anything. However, I noticed that commands like M-f etc. still "see through" the hidden
>> text and will stop at points where something is hidden.
>>
>> Question: is it somehow possible to make M-f and so on (of course, for interactive use only) ignore invisible
>> text completely, as if it was not there at all? If not, could such a feature be implemented in future?
>
> You didn't show an example, but I'm guessing that your invisible
> property causes "words" to appear on display which are made up from
> parts of words in the buffer text.  IOW, you have something like this
> in the buffer:
>
>    word1bla yak-yak word2
>
> and then you make the middle part of the text invisible such that
> what's displayed is this:
>
>   word1word2
>
> and you then want M-f to move all the way to after '2', but what you
> see instead is that it stops at 'w' after '1'.  Is that correct?
>
> Emacs already moves point to the first visible character after some
> command ends up with point on invisible text, but it never moves more
> than to the closest visible character.  So for C-f and C-b you should
> already have what you want, but M-f and M-b is not covered, and you
> will have to write code similar to forward-visible-line.
>
> Note that there's a caveat here: when invisible text splices parts of
> words into "display words", the definition of what is a word for this
> purpose is not trivial.  You should decide what exactly do you want to
> do before writing the code.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: invisible text and navigation commands
  2017-10-02 17:21   ` Paul Pogonyshev
@ 2017-10-03  0:44     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2017-10-03  0:44 UTC (permalink / raw)
  To: emacs-devel

> I just wanted to know if Emacs already has some variable like
> `ignore-invisible-text-when-moving' which I could just bind to t in my
> mode and be done.

It kind of does, but it's already t by default.  It's just that it
doesn't quite do what you want, because what you want can't be done in
a generic way easily.  Movement normally works on the buffer text,
whereas in your case to make sense you'd want to work in terms of
displayed text.

BTW, you can get what you want by *deleting* the text instead of marking
it invisible ;-)


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-03  0:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-01 19:21 invisible text and navigation commands Paul Pogonyshev
2017-10-02 13:50 ` Robert Weiner
2017-10-02 17:15   ` Paul Pogonyshev
2017-10-02 16:20 ` Eli Zaretskii
2017-10-02 17:21   ` Paul Pogonyshev
2017-10-03  0:44     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.