;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\207" [require python json] 2) #@225 Trim extra Python indentation from STR. STR is a string copied from Python code. It can be that each line of STR is prefixed by e.g. 4 or 8 or 12 spaces. Stripping them will produce code that's valid for an eval. (fn STR) (defalias 'lispy-trim-python #[257 "\300\301\"\203\302\303\"\304P\305\306\307\310#\"\207\207" [string-match "\\`\\( +\\)" match-string 1 "^" apply concat split-string t] 9 (#$ . 153)]) (defalias 'lispy-eval-python-bnd #[0 "\304\212\305 \203(\306\307 \310 \"\311V\203 \212\307 b\210\312\304x\210`)\202\"\307 \310 B\202\260\313!\2039\313 !\2039\314 \202\260\313\315!\203S`\212\316 \210\317\304w\210\320 A)B\211\262\202\260\320 \211\262\206\260n\203d\321 \202\260\322 \203n\321 \202\260\313\n!\204\206\323 \324 \"\203\202\325 \210\202\206\326\327!\210\330 \262\3311\225\332 0\210\202\226\210`Sf\333=\204\245\304f\334=\203\253\332 \210\202\226\211`\240\210\211)\207" [lispy-outline lispy-outline-header lispy-left lispy-right nil region-active-p count-lines region-beginning region-end 1 " " looking-at lispy--bounds-outline "@" forward-sexp "[ \n]" lispy-bounds-python-block lispy--bounds-c-toplevel lispy-bolp looking-back line-beginning-position backward-list error "Unexpected" lispy--bounds-dwim (error) backward-sexp 46 40] 4]) #@12 (fn BND) (defalias 'lispy-extended-eval-str #[257 "\300!\301\302\"\301\303\"\212Ab\210\211W\203A\304\305\306\307#\210\310\311!\312\230\203+T\262\202\310\311!\313\230\203:\211T\262\202\314\315!\210\202\316\313!\203b`\212\317\320!\210\321@`\"\322\323\324\321`\"#P)\262\202g\321@`\")\207" [lispy--string-dwim cl-count 40 41 re-search-forward "[()]" nil t match-string 0 "(" ")" error "Unexpected" lispy-after-string-p forward-sexp -1 buffer-substring-no-properties replace-regexp-in-string "[\\]*\n[ ]*" " "] 12 (#$ . 1447)]) (defalias 'lispy-eval-python-str #[0 "\300 \301\302!!\303\304\305#\207" [lispy-eval-python-bnd lispy-trim-python lispy-extended-eval-str replace-regexp-in-string "^ *#[^\n]+\n" ""] 6]) (defalias 'lispy-bounds-python-block #[0 "\212\300\301!\203\n\302u\210\303 )\203\\n\203\304\202`\305 ZT\305 \212\306 \210`\302\307\302w\210\310 \211\262\2035\211Ab\210\311 \210\300\312\313\"!\203G\266\202Nb\266\202X\314\224b\210\306 \210\202#`)B\207\300\301!\203g`T\202h`\212\302\210\302\315 \211\262\203y\211Ab\210\210\302\210`Sf\316>\203\234`Sf\317>\203\226\320 \210\302\210\202}\321\210\202}`)B\207" [looking-at " " nil python-info-beginning-of-block-p 0 line-beginning-position python-nav-end-of-block "\n " lispy--bounds-comment beginning-of-line format "[\n ]\\{%d,\\}\\(except\\|else\\|elif\\)" 1 lispy--bounds-string (92 40 44 91 123) (40 91 123) up-list 2] 8]) #@24 (fn &optional PLAIN) (defalias 'lispy-eval-python #[256 "\301\302 \"\211\203\211\303\232\204\304\305\306\307#!\207\304\305\306\307#!\207" [lispy-eval-error lispy--eval-python lispy-eval-python-str "" lispy-message replace-regexp-in-string "%" "%%"] 7 (#$ . 2889)]) (defvar lispy-python-proc nil nil) (make-variable-buffer-local 'lispy-python-proc) #@10 (fn X) (defalias 'lispy-set-python-process-action #[257 "\211:\203\n\211A\202*\301\302\303\304#\203%\305 \306\307\"\216\310\311\312\"!)\262\202*\313\314P!\211\207" [lispy-python-proc require mash-python nil t current-window-configuration make-closure #[0 "\301\300!\207" [V0 set-window-configuration] 2] get-buffer-process mash-make-shell mash-new-lispy-python lispy--python-proc "lispy-python-"] 6 (#$ . 3252)]) #@10 (fn X) (defalias 'lispy-short-process-name #[257 "\300\301\302!\"\205\303\304\302!\"\207" [string-match "^lispy-python-\\(.*\\)" process-name match-string 1] 5 (#$ . 3682)]) #@149 Associate a (possibly new) Python process to the current buffer. Each buffer can have only a single Python process associated with it at one time. (defalias 'lispy-set-python-process #[0 "\301\302\303\304\305 \"\"\306\307\310\311\312\313!\205\314!\315\316&\207" [lispy-python-proc delq nil mapcar #[257 "\300!\211\205\n\211B\207" [lispy-short-process-name] 4 "\n\n(fn X)"] process-list ivy-read "Process: " :action lispy-set-python-process-action :preselect process-live-p lispy-short-process-name :caller lispy-set-python-process] 10 (#$ . 3869) nil]) #@70 Nil if the Python middleware in "lispy-python.py" wasn't loaded yet. (defvar lispy--python-middleware-loaded-p nil (#$ . 4438)) #@23 (fn &optional NAME) (defalias 'lispy--python-proc #[256 "\211\206\305!\203\206\306\307!\305!\203\207\310\211\212eb\210\311\312!)\203.\313\314!\202;\315 !\203:\316 !\202; \317 \320\321\310\211$!\262+\210\310\322 \210\207" [lispy-python-proc python-shell-font-lock-enable inferior-python-mode-hook python-shell-interpreter lispy--python-middleware-loaded-p process-live-p "lispy-python-default" get-process nil looking-at "#!\\(?:/usr/bin/env \\)\\(.*\\)$" match-string-no-properties 1 file-exists-p expand-file-name python-shell-calculate-command get-buffer-process python-shell-make-comint lispy--python-middleware-load] 11 (#$ . 4572)]) #@12 (fn STR) (defalias 'lispy--python-eval-string-dwim #[257 "\211\301\211\302\303\"\"\266\203\262\304\305\"\306U\307\310\"\204\"\307\311\"\203X\312 \313\314\"\216\206G\315\301\316\307#)\266\203?\205G\317\320\321\"\316\"\322\232)\262\203X\320\323\324\325\"\"P\207\211\203r\307\326\"\203r\324\325\"\324\327\"\320\330$\207\307\331\"\203\215\324\325\"\332\333 \334\"@\335\320\336#Q\207\207" [inhibit-changing-match-data nil string-trim-left string-trim-right cl-count 10 0 string-match "\\`\\(\\(?:[., ]\\|\\sw\\|\\s_\\|[][]\\)+\\) += " "\\`\\(([^)]+)\\) *=[^=]" match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] "lp\\." t lispy--eval-python format "x=lp.is_assignment(\"\"\"%s\"\"\")\nprint (x)" "True" "\nprint (repr ((%s)))" match-string 1 "\\`\\([A-Z_a-z0-9]+\\|\\(?:([^)]+)\\)\\) in \\(.*\\)\\'" 2 "%s = list (%s)[0]\nprint ((%s))" "\\`def \\([a-zA-Z_0-9]+\\)\\s-*(\\s-*self" split-string python-info-current-defun "\\." "\n" "lp.rebind('%s', '%s')"] 10 (#$ . 5241)]) #@52 Eval STR as Python code. (fn STR &optional PLAIN) (defalias 'lispy--eval-python #[513 "\302\303\"\304U\2040\305!\262\306\307\"\203\310\311\312\313 \"\314\"\210\211\2030\306\315\"\2030\316\317\"\262\211\204B\306\320\"\204B\306\321\"\203J\322\323 \"\202\256\306\324\"\203\253\316\317\"\316\325\"\322\323 \"\326\327\326\314\306#)\266\203\203z\322\323 \"\266\204\202\256\204\206\330 !\266\204\202\256\310!\211\262\204\227\330 !\266\204\202\256\331\230\203\241\331\202\244\332PP\266\204\202\256\333\334!\306\335\"\203\302\310\336\337\340\341#\342Q\314\"\207\306\343\"\203\326\344\304\224\304\225\345$\210\211\326\207\211\331\232\203\340\346\331\207\347\326\314\306#)\266\203\203\350\351\332\"!@\306\352\"\203\316\317\"\262\210\310\311\353\"\314\"\207\354\326\314\306#)\266\203\203\"\211\326\207\337\355\332#\207" [inhibit-changing-match-data lispy-eval-error cl-count 10 0 lispy--python-eval-string-dwim string-match "__file__" lispy--eval-python format "__file__ = '%s'\n" buffer-file-name t "\\`return \\(.*\\)\\'" match-string 1 "\n .*\\'" "\"\"\"" python-shell-send-string-no-output lispy--python-proc "\\`\\([-\377[:nonascii:]]*\\)\n\\([^\n]*\\)\\'" 2 nil "SyntaxError:\\|error:" lispy-message "" "\n" error "unexpected" "SyntaxError: 'return' outside function\\'" "__return__ = None\n" replace-regexp-in-string "\\(^ *\\)return" #[257 "\300\301\"\302P\207" [match-string 1 "__return__ ="] 4 "\n\n(fn X)"] "\nprint (repr(__return__))" "^Traceback.*:" set-text-properties (face error) "(ok)" "^<\\(?:map\\|filter\\|generator\\) object" last split-string "\\`print (repr ((\\(.*\\))))\\'" "list(%s)" "SyntaxError:" "\\\\n"] 14 (#$ . 6287)]) #@79 Transform a Python string ARRAY-STR to an Elisp string array. (fn ARRAY-STR) (defalias 'lispy--python-array-to-elisp #[257 "\211;\205O\211\300\230?\205O\301\302\303\"r\211q\210\304\305\"\216\306 \210\307\310Oc\210eb\210\311\211`dW\203B`\262\312 \210\313`\"B\262\314\311w\210\202'\211\237\266\202*\262\315\316\"\262\207" ["" generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] python-mode 1 -1 nil forward-sexp buffer-substring-no-properties ", " mapcar #[257 "\300\301\"\203 \302!\207\300\303\"\203\304\305\"\207\207" [string-match "\\`\"" read "\\`'\\(.*\\)'\\'" match-string 1] 4 "\n\n(fn S)"]] 7 (#$ . 8015)]) (defalias 'lispy-python-symbol-bnd #[0 "\300\301!\206 ``B\212\211@b\210\302\303x\210\304\305!\2032\306u\210\302\303x\210\304\307!\203,\310\311!\210\202\310 \210\202\302\303w\210\211`\240\210)\207" [bounds-of-thing-at-point symbol " " nil lispy-after-string-p "." -1 ")" backward-sexp 2] 3]) (defalias 'lispy-python-completion-at-point #[0 "\300\301\302 \"\2034\303\302 `\"\304\305\211G#\306\307!!\310\311!\211\203$\211@\202%`\203.A\202/`E\207\312 \206z\313 \303@A\"\314\315\"\203i\304\316\317\320\225O\"\321\320\225\322OP\262\211@\320\225\\\240\266\307\323\"\266@A\324\325\326\327 \322#\"E\266\202\207" [looking-back "^\\(import\\|from\\) .*" line-beginning-position buffer-substring-no-properties format "import jedi; script=jedi.Script(\"%s\",1,%d); [_x_.name for _x_ in script.completions()]" lispy--python-array-to-elisp lispy--eval-python bounds-of-thing-at-point symbol lispy-complete-fname-at-point lispy-python-symbol-bnd string-match "\\()\\)[^)]*\\'" "__t__ = %s" 0 1 "__t__" nil t mapcar #[257 "\300\301\302\303\304\"\203\305\211\224O\202#\207" [replace-regexp-in-string "__t__" "" string-match "(\\'" 0] 7 "\n\n(fn S)"] python-shell-completion-get-completions lispy--python-proc] 10]) #@53 Constant regexp for matching function keyword spec. (defvar lispy--python-arg-key-re "\\`\\(\\(?:\\sw\\|\\s_\\)+\\) ?= ?\\(.*\\)\\'" (#$ . 9955)) #@16 (fn BEG END) (defalias 'lispy--python-args #[514 "\300\212b\210\301\300w\210`\262`W\2039\302 \210`W\203'\303\304!\204'\302 \210\202\305`\"B\262\306\300w\210`\262\202\f)\211\237\207" [nil "\n " forward-sexp looking-at "," buffer-substring-no-properties ", \n"] 6 (#$ . 10107)]) (defalias 'lispy--python-step-in-loop #[0 "\300\301!\205\302\303!\302\304!\305\306\307#\310\"\311!\266\203\207" [looking-at " ?for \\([A-Z_a-z,0-9 ()]+\\) in \\(.*\\):" match-string-no-properties 1 2 lispy--eval-python format "lp.list_step(\"%s\",%s)" t lispy-message] 7]) (defalias 'lispy--python-debug-step-in #[0 "\302 ?\205A\303\304!\203\305\306!\210\307\310\311 \"\210\312u\210`\212\305 \210`)\313\314x\210`\314\315 \210`Sf\316=\203:\317\262\315 \210\202)`\320\"\321TS\"\203[\322\323\"\203[\324\306\"B\202\\\211\325\326\"\327\"\330\331\332\333\"!\306\312O!\334\335\336\337\234\"\306\234\205\201\306\234C\"\335\340\341\234\"\342\343\334\344GGZ\314\"\"#\314\211\f\203\256\345\235\204\264\346B\262\202\264\347\350\"\262\262\211\203\317\211@\211A\262\242\241\210A\266\202\202\271\210\211\203\211@\322\"\203\324\306\"\324\351\"\314\352 \"\211\262\203\373\211\241\266\202 \353\354\n#\266\202 \353\355\"\210A\266\202\202\322\210\314\335\356\">\203!\353\357\"\210\360\361\362#\262\331\317\"\2038 b\210\363 !\207b\210\364 !\266\220\207" [lispy--python-arg-key-re lispy-eval-error lispy--python-step-in-loop looking-at " *(" forward-list 1 re-search-forward "(" line-end-position -1 " " nil backward-sexp 46 t buffer-substring-no-properties lispy--python-args string-match "\\`\\(.*?\\)\\.\\([^.]+\\)\\'" match-string cl-remove-if-not #[257 "\301\"\207" [lispy--python-arg-key-re string-match] 4 "\n\n(fn S)"] cl-set-difference json-read-from-string lispy--eval-python format "import inspect, json; json.dumps (inspect.getargspec (%s))" append mapcar identity 0 #[257 "\211\204\300\207\211\301=\203\302\207\303!\207" ["None" t "True" prin1-to-string] 3 "\n\n(fn X)"] 3 cl-mapcar cons make-list ("self") ("self") delete ("self") 2 assoc error "\"%s\" is not in %s" "\"%s\" does not match the regex spec" cdr "Not all args were provided: %s" mapconcat #[257 "\300\301@A#\207" [format "%s = %s"] 5 "\n\n(fn X)"] "; " lispy-goto-symbol message] 25]) #@15 (fn SYMBOL) (defalias 'lispy-goto-symbol-python #[257 "\214~\210\3001\301\302 !\206\3030\202\210\304\211\305\235\203Y\306 \307\310\311\312\303#!@P\313\314\315\"!\211\316\232\203;\317\304\303#\206T\211\203Q\320!\210eb\210\321!\210\322 \266\203\202d\323\324!\266\203\202d\325\326\327 \"?\205d\302 \262)\207" [(error) deferred:sync! jedi:goto-definition t nil (nil "Definition not found.") python-info-current-symbol "^\\(?:def\\|class\\).*" last split-string "\\." lispy--eval-python format "import inspect\nprint(inspect.getsourcefile(%s))" "None" re-search-backward find-file re-search-forward beginning-of-line error "Both jedi and inspect failed" looking-back "def " line-beginning-position] 9 (#$ . 12451)]) #@181 Look up the docstring for SYMBOL. First, try to see if SYMBOL.__doc__ returns a string in the current REPL session (dynamic). Otherwise, fall back to Jedi (static). (fn SYMBOL) (defalias 'lispy--python-docstring #[257 "\300\301P!\211G\302V\203\303\304\305\306\307O\310\"\311#\207\312\313!\210\314\315\316\317!!@\320\"\207" [lispy--eval-python ".__doc__" 0 mapconcat string-trim-left split-string 1 -1 "\\\\n" "\n" require jedi plist-get deferred:sync! jedi:call-deferred get_definition :doc] 8 (#$ . 13190)]) (defalias 'lispy-python-middleware-reload #[0 "\301\302 \207" [lispy--python-middleware-loaded-p nil lispy--python-middleware-load] 1 nil nil]) (defvar lispy-python-init-file "~/git/site-python/init.py") #@51 Load the custom Python code in "lispy-python.py". (defalias 'lispy--python-middleware-load #[0 "?\205,\304\305\306\307\310 \"\"!\211\203'\311\n!\203!\304\305\312\307\n!\"!\210\313\211\202*\314 !\262\207" [lispy--python-middleware-loaded-p lispy-site-directory lispy-python-init-file lispy-eval-error lispy--eval-python format "import imp;lp=imp.load_source('lispy-python','%s');__name__='__repl__'" expand-file-name "lispy-python.py" file-exists-p "exec (open ('%s').read(), globals ())" t lispy-message] 6 (#$ . 13917)]) #@36 (fn SYMBOL FILENAME LINE COLUMN) (defalias 'lispy--python-arglist #[1028 "\300 \210\301!\211\203\302\303\"\202\302\304$\305\301!!\302\306\307\310\311\312\"\313##\207" [lispy--python-middleware-load lispy--eval-python format "lp.arglist(%s)" "lp.arglist_jedi(%d, %d, '%s')" lispy--python-array-to-elisp "%s (%s)" mapconcat identity delete "self" ", "] 15 (#$ . 14452)]) (provide 'le-python)