aboutsummaryrefslogblamecommitdiff
path: root/en_US.ISO8859-1/books/fdp-primer/psgml-mode/chapter.sgml
blob: 6dc06189f6faa237f6694c27539adabde205bf1d (plain) (tree)



























                                                                              

                                                          























































































































                                                                              
<!-- Copyright (c) 1998, 1999 Nik Clayton, All rights reserved.

     Redistribution and use in source (SGML DocBook) and 'compiled' forms
     (SGML HTML, PDF, PostScript, RTF and so forth) with or without
     modification, are permitted provided that the following conditions
     are met:

      1. Redistributions of source code (SGML DocBook) must retain the above
         copyright notice, this list of conditions and the following
         disclaimer as the first lines of this file unmodified.

      2. Redistributions in compiled form (transformed to other DTDs,
         converted to PDF, PostScript, RTF and other formats) must reproduce
         the above copyright notice, this list of conditions and the
         following disclaimer in the documentation and/or other materials
         provided with the distribution.

     THIS DOCUMENTATION IS PROVIDED BY NIK CLAYTON "AS IS" AND ANY EXPRESS OR
     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     DISCLAIMED. IN NO EVENT SHALL NIK CLAYTON BE LIABLE FOR ANY DIRECT,
     INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE
     POSSIBILITY OF SUCH DAMAGE.

     $Id: chapter.sgml,v 1.2 1999-07-14 19:17:50 nik Exp $
-->

<chapter id="psgml-mode">
  <title>Using <literal>sgml-mode</literal> with
    <application>Emacs</application></title>
  
  <para>Recent versions of Emacs or Xemacs (available from the ports
    collection) contain a very useful package called PSGML. Automatically
    invoked when a file with <filename>.sgml</filename> extension is loaded,
    or by typing <command>M-x sgml-mode</command>, it is a major mode for
    dealing with SGML files, elements and attributes.</para>

  <para>An understanding of some of the commands provided by this mode can
    make working with SGML documents such as the Handbook much easier.</para>

  <variablelist>
    <varlistentry>
      <term><command>C-c C-e</command></term>
      
      <listitem>
	<para>Runs <literal>sgml-insert-element</literal>. You will be
	  prompted for the name of the element to insert at the current point.
	  You can use the TAB key to complete the element. Elements that are
	  not valid at the current point will be disallowed.</para>

	<para>The start and end tags for the element will be inserted. If the
	  element contains other, mandatory, elements then these will be
	  inserted as well.</para>
      </listitem>
    </varlistentry>
    
    <varlistentry>
      <term><command>C-c =</command></term>
      
      <listitem>
	<para>Runs <literal>sgml-change-element-name</literal>. Place the
	  point within an element and run this command. You will be prompted
	  for the name of the element to change to. Both the start and end
	  tags of the current element will be changed to the new
	  element.</para>
      </listitem>
    </varlistentry>
    
    <varlistentry>
      <term><command>C-c C-r</command></term>
      
      <listitem>
	<para>Runs <literal>sgml-tag-region</literal>. Select some text (move
	  to start of text, C-space, move to end of text, C-space) and then
	  run this command. You will be prompted for the element to use. This
	  element will then be inserted immediately before and after your
	  marked region.</para>
      </listitem>
    </varlistentry>

    <varlistentry>
      <term><command>C-c -</command></term>
      
      <listitem>
	<para>Runs <literal>sgml-untag-element</literal>. Place the point
	  within the start or end tag of an element you want to remove, and
	  run this command. The element's start and end tags will be
	  removed.</para>
      </listitem>
    </varlistentry>
    
    <varlistentry>
      <term><command>C-c C-q</command></term>
      
      <listitem>
	<para>Runs <literal>sgml-fill-element</literal>. Will recursively fill
	  (i.e., reformat) content from the current element in. The filling
	  <emphasis>will</emphasis> affect content in which whitespace is
	  significant, such as within <sgmltag>programlisting</sgmltag>
	  elements, so run this command with care.</para>
      </listitem>
    </varlistentry>
    
    <varlistentry>
      <term><command>C-c C-a</command></term>
      
      <listitem>
	<para>Runs <literal>sgml-edit-attributes</literal>. Opens a second
	  buffer containing a list of all the attributes for the closest
	  enclosing element, and their current values. Use TAB to navigate
	  between attributes, <command>C-k</command> to remove an existing
	  value and replace it with a new one, <command>C-c</command> to close
	  this buffer and return to the main document.</para>
      </listitem>
    </varlistentry>
    
    <varlistentry>
      <term><command>C-c C-v</command></term>
      
      <listitem>
	<para>Runs <literal>sgml-validate</literal>. Prompts you to save the
	  current document (if necessary) and then runs an SGML validator. The
	  output from the validator is captured into a new buffer, and you can
	  then navigate from one troublespot to the next, fixing markup errors
	  as you go.</para>
      </listitem>
    </varlistentry>
  </variablelist>
  
  <para>Doubtless there are other useful functions of this mode, but those are
    the ones I use most often.</para>
</chapter>


<!--
     Local Variables:
     mode: sgml
     sgml-declaration: "../chapter.decl"
     sgml-indent-data: t
     sgml-omittag: nil
     sgml-always-quote-attributes: t
     sgml-parent-document: ("../book.sgml" "part" "chapter")
     End:
-->