emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas <n.goaziou@gmail.com>
To: Emacs Org mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: advice: how to export a list without exporting all entries
Date: Fri, 01 Apr 2011 18:26:27 +0200	[thread overview]
Message-ID: <87hbaiym30.fsf@gmail.com> (raw)
In-Reply-To: <87y644aodc.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Thu, 24 Mar 2011 08:55:59 +0000")


Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Nicolas <n.goaziou@gmail.com> writes:

>> Eric S Fraga <e.fraga@ucl.ac.uk> 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))))

(defun esf-clear-toggled-checkboxes ()
  "Remove toggled check-boxes from list at point.
Move point at the end of the list."
  (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)))
      (goto-char end))))

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)

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




  reply	other threads:[~2011-04-01 16:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-21  9:16 advice: how to export a list without exporting all entries Eric S Fraga
2011-03-23 17:29 ` Nicolas
2011-03-24  8:55   ` Eric S Fraga
2011-04-01 16:26     ` Nicolas [this message]
2011-04-01 16:52       ` Eric S Fraga
2011-04-01 20:20         ` Nicolas
2011-03-24 15:19 ` Carsten Dominik
2011-03-24 19:12   ` Eric S Fraga
2011-03-24 20:45   ` Eric S Fraga
2011-03-24 21:00     ` Carsten Dominik
2011-03-28 18:46     ` Carsten Dominik
2011-03-29  6:39       ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hbaiym30.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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