emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Re: advice: how to export a list without exporting all entries


From: Nicolas
Subject: [O] Re: advice: how to export a list without exporting all entries
Date: Fri, 01 Apr 2011 18:26:27 +0200

Hello,

Eric S Fraga <address@hidden> writes:

> Nicolas <address@hidden> writes:

>> Eric S Fraga <address@hidden> writes:

>>> I would like to move to a system in which all the actions are numbered
>>> sequentially.  At present, they are numbered sequentially within a list
>>> for each meeting.  I would like to have a single list which grows over
>>> time. However, when I distribute the minutes of the latest meeting, I
>>> would like to only have those actions which are not yet complete listed
>>> in the document I circulate.  The complication is that I want those
>>> actions that have actually been done still in the list but not exported.

>>> Is there any way to /comment/ out individual list items (whether bullet
>>> or enumerated) on export?  I export typically to latex but this need not
>>> be a constraint.  Simply putting [ ] versus [X] boxes on the items is not
>>> satisfactory as the list would be very long if all items were included in
>>> the export.

>>> Is there some hook that I can intercept that would enable this?  Can I
>>> encapsulate individual list items into latex macros with the status of
>>> the [ ] or [X] boxes?  I am more than happy to write latex code as
>>> required!  Or even, at a push, elisp code...

>> I'm not sure to fully understand what you want, but couldn't you
>> delete-matching-lines toggled check-boxes in a copy of the original
>> buffer, and export that?
>>
>> Regards,
>
> Thanks for the suggestion.  I think you did understand me and, yes, that
> would work, but only *if* each list entry were a single line.
> Unfortunately, I tend to fill my list paragraphs so that each item in
> the list is often several lines and, in fact, often several paragraphs
> (especially when it concerns minutes of a meeting and resulting
> actions).  delete-matching-lines would delete the first line of a list
> entry only.
>
> I need to be able to "delete" whole list entries automatically based on
> their status, whether in a copy or during export.

Maybe the following functions might help you. Their docstring is explicit.

#+begin_src emacs-lisp
(defun esf-list-remove-if (predicate struct)
  "Remove all items satisfying PREDICATE in STRUCT and in buffer.
PREDICATE is a function called with item position as argument.
The modified STRUCT is returned."
  (let ((rev-struct (reverse struct))
        res e)
    (while rev-struct
      (setq e (pop rev-struct))
      (let ((item (car e)))
        (if (funcall predicate item)
            (delete-region item (nth 6 e))
          (push e res))))
    res))

(defun esf-clear-toggled-checkboxes ()
  "Remove toggled check-boxes from list at point.
Move point at the end of the list."
  (interactive)
  (if (not (org-at-item-p))
      (error "Not at a list item")
    (let* ((struct (org-list-struct))
           (end (copy-marker (org-list-get-bottom-point struct))))
      (esf-list-remove-if (lambda (e)
                            (equal "[X]" (org-list-get-checkbox e struct)))
                          struct)
      (goto-char end))))
#+end_src

Then, remove toggled checkboxes in an hook called just before list processing:

#+begin_src emacs-lisp
(add-hook 'org-export-preprocess-after-tree-selection-hook
          (lambda ()
            (goto-char (point-min))
            (while (org-list-search-forward (org-item-beginning-re) nil t)
              (esf-clear-toggled-checkboxes))))
#+end_src

Note that this solution doesn't handle nested lists (i.e. checkboxes in
lists inside a drawer itself in a list).

HTH,

Regards,

-- 
Nicolas



reply via email to

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