Hi, 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 improvements. (defun my/org-list-escape-nonitems () (interactive) (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)) (query-replace-regexp (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. Yours, Christian
Hello,
Christian Moe <mail@christianmoe.com> writes:
> 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:
Did you read my suggestion to avoid filling at such positions? While it
won't help on existing documents, I think it is a more general approach
to the problem.
Regards,
--
Nicolas
Here are 2 alternatives. The second, for me, is probably pretty bulletproof (pun intended after it was made :)). I like solution 2. Solution 1: Is it the case that you have text at the same column on the line before? Perhaps that could be considered invalid for lists. Of course there will still be problems with e.g. partial lists of references. And perhaps this will break people's habits. Not sure I like this solution, but thought to mention it. Solution 2: 1) I always start my lists at column 2, without exception. 2) I always have paragraphs at column 0, unless they are in a list or are manual insets (such as quotes). I am willing to put manual quotes some place other than column 2. All that's required is for the list code to (optionally): 1) start lists at column 2 2) never assume anything at column 0 is a list item Perhaps a combination of solutions would work. Samuel -- AIDS 2.0 is here now: http://thekafkapandemic.blogspot.com/2010/12/welcome-to-kafka-pandemic-two-forces_9182.html I support the Whittemore-Peterson Institute (WPI) === I want to see the original (pre-hold) Lo et al. 2010 NIH/FDA/Harvard MRV paper.
On 3/11/11 4:20 PM, Nicolas wrote:
> Hello,
>
> Christian Moe <mail@...> writes:
>
>> 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:
>
> Did you read my suggestion to avoid filling at such positions? While it
> won't help on existing documents, I think it is a more general approach
> to the problem.
I must have missed that, sorry. I remember you suggesting either to
use right-paren as item terminator, or manually insert a non-breaking
space after the dot.
Did you have a particular trick in mind, or just to avoid filling
manually? I tend to have auto-fill on by default.
The little utility function I posted makes the non-breaking-space
solution more workable for me. It wasn't intended as a contribution to
Org-mode, just as something some people might want to put in their
.emacs and try out, so I didn't put much thought into generalizing it.
Yours,
Christian
Christian Moe <mail@christianmoe.com> writes: > Did you have a particular trick in mind, or just to avoid filling > manually? I tend to have auto-fill on by default. I meant automatically. Please have a look at: http://article.gmane.org/gmane.emacs.orgmode/39149 Regards, -- Nicolas
On 3/11/11 7:22 PM, Nicolas wrote:
> Christian Moe<mail@christianmoe.com> writes:
>
>> Did you have a particular trick in mind, or just to avoid filling
>> manually? I tend to have auto-fill on by default.
>
> I meant automatically. Please have a look at:
>
> http://article.gmane.org/gmane.emacs.orgmode/39149
>
> Regards,
>
Magic! Thanks a lot for this, it's far and away a better solution.
Yours,
Christian