# HG changeset patch # User Oleksandr Gavenko # Date 1512291425 -7200 # Node ID e3a381f14ad111bd1e9b1052af2b0de87cf50e25 # Parent 4ede173a315fb267ce499b27576c4a157cb9934a Added function that copies xpath-like path in XML document. diff -r 4ede173a315f -r e3a381f14ad1 .emacs-my --- a/.emacs-my Sun Dec 03 10:55:56 2017 +0200 +++ b/.emacs-my Sun Dec 03 10:57:05 2017 +0200 @@ -3493,6 +3493,27 @@ (my--eval-after-load nxml-mode (define-key nxml-mode-map [C-return] 'nxml-complete)) +(defun my-nxml-where (&optional prefix) + "Display the hierarchy of XML elements the point is on as a path." + (interactive "P") + (let (path) + (save-excursion + (save-restriction + (widen) + (while (and (< (point-min) (point)) + (condition-case nil + (progn + (nxml-backward-up-element) + t) + (error nil))) + (setq path (cons (xmltok-start-tag-local-name) path))) + (setq path (mapconcat 'identity path "/")) + (when prefix + (kill-new path)) + (if (called-interactively-p t) + (message "%s" path) + path))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "relax ng, rng")