;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (require 'cl-lib) #@400 Get the value from VALUE depending on its type. VALUE is evaluated in two stages: 1. If it is a function, call it using `funcall', applying ARGS (a list of arguments) to it. If VALUE is a symbol and that symbol does not have an associated function, yield that symbol's value. 2. If the result of the first stage is a number, make it a string, yielding stage 1's result otherwise. (fn VALUE ARGS) (defalias 'dap-variables--eval-poly-type #[514 "\300!\203 \301\"\2029\203J\202\211\247\203!\302!\207\207" [functionp apply number-to-string] 5 (#$ . 106)]) #@103 Expand all characters escaped with backslashes in string S. Return the result, also a string. (fn S) (defalias 'dap-variables--expand-escapes #[257 "\300\301\302\303\304%\207" [replace-regexp-in-string "\\\\\\(.\\)" #[257 "\300\301\"\207" [match-string 1] 4 "\n\n(fn MATCH)"] nil t] 7 (#$ . 683)]) #@233 Expand all variables of the form ${VARIABLE} in string S. Return the result. To expand each variable, VAR-CB is `funcall'ed, with VARIABLE as argument. If it returns nil, no expansion is performed for that part of S. (fn VAR-CB S) (defalias 'dap-variables--expand-in-string #[514 "\300\301\302\303\"\304\305%\207" [replace-regexp-in-string "\\\\\\(\\$\\)\\|\\${\\(\\(?:[^\\}]\\|\\\\[^z-a]\\)*\\)}" make-closure #[257 "\301\302\"\301\303\"\206\211\203\300\304!!\206\207" [V0 match-string 1 2 dap-variables--expand-escapes] 6 "\n\n(fn MATCH)"] nil t] 8 (#$ . 991)]) #@329 Return the corresponding VALUE to the REGEX matching VAR. Return nil if no matching VALUE is found. VARIABLE-ALIST is a list of the form (REGEX . VARIABLE). This function modifies the `match-data': REGEX may contain captures, which may be accessed with regular (`match-string' VAR) or `match-data'. (fn VARIABLE-ALIST VAR) (defalias 'dap-variables--find-matching #[514 "\300\301\302\"\"A\207" [cl-find-if make-closure #[257 "\301@\300\"\207" [V0 string-match] 4 "\n\n(fn X)"]] 6 (#$ . 1576)]) #@224 Return all strings matched by the last search. The result is a list of strings, each of which is as if from `match-string'. If S is not nil, acquire the match texts from S and not from the current buffer. (fn &optional S) (defalias 'dap-variables--all-matches #[256 "\300\301\211\211\302\"\262\203B\262T\262\301\262\202\237\207" [1 nil match-string] 8 (#$ . 2084)]) #@635 Recursively walk TREE and call VAR-CB on all variables. The return value of a VAR-CB invocation is ignored. Special case: if TREE (or one of its subtrees) is cons whose `cdr' does not satisfy `listp' (e.g. '("foo" . "bar")), its `car' is left as is and its `cdr' is expanded recursively. Note that a dotted pair whose `cdr' is a list cannot be told from a list. So, '(4 5) and '(4 . (5)) are `equal'. As such, you should use plists when parsing from JSON. TREE can be a ...: - cons whose `cdr' does not satisfy `listp' - list (nil counts) - vector - keyword (:foo) - string - a hashmap Everything else is ignored. (fn VAR-CB TREE) (defalias 'dap-variables--walk-tree #[514 "\300!\203\207\211:\203\211A<\204\301A\"\207\211<\204#\302!\203+\303\304\301\"\"\207\211;\2035\305\"\207\306!\205B\307\310\311\"\"\207" [functionp dap-variables--walk-tree vectorp mapc apply-partially dap-variables--expand-in-string hash-table-p maphash make-closure #[514 "\301\300\"\210\301\300\"\207" [V0 dap-variables--walk-tree] 5 "\n\n(fn A B)"]] 6 (#$ . 2474)]) #@340 Recursively walk TREE, replacing all variables using VAR-CB. When a variable in a string is encountered, VAR-CB is called on it and the result used in its place. TREE is copied in the process. This function is similar to `dap-variables--walk-tree'. In particular, the walking rules and constraints on TREE are the same. (fn VAR-CB TREE) (defalias 'dap-variables--map-tree #[514 "\300!\203\207\211:\203\211A<\204\211@\301A\"B\207\211<\204&\302!\203?\303!\304\301\"\305\306\307$\205>\310\"\207\211;\203I\311\"\207\207" [functionp dap-variables--map-tree vectorp type-of apply-partially nil apply cl-mapcar cl-coerce dap-variables--expand-in-string] 11 (#$ . 3549)]) #@164 Look up VAR in VARIABLE-ALIST and call the result. The looked up value is called for side-effects only; this function always returns nil. (fn VARIABLE-ALIST VAR) (defalias 'dap-variables--call-alist-variable #[514 "\300\"\211\205\301\302\303!\"\210\207" [dap-variables--find-matching nil apply dap-variables--all-matches] 8 (#$ . 4248)]) #@151 The current list of expansion variables. See `dap-variables-standard-variables' for details. You can push to this to add new variables for expansion. (defvar dap-variables-current-variables nil (#$ . 4600)) #@73 Expand VAR by looking it up in VARIABLE-ALIST. (fn VARIABLE-ALIST VAR) (defalias 'dap-variables--expand-alist-variable #[514 "\300 \301\302\"\216\303\"\211\205!\304\305!\"\206!\306\307\310\311$\210\312\262)\207" [match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] dap-variables--find-matching dap-variables--eval-poly-type dap-variables--all-matches lwarn (dap-variables-expand-variable) :warning "variable ${%s} is nil here" ""] 9 (#$ . 4813)]) #@117 Expand VAR according to `dap-variables-current-variables'. This function may be used in nested variables. (fn VAR) (defalias 'dap-variables-expand-variable #[257 "\301\"\207" [dap-variables-current-variables dap-variables--expand-alist-variable] 4 (#$ . 5308)]) #@761 Non-destructively expand all variables in all strings of TREE. TREE is a recursive data-structure, whose constraints are described in `dap-variables--map-tree'. VARS has the form (REGEX . VALUE). During expansion, variables of the form ${var} get replaced by finding a matching REGEX and processing the value as in `dap-variables--eval-poly-type'. TREE is expanded in two stages: first, the tree is walked, with the set of variables being PRE-EXPAND-VARS. Their results are ignored. Then, all functions in POST-WALK-HOOK are called, with the original variable string encountered as arguments. They may introduce new variables by prepending (`cl-pushnew', `push') to `dap-variables-current-variables'. (fn TREE VARS &optional PRE-EXPAND-VARS POST-WALK-HOOK) (defalias 'dap-variables-expand-tree #[1026 "\203\f\301\302\303\"\"\210\304\305\"\210\306\307\")\207" [dap-variables-current-variables dap-variables--walk-tree apply-partially dap-variables--call-alist-variable mapc funcall dap-variables--map-tree dap-variables-expand-variable] 8 (#$ . 5580)]) #@65 Find the current buffer's project root using `project-current'. (defalias 'dap-variables--project-current-root #[0 "\300\301\302!A!\207" [directory-file-name project-current t] 3 (#$ . 6649)]) (byte-code "\300\301\302\303\304DD\305\306\307\310\311&\207" [custom-declare-variable dap-variables-project-root-function funcall function #[0 "\300\207" [dap-variables--project-current-root] 1] "Function to acquire the project root of the current buffer.\nThe function will be called with no arguments and shall return\nthe path to the project of the current buffer, without a trailing\nslash.\n\nUsed in project variables like ${workspaceFolder}. When using\n`dap-variables' as a library, this can be overridden using\n`let'." :group dap-variables :type (function)] 8) #@98 Find the current buffer's project root. Respects and uses `dap-variables-project-root-function'. (defalias 'dap-variables-project-root #[0 " \207" [dap-variables-project-root-function] 1 (#$ . 7420)]) #@52 Return the basename of the project root directory. (defalias 'dap-variables-project-basename #[0 "\300\301\302 !!\207" [file-name-nondirectory directory-file-name dap-variables-project-root] 3 (#$ . 7628)]) #@169 Return the path to FILE relative to the project root. The search for the project root starts at DIR. FILE defaults to variable `buffer-file-name'. (fn &optional FILE) (defalias 'dap-variables-project-relative-file #[256 "\301\206\302 \"\207" [buffer-file-name file-relative-name dap-variables-project-root] 4 (#$ . 7842)]) #@185 Return the path to the directory of file relative to the project root. The search for the project root starts at DIR. FILE defaults to variable `buffer-file-name' (fn &optional FILE) (defalias 'dap-variables-project-relative-dirname #[256 "\301\302\206!!\207" [buffer-file-name dap-variables-project-relative-file file-name-directory] 4 (#$ . 8177)]) #@69 Return the name of the current buffer's file without its directory. (defalias 'dap-variables-buffer-basename #[0 "\301!\207" [buffer-file-name file-name-nondirectory] 2 (#$ . 8539)]) #@69 Same as `dap-variables-buffer-basename', but without the extension. (defalias 'dap-variables-buffer-basename-sans-extension #[0 "\300\301 !\207" [file-name-sans-extension dap-variables-buffer-basename] 2 (#$ . 8729)]) #@184 Return the extension of the buffer's file with a leading dot. If there is either no file associated with the current buffer or if that file has no extension, return the empty string. (defalias 'dap-variables-buffer-extension #[0 "\300 \205\n\301\300 \302\"\207" [buffer-file-name file-name-extension t] 3 (#$ . 8954)]) #@47 Return the directory the buffer's file is in. (defalias 'dap-variables-buffer-dirname #[0 "\300\301 !\207" [file-name-directory buffer-file-name] 2 (#$ . 9280)]) #@98 Return the text selected in the current buffer. If no text is selected, return the empty string. (defalias 'dap-variables-buffer-selected-text #[0 "\300\301 `\"\207" [buffer-substring-no-properties mark] 3 (#$ . 9448)]) #@78 `getenv' VARIABLE; yield the empty string if it is undefined. (fn VARIABLE) (defalias 'dap-variables-getenv-or-empty #[257 "\300!\206\301\207" [getenv ""] 3 (#$ . 9674)]) (custom-declare-face 'dap-variables-pid-face '((t :inherit font-lock-function-name-face)) "Face process ids are shown in for ${command:pickProcess}.\nEach entry in that function consists of the process args followed\nby the PID, in parentheses (). Only the PID (not the parentheses)\nis shown with that face." :group 'dap-faces) #@162 Prompt the user to select a system process and return it. The return value is the process' PID, as an integer. If the user fails to select an entry, return nil. (defalias 'dap-variables-pick-process #[0 "\300 \211\301\211:\203 @\262\302\303!\304\305#B\262A\262\202\211\237\266\203\306\307\"\306\310\311\312\"\"\313\310\314\315\"#\313\316#\317\320\"\311\301\321%\207" [list-system-processes nil propertize number-to-string face dap-variables-pid-face mapcar process-attributes apply-partially alist-get args cl-mapcar format "%s (%s)" cons completing-read "Select a PID: " string=] 13 (#$ . 10185)]) #@155 Count the unique prompt numbers in PROMPTS. PROMPTS must have the form of `dap-variables-numbered-prompts' and it must be sorted by NUMBER. (fn PROMPTS) (defalias 'dap-variables--count-unique-numbered-prompts #[257 "\300C\301\302\303\"\"\207" [nil cl-count-if-not make-closure #[257 "\211@\300\242=\300\240\210\207" [V0] 5 "\n\n(fn PROMPT)"]] 6 (#$ . 10813)]) #@397 Mapping between numbered variables ${1} and their prompts. List of lists (NUMBER QUESTION VAR) where NUMBER is the number of the question (questions are asked in correct order), QUESTION is a prompt to be displayed to the user and VAR is the variable corresponding to the prompt. So if there is a variable ${1:hostname}, NUMBER would be 1, QUESTION would be hostname and VAR would be 1:hostname. (defvar dap-variables-numbered-prompts nil (#$ . 11185)) #@269 Implement a variable of the form ${num:question}. Register a question variable in `dap-variables-numbered-prompts'. VAR is the variable encountered, ID is the number associated with it and QUESTION is the string used to ask the user for a value. (fn VAR ID QUESTION) (defalias 'dap-variables--colon-prompt-var #[771 "\301!EB\211\207" [dap-variables-numbered-prompts string-to-number] 6 (#$ . 11645)]) #@65 History of the user's answers to variable prompts (${1:host?}). (defvar dap-variables-prompt-histories (make-hash-table :test 'equal) (#$ . 12058)) (byte-code "\301\300!\203\302>\204\302B\301\207" [savehist-additional-variables boundp dap-variables-prompt-histories] 2) #@274 Temporarily the history list during expansion of a prompting variable. To overcome the limitation of read-string's history having to always be a symbol, this variable is temporarily `let'-bound to the correct history list, as looked up in `dap-variables-prompt-histories'. (defvar dap-variables--temp-hist nil (#$ . 12342)) #@150 Ask the questions in `dap-variables-numbered-prompts'. Prepend the answers in the form of additional variables to `dap-variables-current-variables'. (defalias 'dap-variables--do-prompts #[0 "\304\305\"\306!\307\211\307\211\211\211\310:\203\214@\262\211A\262\242\262\211A\262\242\262@\262=\203@\311\312\313\314%\210\202h\262\315 \"\316\317\320\f$\307\302#\262\321\n #\210)\317\322\"B B\317\323\324!\"B\325 \"\203|\210\202\201\211 B\210A\262\211T\262\202\307\207" [dap-variables-numbered-prompts dap-variables-prompt-histories dap-variables--temp-hist dap-variables-current-variables sort #[514 "@@W\207" [] 4 "\n\n(fn A B)"] dap-variables--count-unique-numbered-prompts nil 1 lwarn (dap-variables-prompt) :error "multiple prompts for %d (in ${%s})" gethash read-string format "(%d/%d) %s: " puthash "\\`%d\\'" "\\`%s\\'" regexp-quote memql] 16 (#$ . 12673)]) #@130 Ask and reset the questions in `dap-variables-numbered-prompts'. For details, see `dap-variables--do-prompts'. (fn &optional _) (defalias 'dap-variables--do-prompts-reset #[256 "\300\216\301 )\207" [#[0 "\301\211\207" [dap-variables-numbered-prompts nil] 2] dap-variables--do-prompts] 2 (#$ . 13591)]) (byte-code "\300\301\302\303\304DD\305\306\307\310\311&\207" [custom-declare-variable dap-variables-standard-variables funcall function #[0 "\300\207" [(("\\`workspaceFolderBasename\\'" . dap-variables-project-basename) ("\\`workspaceFolder\\'" . dap-variables-project-root) ("\\`relativeFileDirname\\'" . dap-variables-project-relative-dirname) ("\\`relativeFile\\'" . dap-variables-project-relative-file) ("\\`fileBasenameNoExtension\\'" . dap-variables-buffer-basename-sans-extension) ("\\`fileBasename\\'" . dap-variables-buffer-basename) ("\\`fileDirname\\'" . dap-variables-buffer-dirname) ("\\`fileExtname\\'" . dap-variables-buffer-extension) ("\\`lineNumber\\'" . line-number-at-pos) ("\\`selectedText\\'" . dap-variables-buffer-selected-text) ("\\`file\\'" . buffer-file-name) ("\\`env:\\(.*\\)\\'" . dap-variables-getenv-or-empty) ("\\`\\$\\'" . "$") ("\\`command:pickProcess\\'" . dap-variables-pick-process))] 1] "Alist of (REGEX . VALUE) pairs listing variables usable in launch.json files.\nThis list is iterated from the top to bottom when expanding\nvariables in the strings of the selected launch configuration\n`dap-variables-expand-variable'.\n\nWhen a REGEX matches (`string-match'), its corresponding VALUE is\nevaluated as follows: if it is a function (or a quoted lambda),\nthat function is called with `funcall', and its result, which\nmust be a string, is used in place of the variable. The function\ngets the strings of all capture groups as arguments. Otherwise,\nif it is a symbol, the symbol's value is used the same way.\nLastly, if it is a string, the string is used as a replacement.\nIf no regex matches, the empty string is used as a replacement\nand a warning is issued.\n\nDo not push to this variable directly to add new ones; instead,\nuse `dap-variables-current-variables'." :type (alist :key-type string :value-type (choice integer string function)) :group dap-variables] 8) #@580 Functions to be run after first walking the launch configuration. When expanding a launch configuration, first `dap-variables-pre-expand-hook' is called. Then, the launch configuration is walked, visiting, but not expanding, all variables in `dap-variables-pre-expand-variables'. Then all functions in this list are called, with the launch configuration as their only argument. They shall return a list of additional variables of the form (REGEX . VALUE) (see `dap-variables-standard-variables'). All lists are concatenated and added to the list of variables used for expansion. (defvar dap-variables-post-walk-hook '(dap-variables--do-prompts-reset) (#$ . 15819)) #@305 Alist of (REGEX . FUNCTION) pairs listing pre-expansion variables. Before any expansion occurs, all variables matching REGEX have their corresponding FUNCTION called, with the variable as argument. Its result is ignored, but FUNCTION could initialize something for use in `dap-variables-post-walk-hook'. (defvar dap-variables-pre-expand-variables '(("\\`\\(\\([[:digit:]]+\\):\\(.*\\)\\)'" . dap-variables--colon-prompt-var)) (#$ . 16491)) #@119 List of functions to be run before a launch configuration is expanded. They take one argument: the run configuration. (defvar dap-variables-pre-expand-hook nil (#$ . 16938)) #@163 List of functions to be run after a launch configuration has been expanded. They take one argument: the run configuration, this time with all variables expanded. (defvar dap-variables-post-expand-hook nil (#$ . 17119)) #@429 Expand TREE using the user's set of variables. See `dap-variables-expand-tree' for details. Note that this function does not handle os-specific properties (e.g. "linux": ..., "macosx": ...) specially. Respects `dap-variables-standard-variables', `dap-variables-pre-expand-hook', `dap-variables-post-expand-hook', `dap-variables-post-walk-hook', `dap-variables-pre-expand-hook' and `dap-variables-post-expand-hook'. (fn TREE) (defalias 'dap-variables-standard-expand-tree #[257 "\303\304\"\210\305 \n$\211\303\306\"\210\207" [dap-variables-standard-variables dap-variables-pre-expand-variables dap-variables-post-walk-hook run-hook-with-args dap-variables-pre-expand-hook dap-variables-expand-tree dap-variables-post-expand-hook] 6 (#$ . 17345)]) #@168 Find a project-specific VSCode configuration file. ROOT specifies the root of the project to search for F; search for F in either ROOT/ or ROOT/.vscode/. (fn F ROOT) (defalias 'dap-variables-find-vscode-config #[514 "\300!\211P\300\301!Q\302\303D\"\207" [file-name-as-directory ".vscode" cl-find-if file-exists-p] 9 (#$ . 18105)]) #@274 Alist mapping system types to os-specific properties. See `dap-variables-elevate-os-properties'. Alist (SYSTEM-TYPE . PROP) which maps a given `system-type' to a property that should hold a plist of attributes that should be set for that platform only in the plist above. (defconst dap-variables-os-property-alist '((windows-nt . :windows) (gnu/linux . :linux) (darwin . :macos)) (#$ . 18450)) #@353 Replace properties with their platform-specific counterparts. VSCode often allows specifying some properties for some platforms only, so there could be a launch.json "linux" section listing some properties to set when debugging from Linux, .... Transform PLIST so that those sections are added (removing previous values) at the top-level. (fn PLIST) (defalias 'dap-variables-elevate-os-properties #[257 "\302!\303 \"A\304\" \211\2034\211@\211A\211@=\203&AA\262\210\202-\305\"\266A\266\202\202 \210\211\306\211\211:\203l\262\211A\262\242\262@\262@=\203^AA\262\202d\305\"\210AA\262\2029\266\307\"\207" [system-type dap-variables-os-property-alist cl-copy-list assoc plist-get cl--do-remf nil append] 11 (#$ . 18852)]) #@140 Handle PLIST as if it were a VSCode *.json item. `dap-variables-elevate-os-properties' + `dap-variables-standard-expand-tree'. (fn PLIST) (defalias 'dap-variables-expand #[257 "\300\301!!\207" [dap-variables-standard-expand-tree dap-variables-elevate-os-properties] 4 (#$ . 19620)]) (provide 'dap-variables)