Reading a very good emacs blog
I found the guy has a book, $5 US
http://ergoemacs.org/emacs/buy_xah_emacs_tutorial.html

The blog is good, I'm finding the tutorial really handy

Quick lesson in macros. Docbook indexing.

Highlight the term, M-x pi
with or without s (for secondary term)

Enjoy.


(defun pi (class start end)
  "Markup for docbook index, optional secondary term"
  (interactive "sEnter s for secondary : \nr")
  (let* (
         (idxterm  (buffer-substring start end))  ; the indexed term
         (termlen (length idxterm))              ; len of above
         (pms (concat "<indexterm><primary>" idxterm "</primary>"))
         (sms "<secondary>")
         (sme "</secondary>")
         (pme "</indexterm>")
         (pml (length pms)) ;; primary length
         (sml (length sms))  ;; secondary length
         ) ;; end of local vars
  (goto-char (- end termlen ))(insert pme )
    (goto-char start)(insert pms)
    (when (equal "s" class) ;; if secondary wanted
           (insert (concat sms sme )))
    (setq newpoint
          (if (equal "s" class)
              (+ (length pms) (length sms)) ;; insert point for secondary
            (+ (length pms) (length pme))
            ))
    (goto-char (+ (region-beginning) newpoint))
))

regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to