help-gnu-emacs
[Top][All Lists]
Advanced

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

Command in nxml-mode to show the current place in the structure (path)?


From: arndt . jonasson
Subject: Command in nxml-mode to show the current place in the structure (path)?
Date: 17 May 2006 07:52:38 -0700
User-agent: G2/0.2

I've recently started using nxml-mode, and one function I quickly
felt a need for is one which compactly indicates where in the
structure we currently are. For example,

<e>
  <a>
     <b>
      oh
     </b>
     <c/>
     <d>
          point is here
     </d>
  </a>
</e>

The command in question should show something like /e/a/d, i.e.,
an XML path to the current element. Has anyone written such a
function? Actually, I just did myself, but it feels like a rough and
error-prone attempt. Since it's very small, I'll enclose it here:

(defun show-xml-path (arg)
  "Shows the names of all elements enclosing point, in the echo area."
  (interactive "*P")
  (let ((q ""))
    (nxml-ensure-scan-up-to-date)
    (setq q "")
    (condition-case ()
        (save-excursion
          (while t
            (nxml-backward-up-element)
            (setq q (concat (xmltok-start-tag-qname) "/" q))))
      (error (message q)))))

I know there is a mailing-list for nxml-mode, but searching it didn't
turn up anything like this.

/Arndt Jonasson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]