* Command in nxml-mode to show the current place in the structure (path)?
@ 2006-05-17 14:52 arndt.jonasson
2006-05-17 16:02 ` Command in nxml-mode to show the current place in the structure(path)? Drew Adams
2006-05-17 17:55 ` Command in nxml-mode to show the current place in the structure (path)? Lennart Borgman
0 siblings, 2 replies; 6+ messages in thread
From: arndt.jonasson @ 2006-05-17 14:52 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Command in nxml-mode to show the current place in the structure(path)?
2006-05-17 14:52 Command in nxml-mode to show the current place in the structure (path)? arndt.jonasson
@ 2006-05-17 16:02 ` Drew Adams
2006-05-17 18:02 ` Lennart Borgman
2006-05-17 17:55 ` Command in nxml-mode to show the current place in the structure (path)? Lennart Borgman
1 sibling, 1 reply; 6+ messages in thread
From: Drew Adams @ 2006-05-17 16:02 UTC (permalink / raw)
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.
I haven't (yet) used nxml (if it supported XML Schema, I'd use it in a
heartbeat), but I second your suggestion about path/position feedback
(assuming that feature is not already in nxml).
Taking it further, XPath navigation (not just telling you where you are)
would be helpful (a must, no?). I'd like an XML editor to take an XPath
expression and select (if multi-regions are available), or at least
highlight, all of the targeted nodes - and then let me cycle through them,
navigating to them. And that includes navigation using relative XPath
expressions (navigate from where point is now, along different axes).
There are lots of other things an XML editor could do if it was XPath-aware.
Perhaps nxml already is; I don't know. That could be a separate library
(xpath.el?), I suppose, but it sure would be useful.
Taking it one step further, how about an XQuery mode (every XPath expression
is an XQuery expression)?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Command in nxml-mode to show the current place in the structure (path)?
2006-05-17 14:52 Command in nxml-mode to show the current place in the structure (path)? arndt.jonasson
2006-05-17 16:02 ` Command in nxml-mode to show the current place in the structure(path)? Drew Adams
@ 2006-05-17 17:55 ` Lennart Borgman
2006-05-18 8:16 ` Florent Georges
1 sibling, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2006-05-17 17:55 UTC (permalink / raw)
Cc: help-gnu-emacs, emacs-nxml-mode
arndt.jonasson@gmail.com wrote:
> 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
>
Maybe you will have more luck asking this on the nxml-mode mailing list?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Command in nxml-mode to show the current place in the structure(path)?
2006-05-17 16:02 ` Command in nxml-mode to show the current place in the structure(path)? Drew Adams
@ 2006-05-17 18:02 ` Lennart Borgman
0 siblings, 0 replies; 6+ messages in thread
From: Lennart Borgman @ 2006-05-17 18:02 UTC (permalink / raw)
Cc: help-gnu-emacs
Drew Adams wrote:
> 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.
>
> I haven't (yet) used nxml (if it supported XML Schema, I'd use it in a
> heartbeat), but I second your suggestion about path/position feedback
> (assuming that feature is not already in nxml).
>
> Taking it further, XPath navigation (not just telling you where you are)
> would be helpful (a must, no?). I'd like an XML editor to take an XPath
> expression and select (if multi-regions are available), or at least
> highlight, all of the targeted nodes - and then let me cycle through them,
> navigating to them. And that includes navigation using relative XPath
> expressions (navigate from where point is now, along different axes).
>
There is an xpath for Emacs
http://www.emacswiki.org/cgi-bin/wiki/xpath.el
but I have never tried it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Re: Command in nxml-mode to show the current place in the structure (path)?
2006-05-17 17:55 ` Command in nxml-mode to show the current place in the structure (path)? Lennart Borgman
@ 2006-05-18 8:16 ` Florent Georges
2006-05-18 8:30 ` Florent Georges
0 siblings, 1 reply; 6+ messages in thread
From: Florent Georges @ 2006-05-18 8:16 UTC (permalink / raw)
Cc: help-gnu-emacs
Lennart Borgman wrote:
> arndt.jonasson@gmail.com wrote:
Hi
> > <e>
> > <a>
> > <b>
> > oh
> > </b>
> > <c/>
> > <d>
> > point is here
> > </d>
> > </a>
> > </e>
> > The command in question should show something like /e/a/d
> Maybe you will have more luck asking this on the nxml-mode
> mailing list?
I took the code of the OP, and did a few changes, then I
have:
(defun drkm-nxml:ancestor-axis-path ()
"Returns all the elements in the ancestor axis of the current
element. If called interactively, show it in the echo area."
(interactive)
(nxml-ensure-scan-up-to-date)
(let ((path ""))
(save-excursion
(condition-case ()
(while t
(nxml-backward-up-element)
(setq path (concat
"/" (xmltok-start-tag-qname) path)))
(error nil)))
path))
This seems to work. But I didn't check all cases nor
functions used. There is still the problem of the
namespaces. And the trick with the CONDITION-CASE is not
satisfactory, IMHO.
But it could be usable in some cases.
Regards,
--drkm
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger. Appelez le monde entier à partir de 0,012 /minute !
Téléchargez sur http://fr.messenger.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
You can search right from your browser? It's easy and it's free. See how.
http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/2U_rlB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/emacs-nxml-mode/
<*> To unsubscribe from this group, send an email to:
emacs-nxml-mode-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Re: Command in nxml-mode to show the current place in the structure (path)?
2006-05-18 8:16 ` Florent Georges
@ 2006-05-18 8:30 ` Florent Georges
0 siblings, 0 replies; 6+ messages in thread
From: Florent Georges @ 2006-05-18 8:30 UTC (permalink / raw)
Cc: help-gnu-emacs
Florent Georges wrote:
> "Returns all the elements in the ancestor axis of the current
> element. If called interactively, show it in the echo area."
As you did see, the command show nothing. Here is the
corrected version:
(defun drkm-nxml:ancestor-axis-path (&optional print-message)
"Return all the elements in the ancestor axis of the current
element. If called interactively, show it in the echo area."
(interactive "p")
(nxml-ensure-scan-up-to-date)
(let ((path ""))
(save-excursion
(condition-case ()
(while t
(nxml-backward-up-element)
(setq path (concat
"/" (xmltok-start-tag-qname) path)))
(error nil)))
(when print-message
(message "%s" path))
path))
There could be improvement to take other kinds of node into account
(attributes, etc.), to put the path in the kill ring if C-u, etcetera.
Regards,
--drkm
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger. Appelez le monde entier à partir de 0,012 /minute !
Téléchargez sur http://fr.messenger.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Home is just a click away. Make Yahoo! your home page now.
http://us.click.yahoo.com/DHchtC/3FxNAA/yQLSAA/2U_rlB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/emacs-nxml-mode/
<*> To unsubscribe from this group, send an email to:
emacs-nxml-mode-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-05-18 8:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-17 14:52 Command in nxml-mode to show the current place in the structure (path)? arndt.jonasson
2006-05-17 16:02 ` Command in nxml-mode to show the current place in the structure(path)? Drew Adams
2006-05-17 18:02 ` Lennart Borgman
2006-05-17 17:55 ` Command in nxml-mode to show the current place in the structure (path)? Lennart Borgman
2006-05-18 8:16 ` Florent Georges
2006-05-18 8:30 ` Florent Georges
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.