emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [BUG] in org-property-drawer-re?
Date: Wed, 02 Oct 2013 13:38:29 +0200	[thread overview]
Message-ID: <87txgz298q.fsf@gmail.com> (raw)
In-Reply-To: 87li2ct2t3.fsf@gmail.com

Nicolas Goaziou <n.goaziou@gmail.com> writes:

Hello,

> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> This is just a cheep way to match any character at all, because \000 should
>> not be part of any string (in C it indicates the end of a string).
>> In principle you could put any character you are sure will not turn up,
>> but \000 seems to be the safest choice.  It is
>> faster (I think) than "\\(.\\|\n\\)*" because the first will
>> just run fast and streight with a table lookup while the
>> latter need to always alternate between two alternatives.
>> I have not timed it, though.
>
> On that topic, I would add that "^\000" must be used with care, as it
> can lead to a stack overflow in regexp matcher error quite easily. In
> particular, it may be safe to use it to match a property drawer, which
> will not be very large, but I think it's wrong to use it to match
> regular blocks or drawers, which can have arbitrary long size.
>
> For example a regexp like "[^\000]\\." will fail when matching around
> 500 lines (72 characters long). Of course, constructs like
> "\\(.\\|\n\\)*\\." will also fail, but my point is that it is tempting
> to use "^\000" even though a regexp may not be the correct answer to the
> problem.

Conceptually it looks perfect(ly simple) to me, and I'm happy that I
discovered the pattern now by accident (better late than never), but
stack overflow is of course an important point.

Reminds me of my little [[https://github.com/tj64/org-hlc][org-hlc.el]]
library (hidden lines cookies)

,-------------------------------------------------------------------------------
| org-hlc.el implements hidden-lines-cookies for Org-mode
|
| hidden-lines-cookies (hlc) are small cookies at the end of each folded (and
| visible) headline in an Org-mode buffer that show the number of hidden lines
| before the next visible headline.
|
| hidden-lines-cookies can be handled with three user commands:
| org-hlc-show-hidden-lines-cookies, org-hlc-hide-hidden-lines-cookies, and the
| convenience command org-hlc-toggle-hidden-lines-cookies that toggles between
| the two other commands conditional on the last one executed.
|
| The appearance of the cookies can be customized by changing the values of four
| customizable variables: org-hlc-hidden-lines-cookie-left-delimiter (with
| default value "["), org-hlc-hidden-lines-cookie-right-delimiter (with default
| value "]"), org-hlc-hidden-lines-cookie-left-signal-char (with default value
| "#") and org-hlc-hidden-lines-cookie-right-signal-char (with default value
| "").
|
| Thus an exemplary folded headline with 165 hidden lines before the next
| visible headline might look like this when hidden-lines-cookies are shown:
|
| ,----------------- | *** Headline [#165] `-----------------
|
`-------------------------------------------------------------------------------

that was conceptually all 'wrong':

 - the cookies are written in the original buffer (but that could easily be
   changed to a temporary indirect buffer)
 - cookies are only shown/updated with explicit user commands

but it works even in 7000 lines .el or .org files. 

The other attempt to 'do it right' based on a library by Francois
Pinard, [[https://github.com/tj64/org-weights][org-weights.el]], uses
overlays and dynamic updates of the tree-weights via change hooks - much
better in theory - but somehow overwhelms Emacs capacities in big files
so that user experience is affected.

--
cheers,
Thorsten

      parent reply	other threads:[~2013-10-02 11:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 17:50 [BUG] in org-property-drawer-re? Thorsten Jolitz
2013-10-01 18:17 ` Carsten Dominik
2013-10-01 18:36   ` Thorsten Jolitz
2013-10-01 18:44     ` Carsten Dominik
2013-10-02  9:55   ` Nicolas Goaziou
2013-10-02 11:05     ` Carsten Dominik
2013-10-02 11:14       ` Nicolas Goaziou
2013-10-02 11:37         ` Carsten Dominik
2013-10-02 11:38     ` Thorsten Jolitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87txgz298q.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

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).