OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] Docbook Editors

On date Monday 2007-07-02 22:11:21 +0000, W. Borgert wrote:
> On Mon, Jul 02, 2007 at 02:27:52PM +0200, Stefano Sabatini wrote:
> > Unfortunately both seem to lack tagging feature, to show up the layout
> > of the document displayed, which is fundamental to me while editing a
> > complex document, to understand where I am and to easily jump from one
> > section to another one
> One could make use of "imenu" and/or "speedbar". imenu and
> speedbar are parts of Emacs 21 and 22, AFAIK. Try this:
> (require 'imenu)
> (require 'speedbar)
> (defvar dbk-imenu-generic-expression nil
>   "Imenu generic expression for DocBook.  See `imenu-generic-expression'.")
> (add-hook 'nxml-mode-hook
> 	  (lambda ()
> 	    (speedbar-add-supported-extension ".dbk")
> 	    (setq dbk-imenu-generic-expression
> 		  '((nil
> 		     "^[ \t]*<title>\\(.*\\)</title>"
> 		     1)))
> 	    (setq imenu-generic-expression dbk-imenu-generic-expression
> 		  imenu-case-fold-search nil)
> 	    (imenu-add-to-menubar "DocBook")))
> Now call M-x speedbar, when you are in nxml-mode. It does not
> really reflect the document structure, but maybe it helps a bit
> to see all titles in the right order. speedbar lets you jump to
> the right place, as does the menu "DocBook".

Thank you, it helped much :-).

I elaborated a very basic derived mode (attached) with the imenu
tagging for the titles. Then I discovered the function:
which shows in the editing buffer the outline of the whole document.

My ideal solution would be to find a way to use semantic to analyze
somehow these tags to show up in the speedbar or in the ECB methods
buffer this outline.

Kind regards.
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
;;; nxml-docbook-mode.el --- Simple major mode for XML Docbook

;; Copyright (C) 2007  Free Software Foundation, Inc.

;; Author: Stefano Sabatini
;; Keywords: XML, docbook

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:


;;; Code:

(defvar nxml-docbook-mode-hook nil
  "A hook that is run after nxml-docbook-mode is activated in a buffer.")

(defvar nxml-docbook-mode-map-prefix "\C-cd"
  "The prefix to each command defined in the `nxml-docbook-mode-map' keymap.")

(defmacro define-key-with-prefix (map key def prefix)
  `(define-key ,map
     (concat ,prefix ,key)

(defvar nxml-docbook-mode-map
  (let ((map (make-sparse-keymap))
        (prefix nxml-docbook-mode-map-prefix))
    (define-key-with-prefix map "iv" 'nxml-docbook-insert-variablelist prefix)
    (define-key-with-prefix map "ie" 'nxml-docbook-insert-varlistentry prefix)
    (define-key-with-prefix map "ip" 'nxml-docbook-insert-para prefix)
  "Keymap for `nxml-docbook-mode'.")

(defmacro nxml-docbook-define-key (key def)
  `(define-key nxml-docbook-mode-map
     (concat nxml-docbook-mode-map-prefix ,key)

(defvar nxml-docbook-imenu-generic-expression
  '((nil "^[ \t]*<title>\\(.*\\)</title>" 1))
  "Imenu generic expression for XML Docbook. It catches only
titles, wherever they are placed in the document layout (section,
chapters, etc). See `imenu-generic-expression'.")

(defvar nxml-docbook-show-menu nil
  "Tells if to add a menu to the menubar with NXML docbook mode stuff.")

(define-derived-mode nxml-docbook-mode nxml-mode "NXML Docbook"
  "A major mode for editing XML Docbook files, derived from NXML mode."
  (set (make-local-variable 'imenu-generic-expression)
  (if nxml-docbook-show-menu
      (imenu-add-to-menubar "NXML Docbook")))

(defmacro read-not-empty-string (body)
  `(let ((string (read-string ,body)))
     (if (equal string "")

(defun nxml-docbook-insert-variablelist (&optional title)
  "Insert at the current position the skeleton of a docbook variabelist entry.
If the title is specified an element with the title will also be
  (let* ((title (if (null title)
                    (read-not-empty-string "title of the variablelist: ")))
          (if title '((concat "<title>" title "</title>") > \n)
       > \n
       > _ \n
       "</variablelist>" > \n

(defun nxml-docbook-insert-varlistentry()
  (let ((term (read-not-empty-string "term of the varlistentry: ")))
       "<varlistentry>" \n
       "<term>" term "</term>" \n
       "<listitem>" \n
       "<para>" \n
       _ \n
       "</para>" > \n
      "</listitem>" > \n
       "</varlistentry>" > \n

(defun nxml-docbook-insert-para()
     "<para>" > \n
     > _ \n
     "</para>" > \n

;; (defun nxml-docbook-render ()
;;   "Renders the current XML document into HTML."
;;   (interactive)
;;   (if (buffer-modified-p)
;;       (error "Buffer has been modified.  Save your changes first!"))
;;   (message "Rendering document into HTML ...")
;;   (my-background-shell-command (format "db2html %s" (buffer-file-name))))

(provide 'nxml-docbook-mode)
;;; nxml-docbook.el ends here

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]