2

Is there a way I can collapse/expand regexp matches within a line?

e.g. let's say I have this list and want to hide some parts of it temporarily:

* apple: fruit; red
* butter: dairy; yellow

when I set the regexp to ":.*$" and fold the matches, it should become something like this:

* apple...
* butter...

when I set the regexp to ":.*;" instead, and fold the matches, it should become something like this:

* apple... red
* butter... yellow

And when I expand the list, it should get back to the original view:

* apple: fruit; red
* butter: dairy; yellow

However, none of the methods I found so far doesn't seem to work this way.

I tried folding mode, but it only worked for blocks of text, and it didn't work for string within a line.

i.e. it doesn't work when I set it to hide things between ":" and ";" below. It doesn't do anything in that case. It only kind of works (but not really appropriately for my purpose) when I set it to hide things between ":" and ":" since they are placed across the lines.

When I try to hide things between ":", this

* apple: fruit; red
* butter: dairy; yellow

becomes this:

* apple: fruit; red...
: dairy; yellow

(It might be not exactly like this: I tried this yesterday and I don't remember exactly except that it didn't work fine.)

I also tried hs-hide-all with text like "{this should be hidden}" in both org mode and emacs lisp mode, but it didn't do anything. Is this function known to be tricky or something? I'm not even sure if this function is supposed to work for hiding text within a line not across lines, or I'm misusing it.

stacko
  • 1,577
  • 1
  • 11
  • 18
  • What is the result you want? The first example you gave looks good to me. –  Mar 10 '16 at 22:37
  • @blujay, does my example look like I already achieved that? I meant the example to be something I want to achieve, I'll edit it. – stacko Mar 11 '16 at 00:40
  • The problem is that, instead of showing the actual results of what you tried, you simply say, "However, none of the methods I found so far doesn't seem to work this way." Try this: 1. Show the starting condition. 2. Show the desired result. 3. Show what you tried. 4. Show the actual result. For more, I suggest reading this: http://www.catb.org/esr/faqs/smart-questions.html#goal –  Mar 11 '16 at 01:26
  • @blujay, thanks for pointing that out. I edited it. – stacko Mar 11 '16 at 01:50
  • It's still a bit unclear. Try starting over, write in a very ordered way, in sequence, and be as concise as possible. Also, use code tags to make strings and regexps clear. And it would be very helpful if you would paste in the actual elisp code that you're running so we can reproduce exactly what you're doing. –  Mar 14 '16 at 09:09

0 Answers0