emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* PATCH: invoking RET on agenda clock log line ends up with point in closed clock drawer
@ 2016-04-28  5:29 Derek Feichtinger
  2016-04-30 23:34 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Derek Feichtinger @ 2016-04-28  5:29 UTC (permalink / raw)
  To: emacs-orgmode

Hello

A longer time ago, hitting RET on an agenda clock log line brought up the
respective org buffer with the cursor positioned on the clock line. At some
point this stopped to work cleanly, at least when using clock drawers. The
clock drawer would always be closed (even when it was opened in the org
buffer before jumping.) with the cursor being in the hidden drawer. So, it
became impossible to find the target clock line for e.g. modifying it.

I had fixed it for myself a longer time ago and forgot to submit my proposal
for a patch, until yesterday another user raised my attention to it.

My proposal for a patch is


;; when jumping to the agenda from a log message, the point ends up at
;; a CLOCK item in a LOGBOOK drawer, but the drawer gets closed, even
;; if the drawer was open before. I add a drawer opening function to
;; the respective agenda hook
(defun org-open-if-in-drawer ()
  (let ((element (org-element-at-point)))
    (while (and element
		(not (memq (org-element-type element)
			   '(drawer property-drawer))))
      (setq element (org-element-property :parent element)))
    (when element
      (let ((pos (point)))
	(goto-char (org-element-property :begin element))
	(org-flag-drawer nil)
	(goto-char pos)))))

(add-hook 'org-agenda-after-show-hook #'org-open-if-in-drawer)


Best regards,
Derek

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

* Re: PATCH: invoking RET on agenda clock log line ends up with point in closed clock drawer
  2016-04-28  5:29 PATCH: invoking RET on agenda clock log line ends up with point in closed clock drawer Derek Feichtinger
@ 2016-04-30 23:34 ` Nicolas Goaziou
  2016-05-01 10:49   ` Derek Feichtinger
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2016-04-30 23:34 UTC (permalink / raw)
  To: Derek Feichtinger; +Cc: emacs-orgmode

Hello,

Derek Feichtinger <dfeich@gmail.com> writes:

> A longer time ago, hitting RET on an agenda clock log line brought up the
> respective org buffer with the cursor positioned on the clock line. At some
> point this stopped to work cleanly, at least when using clock drawers. The
> clock drawer would always be closed (even when it was opened in the org
> buffer before jumping.) with the cursor being in the hidden drawer. So, it
> became impossible to find the target clock line for e.g. modifying it.

This is fixed. Thank you.

> ;; when jumping to the agenda from a log message, the point ends up at
> ;; a CLOCK item in a LOGBOOK drawer, but the drawer gets closed, even
> ;; if the drawer was open before. I add a drawer opening function to
> ;; the respective agenda hook
> (defun org-open-if-in-drawer ()
>   (let ((element (org-element-at-point)))
>     (while (and element
> 		(not (memq (org-element-type element)
> 			   '(drawer property-drawer))))
>       (setq element (org-element-property :parent element)))

See `org-element-lineage'.

>     (when element
>       (let ((pos (point)))
> 	(goto-char (org-element-property :begin element))
> 	(org-flag-drawer nil)
> 	(goto-char pos)))))
>
> (add-hook 'org-agenda-after-show-hook #'org-open-if-in-drawer)

Hooks are for user convenience, as you used it; I don't think any core feature should be
implemented through hooks.

Note that you can also call `org-flag-drawer' on a specific drawer using
optional argument.


Regards,

-- 
Nicolas Goaziou

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

* Re: PATCH: invoking RET on agenda clock log line ends up with point in closed clock drawer
  2016-04-30 23:34 ` Nicolas Goaziou
@ 2016-05-01 10:49   ` Derek Feichtinger
  0 siblings, 0 replies; 3+ messages in thread
From: Derek Feichtinger @ 2016-05-01 10:49 UTC (permalink / raw)
  To: Derek Feichtinger, emacs-orgmode

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

Hi Nicolas

Thanks for the fast fix and also for the pointers to interesting functions.

Regards,
Derek

On Sun, May 1, 2016 at 1:34 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Derek Feichtinger <dfeich@gmail.com> writes:
>
> > A longer time ago, hitting RET on an agenda clock log line brought up the
> > respective org buffer with the cursor positioned on the clock line. At
> some
> > point this stopped to work cleanly, at least when using clock drawers.
> The
> > clock drawer would always be closed (even when it was opened in the org
> > buffer before jumping.) with the cursor being in the hidden drawer. So,
> it
> > became impossible to find the target clock line for e.g. modifying it.
>
> This is fixed. Thank you.
>
> > ;; when jumping to the agenda from a log message, the point ends up at
> > ;; a CLOCK item in a LOGBOOK drawer, but the drawer gets closed, even
> > ;; if the drawer was open before. I add a drawer opening function to
> > ;; the respective agenda hook
> > (defun org-open-if-in-drawer ()
> >   (let ((element (org-element-at-point)))
> >     (while (and element
> >               (not (memq (org-element-type element)
> >                          '(drawer property-drawer))))
> >       (setq element (org-element-property :parent element)))
>
> See `org-element-lineage'.
>
> >     (when element
> >       (let ((pos (point)))
> >       (goto-char (org-element-property :begin element))
> >       (org-flag-drawer nil)
> >       (goto-char pos)))))
> >
> > (add-hook 'org-agenda-after-show-hook #'org-open-if-in-drawer)
>
> Hooks are for user convenience, as you used it; I don't think any core
> feature should be
> implemented through hooks.
>
> Note that you can also call `org-flag-drawer' on a specific drawer using
> optional argument.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>

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

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

end of thread, other threads:[~2016-05-01 10:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-28  5:29 PATCH: invoking RET on agenda clock log line ends up with point in closed clock drawer Derek Feichtinger
2016-04-30 23:34 ` Nicolas Goaziou
2016-05-01 10:49   ` Derek Feichtinger

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