emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f113707 1/2: * lisp/dom.el (dom-previous-sibling):


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master f113707 1/2: * lisp/dom.el (dom-previous-sibling): New function.
Date: Sun, 22 Feb 2015 12:10:05 +0000

branch: master
commit f113707a071b5b35224861ddba3db881d74a164e
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>

    * lisp/dom.el (dom-previous-sibling): New function.
---
 lisp/dom.el |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/lisp/dom.el b/lisp/dom.el
index 11357e8..4213107 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



reply via email to

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