From: Lars Magne Ingebrigtsen Date: Sun, 22 Feb 2015 12:09:30 +0000 (+0100) Subject: * lisp/dom.el (dom-previous-sibling): New function. X-Git-Tag: emacs-25.0.90~2564^2~321 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f113707a071b5b35224861ddba3db881d74a164e;p=emacs.git * lisp/dom.el (dom-previous-sibling): New function. --- diff --git a/lisp/dom.el b/lisp/dom.el index 11357e88804..42131073a04 100644 --- a/lisp/dom.el +++ b/lisp/dom.el @@ -149,6 +149,16 @@ ATTRIBUTE would typically be `class', `id' or the like." (setq result (dom-parent elem node)))) result))) +(defun dom-previous-sibling (dom node) + (when-let (parent (dom-parent dom node)) + (let ((siblings (dom-children parent)) + (previous nil)) + (while siblings + (when (eq (cadr siblings) node) + (setq previous (car siblings))) + (pop siblings)) + previous))) + (defun dom-node (tag &optional attributes &rest children) "Return a DOM node with TAG and ATTRIBUTES." (if children