emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Limiting properties and property values
@ 2020-02-22 15:26 Vikas Rawal
  2020-02-23  9:32 ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Vikas Rawal @ 2020-02-22 15:26 UTC (permalink / raw)
  To: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

Dear all,

I have two queries regarding use of properties in org mode.

1. Is it possible to restrict the sub-tree of a headline to have only
properties specified in the column property of the parent? That is, no
additional property can be specified.

2. Is it possible to limit the allowed values of a property to say only
numeric values or to a specific range of numeric values?

Thanks in advance, and with best wishes to everyone.

Vikas

[-- Attachment #2: Type: text/html, Size: 670 bytes --]

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

* Re: Limiting properties and property values
  2020-02-22 15:26 Limiting properties and property values Vikas Rawal
@ 2020-02-23  9:32 ` Bastien
  2020-02-23  9:40   ` Vikas Rawal
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2020-02-23  9:32 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: org-mode mailing list

Hi Vikas,

Vikas Rawal <vikasrawal@gmail.com> writes:

> 1. Is it possible to restrict the sub-tree of a headline to have only
> properties specified in the column property of the parent? That is,
> no additional property can be specified.

No, it is currently not possible.  What would be the use-case?

> 2. Is it possible to limit the allowed values of a property to say
> only numeric values or to a specific range of numeric values?

Nope, it is not possible.

Allowed values for a property are only used in the UI for switching
and/or completing values, the notion of allowed values is not used to
"check" value types.

HTH,

-- 
 Bastien

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

* Re: Limiting properties and property values
  2020-02-23  9:32 ` Bastien
@ 2020-02-23  9:40   ` Vikas Rawal
  2020-02-23 13:37     ` John Kitchin
  2020-02-23 16:50     ` Fraga, Eric
  0 siblings, 2 replies; 6+ messages in thread
From: Vikas Rawal @ 2020-02-23  9:40 UTC (permalink / raw)
  To: Bastien; +Cc: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 876 bytes --]

On Sun, 23 Feb 2020 at 15:02, Bastien <bzg@gnu.org> wrote:

> Hi Vikas,
>
> Vikas Rawal <vikasrawal@gmail.com> writes:
>
> > 1. Is it possible to restrict the sub-tree of a headline to have only
> > properties specified in the column property of the parent? That is,
> > no additional property can be specified.
>
> No, it is currently not possible.  What would be the use-case?
>


I am thinking of using org-mode to compile a small database. I would like
to use properties to add data, and some restrictions of this kind to limit
what properties a particular kind of headline could have.

It might seem like an over-kill, but then for org-mode, almost nothing is
an over-kill.

I am missing a few nuts and bolts, but would really like to see how it
works to use org-mode for a small org-mode-skilled team to use it as a data
platform.

Warmest greetings and regards,

Vikas

[-- Attachment #2: Type: text/html, Size: 1514 bytes --]

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

* Re: Limiting properties and property values
  2020-02-23  9:40   ` Vikas Rawal
@ 2020-02-23 13:37     ` John Kitchin
  2020-02-23 16:50     ` Fraga, Eric
  1 sibling, 0 replies; 6+ messages in thread
From: John Kitchin @ 2020-02-23 13:37 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: Bastien, org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 2360 bytes --]

One solution to this is a function you would write that validates the
properties, and prevents saving if they are invalid. You would want to use
it in a buffer/directory hook.

For example:

(defun validate-properties ()
  (goto-char (point-min))
  (catch 'error
    (while (re-search-forward org-heading-regexp nil t)
      (let ((v (org-entry-get (point) "NUMERIC")))
(when v
 ;; Let's say we only allow +/- integers
 (if (string-match "\\`[-+]?[0-9]+\\'" v)
     nil
   (error "Non-integer value found: %s" v)
   (throw 'error nil)
   nil))))))

(add-hook 'write-file-functions 'validate-properties t)

You could use a different function for floats, or to make sure a value was
one of a few allowed options...

This only works if you only edit the files through emacs, and if everyone
is setup so this is automatically loaded in the directory, etc. An
alternative place to put something like this is in a git hook, if you have
your project in a git repo. you would have to figure out how to write a
script that would run emacs to do this kind of thing. But, then you could
make sure no invalid files were commited, for example.



