Function: combobulate-get-specific-parent-type

combobulate-get-specific-parent-type is a natively compiled function defined in combobulate-navigation.el.

Signature

(combobulate-get-specific-parent-type NODE SPECIFIC-TYPES &optional SKIP-SELF-SIMILAR)

Documentation

Get the first parent node of NODE that matches one of the SPECIFIC-TYPES

If SKIP-SELF-SIMILAR is non-nil then the first parent node that is self-similar to NODE is skipped

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-navigation.el
(defun combobulate-get-specific-parent-type (node specific-types &optional skip-self-similar)
  "Get the first parent node of NODE that matches one of the SPECIFIC-TYPES

If SKIP-SELF-SIMILAR is non-nil then the first parent node that is
self-similar to NODE is skipped"
  (let* ((parents (combobulate-get-parents node))
         (self-similar-node nil)
         (match (seq-find (lambda (match-node)
                            (and (member (combobulate-node-type match-node) specific-types)
                                 ;; NOTE there's a special case here. If we
                                 ;; are at the beginning of a node, like a
                                 ;; JSX element, then that is also the
                                 ;; self-same type of node we're often
                                 ;; looking for as a parent. Only we're
                                 ;; going to match against ourselves and so
                                 ;; we're not getting the 'actual' parent
                                 ;; of `node'. This only happens when the
                                 ;; noce you're looking at happens to be
                                 ;; self-similarly the same as the parent.
                                 (if (and skip-self-similar (combobulate-point-at-beginning-of-node-p match-node))
                                     ;; This is the equivalent of skipping a parent, so we should not increment.
                                     (progn (setq self-similar-node match-node) nil)
                                   t)))
                          parents)))
    (cons self-similar-node match)))