From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Subject: Re: advice: how to export a list without exporting all entries Date: Fri, 01 Apr 2011 18:26:27 +0200 Message-ID: <87hbaiym30.fsf@gmail.com> References: <87ipvcvnoo.fsf@ucl.ac.uk> <8739mdn3tm.fsf@gmail.com> <87y644aodc.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=36001 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5hBb-0005eX-Ba for emacs-orgmode@gnu.org; Fri, 01 Apr 2011 12:27:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5hBC-0001PS-Qb for emacs-orgmode@gnu.org; Fri, 01 Apr 2011 12:26:36 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:47036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5hBC-0001P5-MD for emacs-orgmode@gnu.org; Fri, 01 Apr 2011 12:26:34 -0400 Received: by wwb39 with SMTP id 39so3698243wwb.30 for ; Fri, 01 Apr 2011 09:26:33 -0700 (PDT) In-Reply-To: <87y644aodc.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Thu, 24 Mar 2011 08:55:59 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Emacs Org mode mailing list Hello, Eric S Fraga writes: > Nicolas writes: >> Eric S Fraga 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