emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem with property matching
@ 2013-11-26 12:27 Carsten Dominik
  2013-11-26 17:00 ` Nicolas Goaziou
  2013-11-26 21:12 ` Achim Gratz
  0 siblings, 2 replies; 3+ messages in thread
From: Carsten Dominik @ 2013-11-26 12:27 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org List

Hi,

I think there is an error in the property matching regexp.  It will not match a line where the property value is empty.  I propose the following change, which makes the value part optional:

--------------------------------------------------------------------------------
diff --git a/lisp/org.el b/lisp/org.el
index 7a4d244..4641ce5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6205,7 +6205,7 @@ Use `org-reduced-level' to remove the effect of `org-odd-levels'."
 Match group 3 will be set to the value if it exists."
   (concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
 	  (if literal property (regexp-quote property))
-	  "\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"))
+	  "\\):\\)\\([ \t]+\\(?3:[^ \t\r\n].*?\\)\\)?\\(?5:[ \t]*\\)$"))
 
 (defconst org-property-re
   (org-re-property ".*?" 'literal)
--------------------------------------------------------------------------------

Can anyone think of problems this would cause?  Nicolas, does the syntax definition require a non-empty value?

- Carsten

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

* Re: Problem with property matching
  2013-11-26 12:27 Problem with property matching Carsten Dominik
@ 2013-11-26 17:00 ` Nicolas Goaziou
  2013-11-26 21:12 ` Achim Gratz
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Goaziou @ 2013-11-26 17:00 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode@gnu.org List

Hello,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> I think there is an error in the property matching regexp.  It will not match a line where the property value is empty.  I propose the following change, which makes the value part optional:
>
> --------------------------------------------------------------------------------
> diff --git a/lisp/org.el b/lisp/org.el
> index 7a4d244..4641ce5 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -6205,7 +6205,7 @@ Use `org-reduced-level' to remove the effect of `org-odd-levels'."
>  Match group 3 will be set to the value if it exists."
>    (concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
>  	  (if literal property (regexp-quote property))
> -	  "\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"))
> +	  "\\):\\)\\([ \t]+\\(?3:[^ \t\r\n].*?\\)\\)?\\(?5:[ \t]*\\)$"))

Why \\(?3:[^ \t\r\n].*?\\) instead of \\(?3:.*?\\) ?

>  (defconst org-property-re
>    (org-re-property ".*?" 'literal)
> --------------------------------------------------------------------------------
>
> Can anyone think of problems this would cause? Nicolas, does the
> syntax definition require a non-empty value?

Not really. It just means that we cannot have a property named "END".


Regards,

-- 
Nicolas Goaziou

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

* Re: Problem with property matching
  2013-11-26 12:27 Problem with property matching Carsten Dominik
  2013-11-26 17:00 ` Nicolas Goaziou
@ 2013-11-26 21:12 ` Achim Gratz
  1 sibling, 0 replies; 3+ messages in thread
From: Achim Gratz @ 2013-11-26 21:12 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik writes:
> I think there is an error in the property matching regexp.  It will
> not match a line where the property value is empty.

See 3c933adaf6 and 68276fd62d for how this regex developed, the
requirement of the whitespace after the colon was in the original regex
from Nicolas.  I think that makes sense given the description of
properties as key-value pairs.  In other places we use "()" for an empty
value aka nil.

>  I propose the following change, which makes the value part optional:

> --------------------------------------------------------------------------------
> diff --git a/lisp/org.el b/lisp/org.el
> index 7a4d244..4641ce5 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -6205,7 +6205,7 @@ Use `org-reduced-level' to remove the effect of `org-odd-levels'."
>  Match group 3 will be set to the value if it exists."
>    (concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
>  	  (if literal property (regexp-quote property))
> -	  "\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"))
> +	  "\\):\\)\\([ \t]+\\(?3:[^ \t\r\n].*?\\)\\)?\\(?5:[ \t]*\\)$"))

The extra group introduced should be shy.

> Why \\(?3:[^ \t\r\n].*?\\) instead of \\(?3:.*?\\) ?

In fact, this would be preferred (you need whitespace after the colon
for an empty key):

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org.el b/lisp/org.el
index c9055a6..d2aff2f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6203,7 +6203,7 @@ (defsubst org-re-property (property &optional literal)
 Match group 3 will be set to the value if it exists."
   (concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
 	  (if literal property (regexp-quote property))
-	  "\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"))
+	  "\\):\\)[ \t]+\\(?3:.*?\\)\\(?5:[ \t]*\\)$"))
 
 (defconst org-property-re
   (org-re-property ".*?" 'literal)
--8<---------------cut here---------------end--------------->8---

since it still passes the test suite (which may be accidental since I
don't think there's any whitespace after :PROPERTIES: or :END: and we
may actually need to enforce this).  If you don't want to require
whitespace after the colon for an empty key you'd do this:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org.el b/lisp/org.el
index c9055a6..d2aff2f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6203,7 +6203,7 @@ (defsubst org-re-property (property &optional literal)
 Match group 3 will be set to the value if it exists."
   (concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
 	  (if literal property (regexp-quote property))
-	  "\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"))
+	  "\\):\\)[ \t]*\\(?3:.*?\\)\\(?5:[ \t]*\\)$"))
 
 (defconst org-property-re
   (org-re-property ".*?" 'literal)
--8<---------------cut here---------------end--------------->8---

but this fails Babel header arg tests.  I don't think there's anything
that specifically tests for empty values since it wasn't specified or
possible so far, but this somehow messes up property inheritance.  You'd
need to explicitly disallow :PROPERTIES: and :END: as a key, since this
will now be matched by the regex.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf Blofeld V1.15B11:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

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

end of thread, other threads:[~2013-11-26 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-26 12:27 Problem with property matching Carsten Dominik
2013-11-26 17:00 ` Nicolas Goaziou
2013-11-26 21:12 ` Achim Gratz

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