Function: with-navigation-nodes

with-navigation-nodes is a macro defined in combobulate-navigation.el.

Signature

(with-navigation-nodes (&key (NODES nil) SKIP-PREFIX BACKWARD (SKIP-NEWLINE t) (PROCEDURES nil)) &rest BODY)

Documentation

Invoke BODY with a list of specific navigational nodes, and maybe advance point.

If :nodes is non-nil, it must be a list of legitimate tree sitter node types to let-bind to combobulate-navigable-nodes. If nil, or not specified, use the default nodes.

If :skip-prefix is non-nil, then skip forward (unless
:backward is set) in the direction, skipping past
combobulate-skip-prefix-regexp characters.

If an error is raised during BODY, then reset the point to its original position.

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-navigation.el
(cl-defmacro with-navigation-nodes ((&key (nodes nil) skip-prefix backward (skip-newline t) (procedures nil)) &rest body)
  "Invoke BODY with a list of specific navigational nodes, and maybe advance point.

If `:nodes' is non-nil, it must be a list of legitimate tree
sitter node types to `let'-bind to
`combobulate-navigable-nodes'. If nil, or not specified,
use the default nodes.

If `:skip-prefix' is non-nil, then skip forward (unless
`:backward' is set) in the direction, skipping past
`combobulate-skip-prefix-regexp' characters.

If an error is raised during BODY, then reset the point to its
original position."
  (declare (indent 1) (debug (sexp body)))
  (let ((--old-pos (gensym))
        (--err (gensym)))
    `(let* ((procedure-value
             (and
              (not (equal ',procedures nil))
              ,procedures))
            (combobulate-navigable-nodes
             (or ,nodes
                 (when (and procedure-value (not ,nodes))
                   (combobulate-procedure-collect-activation-nodes
                    procedure-value))
                 (combobulate-read default-nodes)
                 (combobulate-procedure-collect-activation-nodes
                  (combobulate-read procedures-default))))
            (combobulate-default-procedures procedure-value))
       ;; keep the old position around: if we skip chars around but
       ;; `body' fails with an error we want to snap back.
       (let ((,--old-pos (point))
             (,--err t))
         (when ,skip-prefix
           (if ,backward
               (skip-chars-backward
                (if ,skip-newline combobulate-skip-prefix-regexp
                  combobulate-skip-prefix-regexp-no-newline))
             (combobulate-skip-whitespace-forward ,skip-newline)))
         ;; preserves call stack in case of an error
         (unwind-protect
             (prog1 (progn ,@body)
               (setq ,--err nil))
           (when ,--err (goto-char ,--old-pos))
           nil)))))