Docbook Editors

View: New views
3 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: Docbook Editors

by Stefano Sabatini :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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:
nxml-hide-all-text-content
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
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; 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)
     ,def))

(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)
    map)
  "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)
     ,def))

(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.")

;;;###autoload
(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)
       nxml-docbook-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 "")
         nil
       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
inserted."
  (interactive)
  (let* ((title (if (null title)
                    (read-not-empty-string "title of the variablelist: ")))
         (title-skeleton
          (if title '((concat "<title>" title "</title>") > \n)
            nil)))
    (skeleton-insert
     `(nil
       "<variablelist>"
       > \n
       ,@title-skeleton
       > _ \n
       "</variablelist>" > \n
       \n
       ))))

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

(defun nxml-docbook-insert-para()
  (interactive)
  (skeleton-insert
   '(nil
     "<para>" > \n
     > _ \n
     "</para>" > \n
     \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


---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@...
For additional commands, e-mail: docbook-apps-help@...

Re: Docbook Editors

by W. Martin Borgert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jul 03, 2007 at 03:50:39PM +0200, Stefano Sabatini wrote:
> I elaborated a very basic derived mode (attached) with the imenu
> tagging for the titles. Then I discovered the function:
> nxml-hide-all-text-content
> which shows in the editing buffer the outline of the whole document.

Thanks, I will use your mode!

> 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.

Yes. Speedbar etc. have an easier life with HTML, because <h1>..<h6>
already give some more information then <title>, where you have to
check if it is the title of a book, a chapter, a section, or a
section/section/section.

Cheers!

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@...
For additional commands, e-mail: docbook-apps-help@...


Re: Docbook Editors

by Alan Ezust-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't care about WISIWYG, but what I care about when I am editing
XML documents is the following.

1: A tree like structure browser, as you mentioned below
2: Error highlighting
3: Completion for both elements and attributes.

jEdit (www.jedit.org) supports all of these, with the XML plugin.
It supports DTDs and XML Schemas, and some day we'll integrate RNG too.

It's 100% free, and open source.

On 6/28/07, Stefano Sabatini <stefano.sabatini-lala@...> wrote:

> On date Thursday 2007-06-28 10:33:40 -0400, Johnson, Eric wrote:
> [...]
> > If you don't need wysiwyg and you like free, Emacs with NXML mode is
> > fast, free, and easy to learn.
>
> Do someone know if it's possible with emacs NXML mode to see (for
> example in the ECB method buffer) the layout of the document edited,
> for example the hierarchy of chapters and sections?
>
> And what about the insertion of complex skeletons, like that of a
> variablelist? There is already some way to add them with some
> shortcuts or is needed to hook into nxml-mode-hook all the various
> docbook specific skeleton insertion functions required?
>
> Thanks in advance for any reply.
>
> Cheers.
> --
> Stefano Sabatini

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@...
For additional commands, e-mail: docbook-apps-help@...

< Prev | 1 - 2 | Next >