Re: Proposal: Image Tag Conventions



Thanks Eric!  While we're making life slightly more complex with this
proposal, I wanted to post something which should make life quite a bit
easier, at least for those of us using Emacs/PSGML.
Dan Barlow wrote a nifty piece of code a while back, which made
inserting a figure a single keypress.  Very slick.  Now that we're using
DocBook 4, and the Nifty New Markup, I did some hacking on it.  It
supports all three proposed markups, and takes just a single keypress to
insert all the markup.

How to use it.  Grab the attachment from this message, or get it from
http://www.ibiblio.org/gleblanc/gdp-pictures.txt, and save it in your
home directory.  Add the following line to your .emacs

(load "/home/USERNAME/gdp-pictures.el")

You can actually put it anywhere you like, so long as you make sure that
the path is correct.  Currently, F7 inserts a <figure>, F8 inserts a
<screenshot>, and F9 inserts a <mediaobject>.  Enjoy!
	Greg

; the markup for pictures automatically.

; this first one inserts a <figure> markup block.  It should be used
; for larger graphics elements.

(defun gdp-insert-figure (title filename)
  (interactive "MTitle: \nMFilename (no extension): ")
  (let ((point (point)))
    (insert 
" 	<figure>
	  <title></title>
	  <mediaobject>
	    <imageobject>
	      <imagedata fileref=\"\" format=\"PNG\"/>
	    </imageobject>
	    <imageobject>
	      <imagedata fileref=\"\" format=\"EPS\"/>
	    </imageobject>
	    <textobject>
	      <phrase></phrase>
	    </textobject>
	  </mediaobject>
	</figure>")
    (indent-region point (point) nil)
    (search-backward "</phrase>" point t)))
(define-key global-map [f7] 'gdp-insert-figure)

; this one inserts a <screenshot>.  Clearly, use this one for
; screenshots.  :-)

(defun gdp-insert-screenshot (title filename)
  (interactive "MTitle: \nMFilename (no extension): ")
  (let ((point (point)))
    (insert 
"   <screenshot>
    <mediaobject>
     <imageobject>
      <imagedata fileref=\"\" format=\"PNG\"/>
     </imageobject>
     <imageobject>
      <imagedata fileref=\"\" format=\"EPS\"/>
     </imageobject>
     <textobject>
      <phrase></phrase>
     </textobject>
     <caption>
      <para></para>
     </caption>
    </mediaobject>
   </screenshot>")
    (indent-region point (point) nil)
    (search-backward "</phrase>" point t)))
(define-key global-map [f8] 'gdp-insert-screenshot)


; This one inserts a media object.  Use this for small graphics, less
; than a figure and not a screenshot.

(defun gdp-insert-mediaobject (title filename)
  (interactive "MTitle: \nMFilename (no extension): ")
  (let ((point (point)))
    (insert 
"  <mediaobject>
   <imageobject>
    <imagedata fileref="" format="PNG"/>
   </imageobject>
   <imageobject>
    <imagedata fileref="" format="EPS"/>
   </imageobject>
   <textobject>
    <phrase></phrase>
   </textobject>
   <caption>
    <para></para>
   </caption>
  </mediaobject>")
    (indent-region point (point) nil)
    (search-backward "</phrase>" point t)))
(define-key global-map [f9] 'gdp-insert-mediaobject)


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