2

In org-mode..

I store lots of state-change messages and timing info in the LOGBOOK drawer.

Most of the time, I don't look into the LOGBOOK drawer, but once in a while when following up on a pending task, I peek into the LOGBOOK drawer to see my note.

I'm looking for a quick-way to expand the drawer using TAB on the head-line. Currently, 1st tab expands the entry, 2nd tab expands entry + subentry but not the LOGBOOK drawer.

Ideally, I'd like to:

  1. First tab expands the entry,
  2. Second tab expands sub-headings including LOGBOOK drawer (but not PROPERTIES or other drawers).

So I'm trying to tie in a function into the org-cycle-hook, but I have an issue:

(defun my/expand-logbook-drawer ()
 "Expand the closest logbook drawer"
 (interactive)
 (search-forward ":LOGBOOK:")
 (org-cycle)
)

(add-hook 'org-cycle-hook
  (lambda (my/var/curr-state)
    (interactive)
    (message "State changed")
    (when (= my/var/curr-state "all")   ;This comparison doesn't work, error: wrong argument, number-or-marker-p
      (my/expand-logbook-drawer)
    )
  )
)

It seems my comparison function doesn't work. Thoughts?

Note, the org-mode-cycle docu is here

4
  • = is for comparing numbers, you probably want string-equal or just equal.
    – wvxvw
    Commented Mar 2, 2015 at 19:49
  • I treid string-equal, but I get stringpq errors ...? Commented Mar 2, 2015 at 19:54
  • Then it means that my/var/curr-state isn't a string. A simple way to debug it is to put a (message "my/var/curr-state: %s" my/var/curr-state) before the offending line and after this hook fires, look into the *Messages* buffer.
    – wvxvw
    Commented Mar 2, 2015 at 20:39
  • I recommend taking a look at the function org-cycle-internal-local and insert your function at the appropriate section -- e.g., if you want your function to run when "CHILDREN" are exposed, then insert your function at that section of the code. You can create a new function to replace org-cycle-internal-local, by having it evaluated after org.el is required -- I believe the current version of Emacs loads the library on startup, so you can probably just drop your new org-cycle-internal-local into your .emacs file and away you go. I have not attempted to debug your proposed code.
    – lawlist
    Commented Mar 28, 2015 at 22:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.