Emacs bits for DocBook figures



Written to a spec conceived on the #docs irc channel, this handy chunk
of elisp will prompt you for a title and a filename, then insert (what
I am told is) the currently recommended markup for inserting a figure
in a GDP document.  It leaves the cursor in the middle of the
<screeninfo> element so that you can type in whatever one usually
types in that element.

It requires psgml to be installed; if you don't have, the indentation
will not work.  Possibly nor will the entire function: you can
probably get by if you delete the line "(indent-region point (point) nil)"

If you already know a fair amount of emacs, you know what to do with
this.  If not, just add it to your .emacs file and restart emacs.

---cut here---

(defun gdp-insert-figure (title filename)
  (interactive "MTitle: \nFFilename: ")
  (let ((point (point))
        (nodename (subseq (file-name-sans-extension filename)
                          (length default-directory)))
        (format (or (file-name-extension filename) "png")))
    (insert 
"<figure>
<title>" title "</title>
<screenshot>
<screeninfo></screeninfo>
<graphic  format=\"" format "\" fileref=\"" nodename "\" srccredit=\"me\">
</graphic>
</screenshot>
</figure>")
    (indent-region point (point) nil)
    (search-backward "</screeninfo>" point t)))

;;; bind to F7 key by default, because it happens to be spare
;;; on my machine.

(define-key global-map [f7] 'gdp-insert-figure)

---cut here---

I'm not on this list, so CC replies to me if you want me to see them.


-dan






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]