John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Sun, Feb 23, 2020 at 4:40 AM Vikas Rawal <vikasrawal@gmail.com> wrote:

>
>
> On Sun, 23 Feb 2020 at 15:02, Bastien <bzg@gnu.org> wrote:
>
>> Hi Vikas,
>>
>> Vikas Rawal <vikasrawal@gmail.com> writes:
>>
>> > 1. Is it possible to restrict the sub-tree of a headline to have only
>> > properties specified in the column property of the parent? That is,
>> > no additional property can be specified.
>>
>> No, it is currently not possible.  What would be the use-case?
>>
>
>
> I am thinking of using org-mode to compile a small database. I would like
> to use properties to add data, and some restrictions of this kind to limit
> what properties a particular kind of headline could have.
>
> It might seem like an over-kill, but then for org-mode, almost nothing is
> an over-kill.
>
> I am missing a few nuts and bolts, but would really like to see how it
> works to use org-mode for a small org-mode-skilled team to use it as a data
> platform.
>
> Warmest greetings and regards,
>
> Vikas
>

[-- Attachment #2: Type: text/html, Size: 3850 bytes --]

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

* Re: Limiting properties and property values
  2020-02-23  9:40   ` Vikas Rawal
  2020-02-23 13:37     ` John Kitchin
@ 2020-02-23 16:50     ` Fraga, Eric
  2020-02-23 23:39       ` Vikas Rawal
  1 sibling, 1 reply; 6+ messages in thread
From: Fraga, Eric @ 2020-02-23 16:50 UTC (permalink / raw)
  To: Vikas Rawal; +Cc: org-mode mailing list

On Sunday, 23 Feb 2020 at 15:10, Vikas Rawal wrote:
> I am thinking of using org-mode to compile a small database. 

Although org is fantastic, it is sometimes worth considering other tools
(and with babel, these can often be brought into the org sphere of
activity easily).  For instance, GNU recutils [1] might suit you
better.  There's even an emacs mode [2].

Just my 2¢.


Footnotes:
[1]  https://www.gnu.org/software/recutils/

[2]  https://www.gnu.org/software/recutils/rec-mode-manual/rec-mode.html

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-354-g9d5880

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

* Re: Limiting properties and property values
  2020-02-23 16:50     ` Fraga, Eric
@ 2020-02-23 23:39       ` Vikas Rawal
  0 siblings, 0 replies; 6+ messages in thread
From: Vikas Rawal @ 2020-02-23 23:39 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]

Dear Eric, Bastien and John,

Thanks for references to recutils and org-ql. These are very interesting,
and I am looking at those.

A recutils database with a possibility of selecting, inserting and updating
records from org is one possibility.

Let me play around with these tools a bit and see what they are like.

Thanks again,

Vikas


On Sun, 23 Feb 2020 at 22:20, Fraga, Eric <e.fraga@ucl.ac.uk> wrote:

> On Sunday, 23 Feb 2020 at 15:10, Vikas Rawal wrote:
> > I am thinking of using org-mode to compile a small database.
>
> Although org is fantastic, it is sometimes worth considering other tools
> (and with babel, these can often be brought into the org sphere of
> activity easily).  For instance, GNU recutils [1] might suit you
> better.  There's even an emacs mode [2].
>
> Just my 2¢.
>
>
> Footnotes:
> [1]  https://www.gnu.org/software/recutils/
>
> [2]  https://www.gnu.org/software/recutils/rec-mode-manual/rec-mode.html
>
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-354-g9d5880
>

[-- Attachment #2: Type: text/html, Size: 1720 bytes --]

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

end of thread, other threads:[~2020-02-23 23:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-22 15:26 Limiting properties and property values Vikas Rawal
2020-02-23  9:32 ` Bastien
2020-02-23  9:40   ` Vikas Rawal
2020-02-23 13:37     ` John Kitchin
2020-02-23 16:50     ` Fraga, Eric
2020-02-23 23:39       ` Vikas Rawal

Code repositories for project(s) associated with this 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).