emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Derek Thomas <derekcthomas@gmail.com>
Cc: emacs-orgmode@gnu.org, nicholas.dokos@hp.com,
	Nicolas Goaziou <n.goaziou@gmail.com>
Subject: Re: Convert list to paragraph
Date: Sat, 27 Aug 2011 12:32:25 -0400	[thread overview]
Message-ID: <14270.1314462745@alphaville.dokosmarshall.org> (raw)
In-Reply-To: Message from Derek Thomas <derekcthomas@gmail.com> of "Sat\, 27 Aug 2011 09\:16\:35 CDT." <CALDRGc_LRi7_+oiRPTWbXjNC9CpFU+K0_okL7GMXAfZoY8XfNA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

Derek Thomas <derekcthomas@gmail.com> wrote:

> > Nick Dokos <nicholas.dokos@hp.com> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: lists to paragraphs --]
[-- Type: text/x-lisp, Size: 1094 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 256 bytes --]


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?

      reply	other threads:[~2011-08-27 16:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 20:01 Convert list to paragraph Derek Thomas
2011-08-26 21:27 ` Nick Dokos
2011-08-27  0:59   ` Nicolas Goaziou
2011-08-27 14:16     ` Derek Thomas
2011-08-27 16:32       ` Nick Dokos [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=14270.1314462745@alphaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=derekcthomas@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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