From: John Kitchin <firstname.lastname@example.org>
To: Vikas Rawal <email@example.com>
Cc: Bastien <firstname.lastname@example.org>, org-mode mailing list <email@example.com>
Subject: Re: Limiting properties and property values
Date: Sun, 23 Feb 2020 08:37:34 -0500 [thread overview]
Message-ID: <CAJ51ETqTpM+Dx00sRiV5VP=ktAy9x4NZYLqGFU4fFPK++P+BWQ@mail.gmail.com> (raw)
[-- 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.
(defun validate-properties ()
(while (re-search-forward org-heading-regexp nil t)
(let ((v (org-entry-get (point) "NUMERIC")))
;; Let's say we only allow +/- integers
(if (string-match "\\`[-+]?[0-9]+\\'" v)
(error "Non-integer value found: %s" v)
(throw 'error 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.
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
On Sun, Feb 23, 2020 at 4:40 AM Vikas Rawal <firstname.lastname@example.org> wrote:
> On Sun, 23 Feb 2020 at 15:02, Bastien <email@example.com> wrote:
>> Hi Vikas,
>> Vikas Rawal <firstname.lastname@example.org> 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
> Warmest greetings and regards,
[-- Attachment #2: Type: text/html, Size: 3850 bytes --]
next prev parent reply other threads:[~2020-02-23 13:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-02-23 16:50 ` Fraga, Eric
2020-02-23 23:39 ` Vikas Rawal
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:
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).