4

I want to make a follow mode where placing the cursor within certain parts of the buffer will cause some action to happen in another window. For example, using helm-follow-mode with helm-occur will cause another window to jump to the context of the selected line. I want to do something similar, except that I want to use another window to jump to a point in some buffer(s) based on the current paragraph.

To give a more concrete example, I have a read-only buffer "A" which has three paragraphs, A1, A2, and A3. And another buffer "B" which has many lines of text.

  +---------------------------+------------------------+
  |                           |                        |
  |         BUFFER A          |       BUFFER B         |
  |                           |                        |
  |   Paragraph A1            |  Line B1               |
  |                           |  Line B2               |
  |   Paragraph A2            |  Line B3               |
  |                           |  Line B4               |
  |   Paragraph A3            |  Line B5               |
  |                           |  Line B6               |
  |                           |  Line B7               |
  |                           |  Line B8               |
  |                           |  Line B9               |
  |                           |                        |
  +---------------------------+------------------------+

When my cursor moves from paragraph A1 into paragraph A2, buffer B should jump to some pre-determined position, for example line B8. This should happen without buffer A losing focus. Later, when my cursor moves out of paragraph A2 and into paragraph A3, buffer B will again jump to another pre-determined line, say B2. Now if I move the cursor back into paragraph A2, then buffer B will again jump to line B8, as before.

Is it possible to execute a "follow" action based on the cursor entering a paragraph? Can I do this with text properties? I want to maintain the ability to navigate buffer A just like any other read-only buffer (i.e. I want to select text and copy a region, perform an isearch within the buffer, etc.)

nispio
  • 8,225
  • 2
  • 36
  • 74

0 Answers0