emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Help with "macro"
@ 2019-10-12 16:18 Nathan Neff
  2019-10-12 19:04 ` Nathan Neff
  2019-10-12 20:16 ` Adam Porter
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Neff @ 2019-10-12 16:18 UTC (permalink / raw)
  To: emacs-orgmode

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

I'm trying to implement a function to display the TODO items of the
currently highlighted
item in the agenda and have a few questions:

Goal:

1) From the agenda, place the cursor on a heading.
2) Press a key and instantly narrow the agenda to the heading which the
cursor is on.
3) Display org-todo-list for the "narrowed" item in a new buffer, with the
name "agenda for <heading name>" or perhaps "agenda for <property "PROP" of
the narrowed item"
4) Keep the existing original agenda view (using sticky or some other
tactic).

Here's what I have so far:
(defun njn-show-tasks-for-project()
   (interactive)
   ;; (setq preval org-agenda-sticky)
   ;; (message "preval is: ")
   (call-interactively 'org-agenda-set-restriction-lock-from-agenda)
   ;; (org-toggle-sticky-agenda 't)
   (setq org-agenda-buffer-name "JarJarBarBar")
   (call-interactively 'org-todo-list)
   ;; (org-toggle-sticky-agenda preval)
)

This works, but my original agenda view is updated to be restricted.
 I've been tinkering with the "sticky" view for the agenda.  Also, I would
like to set the name of the new buffer to either the heading which my cursor
is on in the agenda, or perhaps a property of the heading which my cursor is
on in the agenda.

As you can see, I tried to set a "preval" variable to the current
stickiness of the agenda
and then reset the value after calling org-todo-list, but this has not
worked out for me so far.

Any ideas?

Thanks,
--Nate

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

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

* Re: Help with "macro"
  2019-10-12 16:18 Help with "macro" Nathan Neff
@ 2019-10-12 19:04 ` Nathan Neff
  2019-10-12 20:16 ` Adam Porter
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Neff @ 2019-10-12 19:04 UTC (permalink / raw)
  To: emacs-orgmode

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

I'm getting there - I found

(org-element-property :PROJ (org-element-at-point)) from a regular org-mode
file -
now I just need to jump there from the agenda.

On Sat, Oct 12, 2019 at 12:18 PM Nathan Neff <nathan.neff@gmail.com> wrote:

> I'm trying to implement a function to display the TODO items of the
> currently highlighted
> item in the agenda and have a few questions:
>
> Goal:
>
> 1) From the agenda, place the cursor on a heading.
> 2) Press a key and instantly narrow the agenda to the heading which the
> cursor is on.
> 3) Display org-todo-list for the "narrowed" item in a new buffer, with the
> name "agenda for <heading name>" or perhaps "agenda for <property "PROP" of
> the narrowed item"
> 4) Keep the existing original agenda view (using sticky or some other
> tactic).
>
> Here's what I have so far:
> (defun njn-show-tasks-for-project()
>    (interactive)
>    ;; (setq preval org-agenda-sticky)
>    ;; (message "preval is: ")
>    (call-interactively 'org-agenda-set-restriction-lock-from-agenda)
>    ;; (org-toggle-sticky-agenda 't)
>    (setq org-agenda-buffer-name "JarJarBarBar")
>    (call-interactively 'org-todo-list)
>    ;; (org-toggle-sticky-agenda preval)
> )
>
> This works, but my original agenda view is updated to be restricted.
>  I've been tinkering with the "sticky" view for the agenda.  Also, I would
> like to set the name of the new buffer to either the heading which my
> cursor
> is on in the agenda, or perhaps a property of the heading which my cursor
> is
> on in the agenda.
>
> As you can see, I tried to set a "preval" variable to the current
> stickiness of the agenda
> and then reset the value after calling org-todo-list, but this has not
> worked out for me so far.
>
> Any ideas?
>
> Thanks,
> --Nate
>

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

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

* Re: Help with "macro"
  2019-10-12 16:18 Help with "macro" Nathan Neff
  2019-10-12 19:04 ` Nathan Neff
@ 2019-10-12 20:16 ` Adam Porter
  1 sibling, 0 replies; 3+ messages in thread
From: Adam Porter @ 2019-10-12 20:16 UTC (permalink / raw)
  To: emacs-orgmode

Nathan Neff <nathan.neff@gmail.com> writes:

> I'm trying to implement a function to display the TODO items of the
> currently highlighted item in the agenda and have a few questions:
>
> Goal:
>
> 1) From the agenda, place the cursor on a heading.
>
> 2) Press a key and instantly narrow the agenda to the heading which
> the cursor is on.
>
> 3) Display org-todo-list for the "narrowed" item in a new buffer, with
> the name "agenda for <heading name>" or perhaps "agenda for <property
> "PROP" of the narrowed item"
>
> 4) Keep the existing original agenda view (using sticky or some other
> tactic).

Agenda restrictions are awkward to work with.  I recommend using org-ql
for this sort of thing, since it's designed to do things like this.
This seems to work:

(defun nn/agenda-item-todos ()
  (interactive)
  (org-with-point-at (org-get-at-bol 'org-marker)
    (save-restriction
      (org-narrow-to-subtree)
      (org-ql-search (current-buffer)
        '(todo)
        :narrow t))))

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

end of thread, other threads:[~2019-10-12 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-12 16:18 Help with "macro" Nathan Neff
2019-10-12 19:04 ` Nathan Neff
2019-10-12 20:16 ` Adam Porter

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