From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [BUG] in org-property-drawer-re? Date: Tue, 1 Oct 2013 20:17:08 +0200 Message-ID: References: <87r4c4519w.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Content-Type: multipart/signed; boundary="Apple-Mail=_1F66574B-7F5D-4A97-B425-5FA35FE294B4"; protocol="application/pgp-signature"; micalg=pgp-sha1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR4Vf-0001OE-K0 for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 14:17:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VR4VV-0003i1-9y for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 14:17:23 -0400 Received: from mail-ea0-x22f.google.com ([2a00:1450:4013:c01::22f]:48975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR4VU-0003h4-Sc for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 14:17:13 -0400 Received: by mail-ea0-f175.google.com with SMTP id m14so3628552eaj.34 for ; Tue, 01 Oct 2013 11:17:11 -0700 (PDT) In-Reply-To: <87r4c4519w.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thorsten Jolitz Cc: emacs-orgmode@gnu.org --Apple-Mail=_1F66574B-7F5D-4A97-B425-5FA35FE294B4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 1.10.2013, at 19:50, Thorsten Jolitz wrote: >=20 > Hi List,=20 >=20 > for the navi-mode keyword-search for complete property drawers I = copied >=20 > ,----------------------- > | org-property-drawer-re > `----------------------- >=20 > from org.el: >=20 > #+begin_src emacs-lisp > (concat "\\(" org-property-start-re "\\)[^\000]*\\(" > org-property-end-re "\\)\n?") > #+end_src >=20 > #+results: > : \(^[ ]*:PROPERTIES:[ ]*$\)[^\\000]*\(^[ ]*:END:[ = ]*$\) > : ? >=20 > A bit unreadable, but you get the message ... here is my hopefully = equivalent > version:=20 >=20 > ,-------------------------------------------------------------- > | (:propertydrawer > | . (concat "\\(^[\\s\\t]*:PROPERTIES:[\\s\\t]*$\\)[^\\000]*" > | "\\(^[\\s\\t]*:END:[\\s\\t]*$\\)\\n?")) > `-------------------------------------------------------------- >=20 > But this did not match correctly in Bernt Hansens tutorial: Indeed, this is a bad regular expression, it is too greedy and will match all the way to the last :END: line it can find. also, \\s is wrong, it should be just a space, so "[ \t]". Luckily this regular expression does not seem to be used in Org as far as I can see.... >=20 > = ,-------------------------------------------------------------------------= - > | 43::PROPERTIES: > | ::CUSTOM_ID: Setup > | ::END: > | 131::PROPERTIES: > | ::CUSTOM_ID: OrgFiles > | ::END: > | 185::PROPERTIES: > | ::CUSTOM_ID: AgendaSetup > | ::END: > | : > | :Here is my current =3Dorg-agenda-files=3D setup. > | :#+begin_src emacs-lisp :tangle no > | : (setq org-agenda-files (quote ("~/git/org" > | : "~/git/org/client1" > | : "~/git/org/bzflag" > | : "~/git/client2"))) > | :#+end_src > | : > | :#+begin_src emacs-lisp :tangle yes :exports none > | : ;; The following setting is different from the document so = that you > | : ;; can override the document org-agenda-files by setting = your > | : ;; org-agenda-files in the variable org-user-agenda-files > | : ;; > | : (if (boundp 'org-user-agenda-files) > | : (setq org-agenda-files org-user-agenda-files) > | : (setq org-agenda-files (quote ("~/git/org" > | : "~/git/org/client1" > | : "~/git/org/bzflag" > | : "~/git/client2")))) > | : =20 > | :#+end_src > = `-------------------------------------------------------------------------= - >=20 > I had to add two ? You only need the first - the second is OK. > after the * and delete the final \n=20 >=20 > ,------------------------------------------------------------- > | (:propertydrawer > | . (concat "\\(^[\\s\\t]*:PROPERTIES:[\\s\\t]*$\\)[^\\000]*?" > | "\\(^[\\s\\t]*:END:[\\s\\t]*?$\\)")) > `------------------------------------------------------------- Yes, you need the star to make it non-greedy. However, you can leave the \n after you have corrected the character class to "[ \t]" - it just means that the \n will be part of the match, but still allow for the possibility that the last line hits the end of the buffer. Ahhhh, regular expressions. I think in my entire history as a programmer, learning about regular expressions was the biggest braintrip I ever had - still love them. >=20 > to get the desired results: >=20 > ,--------------------------------- > | 43::PROPERTIES: > | ::CUSTOM_ID: Setup > | ::END: > | 131::PROPERTIES: > | ::CUSTOM_ID: OrgFiles > | ::END: > | 185::PROPERTIES: > | ::CUSTOM_ID: AgendaSetup > | ::END: > | 234::PROPERTIES: > | ::CUSTOM_ID: OrgFileStructure > | ::END: > `--------------------------------- >=20 > A bug in the regexp? >=20 > PS=20 > Can anybody explain this marvelous construct in the regexp: >=20 > ,--------- > | [^\\000] > `--------- 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. >=20 > I often pondered about how to achieve its effect with other means, = since > I did not find it in the Emacs Lisp manual. There you go - sometimes a brain is better than the Emacs manual :) Regards - Carsten >=20 > --=20 > cheers, > Thorsten >=20 >=20 --Apple-Mail=_1F66574B-7F5D-4A97-B425-5FA35FE294B4 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJSSxGkAAoJEO+gg/nAZuwM1IwH+QF6GMGeTMgxc5nGFyxJTb6z atrPU6jYuYURrTzz2khRiMawHV2xB4lpOWfoUoosXODzEsyJd9xTB+cDiqIC9eNX Je6gW5DdYiR5M06W6cqO+CIrf+t5ry4W58g6WnXnTIsa4sgeYqpN2vIu2A126qjG 5VyadkVG6CU/E9fU8G0ldEs8Df8Kw7/IqDwWuN/MhUJHBVbgUxUNmmjJfDmZx2E+ 1Sz870x6n1hdzE+zS91Cy1rjAbWozNgGDGcyp8slDRe5AeKUsx+5yPTt1p/lODHE rXy5XdiSn1WbFVZA1n9aCvqwTHr0u3w06xvUaNJWKysoe0qsaz0ESF33KVOm5/0= =gOxK -----END PGP SIGNATURE----- --Apple-Mail=_1F66574B-7F5D-4A97-B425-5FA35FE294B4--