emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Workaround] Escaping false list items
@ 2011-03-11 14:12 Christian Moe
  2011-03-11 15:20 ` Nicolas
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Moe @ 2011-03-11 14:12 UTC (permalink / raw)
  To: Org Mode


Back to the problem with e.g. "2011. " being interpreted as a list 
item when it happens to be at the beginning of a line:

After a bad experience with a document that had a lot of those, I came 
up with this function to easily escape false list items. Maybe some of 
you will find it helpful, or better yet, have suggestions for 

(defun my/org-list-escape-nonitems ()
   (let ((nonitem "[0-9]\\{4\\}") ; Unlikely list numbers
				 ; here: four-digit numbers (years)
	(term (cond
                ((eq org-plain-list-ordered-item-terminator t) "[.)]")
                ((= org-plain-list-ordered-item-terminator ?\)) ")")
                ((= org-plain-list-ordered-item-terminator ?.) "\\.")
                (t "[.)]"))))
     (goto-char (point-min))
      (concat "^\\(" nonitem "\\)\\(" term "\\) ")
      (concat "\\1\\2" (string ?\240)))))

It calls query-replace-regexp, so the user can confirm each 
replacement interactively, on apparent list items where the numbering 
matches the NONITEM regexp. If confirmed, it replaces the space after 
the item terminator with a non-breaking space.

In the code above, NONITEM is simply hard-coded as four digits, 
matching years. It could be made a customizable variable.

The adventurous might want to call it automatically before export, 
though currently this does not work well with subtree exports:

   (add-hook 'org-export-first-hook 'my/org-list-escape-nonitems)

Feedback welcome.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-03-11 21:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 14:12 [Workaround] Escaping false list items Christian Moe
2011-03-11 15:20 ` Nicolas
2011-03-11 18:02   ` Samuel Wales
2011-03-11 18:15   ` Christian Moe
2011-03-11 18:22     ` Nicolas
2011-03-11 21:18       ` Christian Moe

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