;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\303\304\305\306\307\310%\210\311\312\313\314\315DD\316\317\320\307\304&\210\311\321\313\314\322DD\323\317\320\307\304&\210\311\324\313\314\325DD\326\317\320\307\304&\210\311\327\313\314\330DD\331\307\304\317\332&\207" [require tsc tree-sitter-load custom-declare-group tree-sitter nil "Incremental parsing system." :group languages custom-declare-variable tree-sitter-after-change-functions funcall function #[0 "\300\207" [nil] 1] "Functions to call each time `tree-sitter-tree' is updated.\nEach function will be called with a single argument: the OLD-TREE. This argument\nwill be nil when the buffer is parsed for the first time.\n\nFor initialization logic that should be run only once, use\n`tree-sitter-after-first-parse-hook' instead." :type hook tree-sitter-after-first-parse-hook #[0 "\300\207" [nil] 1] "Functions to call after the buffer is parsed for the first time.\nThis hook should be used for initialization logic that requires inspecting the\nsyntax tree. It is run after `tree-sitter-mode-hook'." tree-sitter-after-on-hook #[0 "\300\207" [nil] 1] "Functions to call after enabling `tree-sitter-mode'.\nUse this to enable other minor modes that depends on the syntax tree." tree-sitter-major-mode-language-alist #[0 "\300\207" [nil] 1] "Alist that maps major modes to tree-sitter language names." (alist :key-type symbol :value-type symbol)] 8) #@26 Tree-sitter syntax tree. (defvar tree-sitter-tree nil (#$ . 1492)) (make-variable-buffer-local 'tree-sitter-tree) #@21 Tree-sitter parser. (defvar tree-sitter-parser nil (#$ . 1612)) (make-variable-buffer-local 'tree-sitter-parser) #@23 Tree-sitter language. (defvar tree-sitter-language nil (#$ . 1731)) (make-variable-buffer-local 'tree-sitter-language) (defvar tree-sitter--text-before-change nil nil) (make-variable-buffer-local 'tree-sitter--text-before-change) (defvar tree-sitter--beg-before-change nil nil) (make-variable-buffer-local 'tree-sitter--beg-before-change) #@166 Update relevant editing states. Installed on `before-change-functions'. BEG and OLD-END are the begin and end positions of the text to be changed. (fn BEG OLD-END) (defalias 'tree-sitter--before-change #[514 "\214~\210\211V\205\302\"\211)\207" [tree-sitter--beg-before-change tree-sitter--text-before-change buffer-substring-no-properties] 5 (#$ . 2077)]) #@272 Update relevant editing states and reparse the buffer (incrementally). Installed on `after-change-functions'. BEG is the begin position of the change. NEW-END is the end position of the changed text. OLD-LEN is the char length of the old text. (fn BEG NEW-END OLD-LEN) (defalias 'tree-sitter--after-change #[771 "\205\243\303!\303!\304\211\211\211\212\214~\210\305 !\262\305!\262*\306U\203/\262\262\202\216  \nZT\307\310\311\"r\211q\210\312\313\"\216c\210\n\\\303!\303!Z\242\243\314!\305!\211\242\243Z\\\306V\203x\202} \\\\\262B\262\266*\266\315&\210\316 \266\206\207" [tree-sitter-tree tree-sitter--text-before-change tree-sitter--beg-before-change position-bytes nil tsc--point-from-position 0 generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] line-number-at-pos tsc-edit-tree tree-sitter--do-parse] 29 (#$ . 2449)]) #@54 Parse the current buffer and update the syntax tree. (defalias 'tree-sitter--do-parse #[0 "\214~\210\302 \303#)\304\305\"\207" [tree-sitter-tree tree-sitter-parser tsc-parse-chunks tsc--buffer-input run-hook-with-args tree-sitter-after-change-functions] 5 (#$ . 3412)]) #@45 Enable `tree-sitter' in the current buffer. (defalias 'tree-sitter--setup #[0 "\204\304 \n\"\211\204\305\306 \"\210\307!\210 \204\"\310 \311 \"\210\312\313\314\315\316$\210\312\317\320\315\316$\207" [tree-sitter-language major-mode tree-sitter-major-mode-language-alist tree-sitter-parser alist-get error "No language registered for major mode `%s'" tree-sitter-require tsc-make-parser tsc-set-language add-hook before-change-functions tree-sitter--before-change :append :local after-change-functions tree-sitter--after-change] 5 (#$ . 3692)]) #@46 Disable `tree-sitter' in the current buffer. (defalias 'tree-sitter--teardown #[0 "\303\304\305\306#\210\303\307\310\306#\210\311\211\311\211\207" [tree-sitter-tree tree-sitter-parser tree-sitter-language remove-hook after-change-functions tree-sitter--after-change :local before-change-functions tree-sitter--before-change nil] 5 (#$ . 4252)]) #@205 Execute BODY-FORM with ERROR-FORMS as cleanup code that is executed on error. Unlike `unwind-protect', ERROR-FORMS is not executed if BODY-FORM does not signal an error. (fn BODY-FORM &rest ERROR-FORMS) (defalias 'tree-sitter--error-protect '(macro . #[385 "\300\301\302\303\304BB\305\306BBEE\207" [let ((err t)) unwind-protect prog1 ((setq err nil)) when err] 9 (#$ . 4607)])) (byte-code "\300\301\302\303#\300\207" [function-put tree-sitter--error-protect lisp-indent-function 1] 4) #@101 Non-nil if tree-sitter mode is enabled. Use the command `tree-sitter-mode' to change this variable. (defvar tree-sitter-mode nil (#$ . 5103)) (make-variable-buffer-local 'tree-sitter-mode) #@632 Minor mode that keeps an up-to-date syntax tree using incremental parsing. This is a minor mode. If called interactively, toggle the `tree-sitter mode' mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode. If called from Lisp, toggle the mode if ARG is `toggle'. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, evaluate `tree-sitter-mode'. The mode's hook is called both when the mode is enabled and when it is disabled. (fn &optional ARG) (defalias 'tree-sitter-mode #[256 "\303 \304=\203 ?\202\247\203\305W\203\306\202\307\310\301!\2031\311\300 \"\2031\300 B\203Z\307C\312\313\"\216\314 \210\3151K\316\317!0\210\202Q\320\321\"\266\211\306\240\210)\210\202a\316\322!\210\323 \210\316\324\203k\325\202l\326\"\210\327\330!\203\216\303 \203\200\211\303 \232\203\216\320\331\203\212\332\202\213\333\334#\210\203\235\n\204\235\335 \210\316\336!\210\210\337 \210\207" [tree-sitter-mode local-minor-modes tree-sitter-tree current-message toggle 1 nil t boundp delq make-closure #[0 "\300\242\205 \302\303 \207" [V0 tree-sitter-mode nil tree-sitter--teardown] 1] tree-sitter--setup (debug error) run-hooks tree-sitter-after-on-hook message "tree-sitter-after-on-hook: %S" tree-sitter--before-off-hook tree-sitter--teardown tree-sitter-mode-hook tree-sitter-mode-on-hook tree-sitter-mode-off-hook called-interactively-p any "tree-sitter mode %sabled%s" "en" "dis" " in current buffer" tree-sitter--do-parse tree-sitter-after-first-parse-hook force-mode-line-update] 7 (#$ . 5299) (byte-code "\203\n\301!\202 \302C\207" [current-prefix-arg prefix-numeric-value toggle] 2)]) (defvar tree-sitter-mode-hook nil) (byte-code "\301\302N\204\f\303\301\302\304#\210\303\301\305\306#\210\303\301\307\310C#\210\311\312\313\314\300!\205#\310\211%\207" [tree-sitter-mode-map tree-sitter-mode-hook variable-documentation put "Hook run after entering or leaving `tree-sitter-mode'.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" custom-type hook standard-value nil add-minor-mode tree-sitter-mode " tree-sitter" boundp] 6) #@54 Turn on `tree-sitter-mode' in a buffer, if possible. (defalias 'turn-on-tree-sitter-mode #[0 "\3001 \301\302!0\207\210\303\207" [(error) tree-sitter-mode 1 nil] 2 (#$ . 7626)]) (put 'global-tree-sitter-mode 'globalized-minor-mode t) (defvar tree-sitter-mode-major-mode nil nil) (byte-code "\300\301!\210\302\303\304\305\306DD\307\310\311\312\313\314\315\316\317& \207" [make-variable-buffer-local tree-sitter-mode-major-mode custom-declare-variable global-tree-sitter-mode funcall function #[0 "\300\207" [nil] 1] "Non-nil if Global Tree-Sitter mode is enabled.\nSee the `global-tree-sitter-mode' command\nfor a description of this minor mode.\nSetting this variable directly does not take effect;\neither customize it (see the info node `Easy Customization')\nor call the function `global-tree-sitter-mode'." :set custom-set-minor-mode :initialize custom-initialize-default :type boolean :group tree-sitter] 12) #@372 Toggle Tree-Sitter mode in all buffers. With prefix ARG, enable Global Tree-Sitter mode if ARG is positive; otherwise, disable it. If called from Lisp, enable the mode if ARG is omitted or nil. Tree-Sitter mode is enabled in all buffers where `turn-on-tree-sitter-mode' would do it. See `tree-sitter-mode' for more information on Tree-Sitter mode. (fn &optional ARG) (defalias 'global-tree-sitter-mode #[256 "\303 \304\301\305=\203\306\301!?\202!\247\203 \307W\203 \310\202!\311\"\210\312\300!\2038\313\301\"\306\301!\2038\301B \203N\314\315\316\"\210\314\317\320\"\210\314\321\322\"\210\202]\323\315\316\"\210\323\317\320\"\210\323\321\322\"\210\324 \211\203\203\211@r\211q\210 \203s\325 \210\202{\n\203{\302\326!\210)A\266\202\202_\210\327\330\306\301!\203\220\331\202\221\332\"\210\333\334!\203\271\335\301!\210\303 \203\251\211\303 \232\203\271\336\337\306\301!\203\265\340\202\266\341\342#\210\210\343 \210\306\301!\207" [global-minor-modes global-tree-sitter-mode tree-sitter-mode current-message set-default toggle default-value 1 nil t boundp delq add-hook after-change-major-mode-hook global-tree-sitter-mode-enable-in-buffers find-file-hook global-tree-sitter-mode-check-buffers change-major-mode-hook global-tree-sitter-mode-cmhh remove-hook buffer-list turn-on-tree-sitter-mode -1 run-hooks global-tree-sitter-mode-hook global-tree-sitter-mode-on-hook global-tree-sitter-mode-off-hook called-interactively-p any customize-mark-as-set message "Global Tree-Sitter mode %sabled%s" "en" "dis" "" force-mode-line-update] 6 (#$ . 8547) (byte-code "\203\n\301!\202 \302C\207" [current-prefix-arg prefix-numeric-value toggle] 2)]) (defvar global-tree-sitter-mode-hook nil) (byte-code "\301\302N\204\f\303\301\302\304#\210\303\301\305\306#\210\303\301\307\310C#\210\311\312\310\313\300!\205#\310\211%\207" [global-tree-sitter-mode-map global-tree-sitter-mode-hook variable-documentation put "Hook run after entering or leaving `global-tree-sitter-mode'.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" custom-type hook standard-value nil add-minor-mode global-tree-sitter-mode boundp] 6) (defvar tree-sitter-mode-set-explicitly nil nil) (make-variable-buffer-local 'tree-sitter-mode-set-explicitly) (defalias 'tree-sitter-mode-set-explicitly #[0 "\301\211\207" [tree-sitter-mode-set-explicitly t] 2]) (byte-code "\300\301\302\303#\210\304\305\301\"\207" [put tree-sitter-mode-set-explicitly definition-name global-tree-sitter-mode add-hook tree-sitter-mode-hook] 4) (defvar global-tree-sitter-mode-buffers nil) (defalias 'global-tree-sitter-mode-enable-in-buffers #[0 "\305\211\211\2059\211@\306!\2032r\211q\210 \204/\n =\204/\f\203,\304\307!\210\310 \210\202/\310 \210 )A\266\202\202\207" [global-tree-sitter-mode-buffers tree-sitter-mode-set-explicitly tree-sitter-mode-major-mode major-mode tree-sitter-mode nil buffer-live-p -1 turn-on-tree-sitter-mode] 5]) (put 'global-tree-sitter-mode-enable-in-buffers 'definition-name 'global-tree-sitter-mode) (defalias 'global-tree-sitter-mode-check-buffers #[0 "\300 \210\301\302\303\"\207" [global-tree-sitter-mode-enable-in-buffers remove-hook post-command-hook global-tree-sitter-mode-check-buffers] 3]) (put 'global-tree-sitter-mode-check-buffers 'definition-name 'global-tree-sitter-mode) (defalias 'global-tree-sitter-mode-cmhh #[0 "\300\301p\"\210\302\303\304\"\207" [add-to-list global-tree-sitter-mode-buffers add-hook post-command-hook global-tree-sitter-mode-check-buffers] 3]) (put 'global-tree-sitter-mode-cmhh 'definition-name 'global-tree-sitter-mode) #@140 Return an equivalent to (funcall FUNC) that can be used in a macro. If FUNC is a quoted symbol, skip the `funcall' indirection. (fn FUNC) (defalias 'tree-sitter--funcall-form #[257 "\211:\203\211@\300>\203\211A@9\203\211A@C\207\301D\207" ['function funcall] 3 (#$ . 12204)]) #@1207 Build the block of code that handles enabling/disabling of a dependent mode. Use this as the body of the `define-minor-mode' block that defines MODE. When MODE is enabled, it automatically enables `tree-sitter-mode'. When MODE is disabled, it does not disable `tree-sitter-mode', since the latter may have been requested by end user, or other dependent modes. When `tree-sitter-mode' is disabled, it automatically disables MODE, which will not function correctly otherwise. This happens before `tree-sitter-mode' cleans up its own state. SETUP-FUNCTION is called when MODE is enabled, after MODE variable has been set to t, and after `tree-sitter-mode' has already been enabled. However, it must not assume that `tree-sitter-tree' is non-nil, since the first parse may not happen yet. It should instead set up hooks to handle parse events. TEARDOWN-FUNCTION is called when MODE is disabled, after MODE variable has been set to nil. It should clean up any state set up by MODE, and should not signal any error. It is also called when SETUP-FUNCTION signals an error, to undo any partial setup. Both SETUP-FUNCTION and TEARDOWN-FUNCTION should be idempotent. (fn MODE SETUP-FUNCTION TEARDOWN-FUNCTION) (defalias 'tree-sitter--handle-dependent '(macro . #[771 "\300!\300!\301\302\303\302\304E\305\n\306BBF\307\310\311\312\313 \314BED\315BBBEF\207" [tree-sitter--funcall-form if progn tree-sitter--error-protect (unless tree-sitter-mode (tree-sitter-mode)) setq (nil) add-hook 'tree-sitter--before-off-hook quote lambda nil (-1) (nil :local)] 16 (#$ . 12495)])) (byte-code "\300\301\302\303#\300\207" [function-put tree-sitter--handle-dependent lisp-indent-function 1] 4) #@156 Return the smallest syntax node at point whose type is NODE-TYPE. If NODE-TYPE is nil, return the smallest syntax node at point. (fn &optional NODE-TYPE) (defalias 'tree-sitter-node-at-point #[256 "\301!`\302\211#\203-\211\303\203,\304!\232\203$\262\303\262\202\305!\262\202\207\207" [tree-sitter-tree tsc-root-node tsc-get-descendant-for-position-range nil tsc-node-type tsc-get-parent] 9 (#$ . 14186)]) (provide 'tree-sitter)