From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Convert list to paragraph Date: Sat, 27 Aug 2011 12:32:25 -0400 Message-ID: <14270.1314462745@alphaville.dokosmarshall.org> References: <5350.1314394027@alphaville.americas.hpqcorp.net> <87ippjmzy0.fsf@gmail.com> Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:49479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxLo6-0007jM-De for emacs-orgmode@gnu.org; Sat, 27 Aug 2011 12:32:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QxLo5-0007Qv-8K for emacs-orgmode@gnu.org; Sat, 27 Aug 2011 12:32:30 -0400 Received: from g1t0029.austin.hp.com ([15.216.28.36]:40591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxLo4-0007Ql-V8 for emacs-orgmode@gnu.org; Sat, 27 Aug 2011 12:32:29 -0400 In-Reply-To: Message from Derek Thomas of "Sat\, 27 Aug 2011 09\:16\:35 CDT." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Derek Thomas Cc: emacs-orgmode@gnu.org, nicholas.dokos@hp.com, Nicolas Goaziou --=-=-= Content-Type: text/plain Derek Thomas wrote: > > Nick Dokos writes: > > > >> (defun org-list-to-paragraph () > >> "Convert the list at point into a paragraph." > >> (interactive) > >> (insert (org-list-to-generic (org-list-parse-list t) > >> '(:ustart "" > >> :splice t > >> :isep " " > >> :nobr t )))) > >> > >> > >> (defun org-lists-to-paragraphs () > >> (goto-char (point-min)) > >> (condition-case nil > >> (while (org-list-search-forward "+ ") > >> (org-list-to-paragraph)) > >> (error nil))) > >> > >> (add-hook 'org-export-preprocess-hook > >> (function org-lists-to-paragraphs)) > > > This looks like it will do what I want. Is there any way to restrict > this export option to certain org files? Thanks, > With elisp you can do anything: just a small matter of programming (TM). E.g. you can set up a list with the files that you want this to apply to and then check in org-lists-to-paragraphs whether the file you are exporting is in the list: if not, don't do anything. Here's a quick and rather dirty implementation - a minor variation on the above: --=-=-= Content-Type: text/x-lisp Content-Disposition: inline; filename=ltop.el Content-Description: lists to paragraphs (setq ndk-list-to-paragraph-file-list '("/home/nick/src/org/list/to-paragraph/derek-thomas.org")) (defun org-list-to-paragraph () "Convert the list at point into a paragraph." (interactive) (insert (org-list-to-generic (org-list-parse-list t) '(:ustart "" :splice t :isep " " :nobr t )))) (defun ndk-buffer-file-name () ;;; if called from inside org-export-preprocess-string ;;; source-buffer will be bound to the original org buffer, not the temp buffer ;;; otherwise assume we want to operate on the current buffer ;;; don't bother telling me how ugly this is - I know ;;; but do bother telling me about a better way to do it. (if (boundp 'source-buffer) (buffer-file-name source-buffer) (buffer-file-name (current-buffer)))) (defun org-lists-to-paragraphs () (if (not (member (ndk-buffer-file-name) ndk-list-to-paragraph-file-list)) nil (goto-char (point-min)) (condition-case nil (while (org-list-search-forward "+ ") (org-list-to-paragraph)) (error nil)))) (add-hook 'org-export-preprocess-hook (function org-lists-to-paragraphs)) --=-=-= Content-Type: text/plain but depending on your needs, you might want to do it differently. It is just a matter of figuring out what criteria you want to apply and then figuring out how to implement those criteria. Nick PS Is there a better way to get the original buffer name? --=-=-=--