emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] a general ID picker


From: Eric Abrahamsen
Subject: Re: [O] a general ID picker
Date: Tue, 20 Dec 2016 13:21:03 -0800
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/26.0.50 (gnu/linux)

Karl Voit <address@hidden> writes:

> * Eric Abrahamsen <address@hidden> wrote:
>> Karl Voit <address@hidden> writes:
>>
>>> 1 Improvement: ID Picker
>>> ========================
>>>
>>>   First of all, I'd like to see some kind of ID picker when defining
>>>   `:TRIGGER:' and `:BLOCKER:' dependencies.
>>>
>>>   This should work like this: after setting up the task in headings and
>>>   giving them IDs, I'd like to invoke a "I want to define a
>>>   dependency"-command. It first asks me what property I want to set:
>>>   `:TRIGGER:' or `:BLOCKER:'.
>>>
>>>   Then I get asked to select any ID which could be found within the same
>>>   sub-hierarchy (or even in all files?).
>>>
>>>   After being asked for the KEYWORD to be set for `:TRIGGER:'
>>>   dependencies (if applicable), the property is added to the current
>>>   heading accordingly.
>>>
>>>   This would drastically improve creating dependency definitions and
>>>   prevent typing errors in the first place.
>>
>> I like this a lot, for more uses than just org-depend, and it would be
>> very easy to implement. We've got `org-property-set-functions-alist' for
>> using special functions to read the values of special properties, and
>> we've got `org-id-get-with-outline-(drilling|path-completion), so it's
>> pretty much already done!
>>
>> (defun my-trigger-property-prompt ()
>>   (when (derived-mode-p 'org-mode)
>>     (let ((id (org-id-get-with-outline-drilling))
>>        (kw (org-completing-read "Keyword: " org-todo-keywords-1)))
>>       (do-something-with-id-and-kw))))
>>
>> (push '("TRIGGER" . my-trigger-property-prompt)
>>       org-property-set-functions-alist)
>>
>> I don't actually know how the TRIGGER property is meant to be formatted
>> (and I didn't really test the above), but something very near to the
>> above should do what you want.
>
> Well, I am afraid that I am totally lost when it comes to "pretty
> much already done". The great Professor Kitchin helped me with a
> sophisticated function and sent me the "almost finished" code and I
> failed at making it run :-(
>
> However, I do tend to think that the ID picker would be of general
> interest and I'd like to see it in the global Org-mode featureset
> for multiple purposes, not only defining org-depend dependencies.

Ha, sorry, I'll actually look at org-depend...

...okay, so it looks like the :TRIGGER: property can contain several
different types of values. But from your message you seem to be talking
about this kind:

some-other-headings-id-df83454(NEXT)

So the code you'd want would be (I actually tested it this time):

(defun my-trigger-property-prompt (&rest args)
  (when (derived-mode-p 'org-mode)
    (let ((id (org-id-get-with-outline-path-completion))
          (kw (org-completing-read "Keyword: " org-todo-keywords-1 nil nil)))
      (format "%s(%s)" id kw))))

(push '("TRIGGER" . my-trigger-property-prompt)
      org-property-set-functions-alist)

I switched from `org-id-get-with-outline-drilling', as that raised an
error about `org-goto-map' being an undefined variable (lexical scoping
issue?). Also, this only does the one kind of TRIGGER format. Also it is
limited to completing on the TODO keywords defined in the current file,
but will accept others.

In short, it's got lots of limitations, but please do eval the above and
see if it works, then we can go from there.

Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]