[O] [PATCH] Make the latex export preprocessor rewrite #+INDEX to \index.

2011-04-28 Thread rpgoldman
From: Robert P. Goldman rpgold...@real-time.com

---
 lisp/org-latex.el |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index e7307ef..731d6e6 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1775,6 +1775,8 @@ The conversion is made depending of STRING-BEFORE and 
STRING-AFTER.
(end-of-line 1)
(insert \n)
 
+
+
 (defun org-export-latex-fixed-width (opt)
   When OPT is non-nil convert fixed-width sections to LaTeX.
   (goto-char (point-min))
@@ -2322,6 +2324,17 @@ The conversion is made depending of STRING-BEFORE and 
STRING-AFTER.
 (and (looking-at [ \t]*ORG-VERSE-END.*)
 (org-replace-match-keep-properties \\end{verse} t t)))
 
+  ;; Convert #+INDEX to LaTeX \\index.
+  (goto-char (point-min))
+  (while
+  (and
+   (let ((case-fold-search t))
+(re-search-forward ^[ \t]*#\\+index:[ \t]*\\(.*?\\)[ \t]*$ nil t))
+   ( (match-end 1) (match-beginning 1)))
+(let ((entry (match-string 1)))
+;;  (message Found a #+INDEX match...)
+  (replace-match (format \\index{%s} entry) t t)))
+
   ;; Convert center
   (goto-char (point-min))
   (while (search-forward ORG-CENTER-START nil t)
-- 
1.7.3.5




Re: [O] [PATCH] Make the latex export preprocessor rewrite #+INDEX to \index.

2011-04-28 Thread Robert Goldman
On 4/28/11 Apr 28 -7:33 AM, Nick Dokos wrote:
 rpgold...@sift.info wrote:
 
 From: Robert P. Goldman rpgold...@real-time.com

 ---
  lisp/org-latex.el |   13 +
  1 files changed, 13 insertions(+), 0 deletions(-)
  ...
 
 Very nice! Did a small test and it works as advertised.
 
 Suggestion: maybe add an I easy template for it? This can be done
 per-user of course, so it is not strictly necessary and easy templates
 are experimental anyway, but it might be a good idea to reserve the I
 for this.  Actually, it might be better to reserve i for this and
 shift the include to I, since there will only be a few includes but
 potentially hundreds of index entries in a file.

I'm not sure that this is feasible.  I tried doing this and as far as I
can tell the template matching is not case-sensitive.  I could wrap the
string-match there in a

(let ((case-fold-search nil))
  ...)

but I'd like some advice from a core maintainer before doing this (I'll
check in on IRC, too).

I've got a patch ready if that's the right way to go.

cheers,
r




Re: [O] [PATCH] Make the latex export preprocessor rewrite #+INDEX to \index.

2011-04-28 Thread Robert Goldman
My mistake -- I made the template wrong; it wasn't a case-fold issue,
after all.

I have a patch that will do this now.  Will post it soon.

Cheers,
r