;ELC ;;; Compiled ;;; in Emacs version 26.3 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. ;;; This file does not contain utf-8 non-ASCII characters, ;;; and so can be loaded in Emacs versions earlier than 23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defconst ediprolog-version "2.1") (byte-code "\300\301\302\303\304\305\304\306&\210\307\310\311\312\304\301\313\314&\210\307\315\316\317\304\301\313\320&\210\307\321\302\322\304\301\313\323&\210\307\324\325\326\304\301\313\320&\210\307\327\330\331\304\301\313\332&\207" [custom-declare-group ediprolog nil "Transparent interaction with Prolog." :group languages processes custom-declare-variable ediprolog-system 'scryer "Prolog system that is used for interaction." :type (choice (const :tag "Scryer Prolog" :value scryer) (const :tag "SWI Prolog" :value swi)) ediprolog-program (or (executable-find "scryer-prolog") (executable-find "swipl") "scryer-prolog") "Program name of the Prolog executable." string ediprolog-program-switches "List of switches passed to the Prolog process. Example:\n'(\"-G128M\" \"-O\")" (repeat string) ediprolog-prefix "%@ " "String to prepend when inserting output from the Prolog\nprocess into the buffer." ediprolog-max-history 80000 "Maximal size of history buffers storing recent interactions, or\nnil to never truncate the history." sexp] 8) #@19 A Prolog process. (defvar ediprolog-process nil (#$ . 1493)) #@47 Buffer that temporarily saves process output  (defvar ediprolog-temp-buffer nil (#$ . 1560)) #@64 Whether a prompt was (recently) emitted by the Prolog process. (defvar ediprolog-seen-prompt nil (#$ . 1659)) #@64 Whether the Prolog process waits for the user to enter a term. (defvar ediprolog-read-term nil (#$ . 1775)) #@67 Any whitespace occurring before the most recently executed query. (defvar ediprolog-indent-prefix "" (#$ . 1889)) #@63 File name of a temporary file used for consulting the buffer. (defvar ediprolog-temp-file nil (#$ . 2009)) #@40 Buffer used to display consult output. (defvar ediprolog-consult-buffer "*ediprolog-consult*" (#$ . 2122)) #@37 Window used to show consult output. (defvar ediprolog-consult-window nil (#$ . 2235)) #@41 Buffer that stores recent interactions. (defvar ediprolog-history-buffer nil (#$ . 2327)) #@67 True iff waiting for the previous query was interrupted with C-g. (defvar ediprolog-interrupted nil (#$ . 2423)) #@36 Prompt used in the Prolog session. (defalias 'ediprolog-prompt #[nil "\301=\203\302\207\303\207" [ediprolog-system swi "?ediprolog- " "?- "] 2 (#$ . 2542)]) #@37 Evaluate FORMS and wait for prompt. (defalias 'ediprolog-wait-for-prompt-after '(macro . #[(&rest forms) "\301\302\303\304\305\306\"BBBB\207" [forms progn (setq ediprolog-seen-prompt nil) (ediprolog-ensure-buffer "temp") (with-current-buffer ediprolog-temp-buffer (let (buffer-read-only) (erase-buffer))) append ((while (not ediprolog-seen-prompt) (discard-input) (sit-for 0.1)))] 7 (#$ . 2708)])) #@68 Set `ediprolog-interrupted' if evaluation of FORM was interrupted. (defalias 'ediprolog-remember-interruption '(macro . #[(form) "\301\302\303BBB\207" [form condition-case nil ((quit (setq ediprolog-interrupted t)))] 4 (#$ . 3113)])) (defalias 'ediprolog-sentinel #[(proc str) "\305\306!!\205Hr\306!q\210\307\310!r q\210\311\216\nc\210\312\313\314\315#\203*\316\317!\210\202\320 +\321\322\323\324 \325\326O #\327\315#\210)\330\331\n\"\205G\315\211)\207" [proc #1=#:temp-buffer str status ediprolog-seen-prompt buffer-live-p process-buffer generate-new-buffer " *temp*" #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] search-backward "\n" nil t replace-match "" buffer-string ediprolog-log format "%s: %s.\n" current-time-string 4 -5 "green" string-match "^\\(?:finished\n\\|exited abnormally\\|killed\n\\)"] 6]) (defalias 'ediprolog-ensure-buffer #[(name) "\304\305\"\306\304\307\"!\310 J!?\205& \311\n!L\210r Jq\210\312 \210\313\211)*\207" [name var str buffer-read-only format "*ediprolog-%s*" intern "ediprolog-%s-buffer" buffer-live-p generate-new-buffer buffer-disable-undo t] 5]) (defalias 'ediprolog-log #[(str &optional col nl) "\306\307!\210rq\210\310db\210\311\312\n\203n\204\313\202\314 # \203-\315\f\316\317 D#\202.\fc\210)deZ\205KV\205Kee\320\245\\|+\207" [ediprolog-history-buffer buffer-read-only nl str s col ediprolog-ensure-buffer "history" nil format "%s%s" "\n" "" propertize face :background 2 size ediprolog-max-history] 5]) #@25 Start a Prolog process. (defalias 'ediprolog-run-prolog #[nil " B\306\307\310\311 \312\313O\n#\314\315#\210\3161\\\317\320\321!\210r\fq\210\317\322 \210*\323\324\325p\n$%\326%\327\"\210\330%\331\"\210&\332=\203I\333\307\334\335 \"!\210 ?\205X\336 \210\337\340!\210\202I0\202g\210\306\341\342\315#\210\343\344\")\207" [ediprolog-program ediprolog-program-switches args ediprolog-seen-prompt ediprolog-temp-buffer buffer-read-only ediprolog-log format "%s: starting: %S\n" current-time-string 4 -5 "green" t (error quit) nil ediprolog-ensure-buffer "temp" erase-buffer apply start-file-process "ediprolog" set-process-sentinel ediprolog-sentinel set-process-filter ediprolog-wait-for-prompt-filter swi ediprolog-send-string "set_prolog_flag(color_term, false), set_prolog_flag(toplevel_prompt, '%s').\n" ediprolog-prompt discard-input sit-for 0.1 "No prompt found." "red" error "No prompt from: %s" ediprolog-process ediprolog-system] 6 (#$ . 4622)]) #@55 Kill the Prolog process and run the process sentinel. (defalias 'ediprolog-kill-prolog #[nil "\301 \205\302!\207" [ediprolog-process ediprolog-running delete-process] 2 (#$ . 5591)]) (defalias 'ediprolog-show-consult-output #[(str) "r\305!q\210\306\307\310 \210\nc\210eb\210\311\312\307\306#\203$\313\224\313\225|\210\202)\314 )\315\316\n\"\206B\317\nG GX\205A\n \313\nGO\230)?\205V\320!\321\f\306\"\210\322\f\323 \324\245\"\207" [ediprolog-consult-buffer buffer-read-only str success ediprolog-consult-window get-buffer-create t nil erase-buffer re-search-forward "^[ ]*%.*\n" 0 buffer-string string-match "^[ ]*\\(?:%.*\\)?\\'" "true." display-buffer set-window-dedicated-p fit-window-to-buffer frame-height 2] 4]) #@61 Filter used when consulting a file, showing consult output. (defalias 'ediprolog-consult-filter #[(proc str) "r\304!q\210db\210\305\nc\210)r\306!q\210\307\n!\210)\310\311\312\313\314 !\"\305\315#\2031r\306!q\210\315)\316\305x\210\317e`{!)\207" [proc buffer-read-only str ediprolog-seen-prompt ediprolog-temp-buffer nil process-buffer ediprolog-log re-search-backward format "^%s" regexp-quote ediprolog-prompt t "\n" ediprolog-show-consult-output] 5 (#$ . 6332)]) #@46 Filter that only waits until prompt appears. (defalias 'ediprolog-wait-for-prompt-filter #[(proc str) "r\304!q\210db\210\305\nc\210)r\306!q\210\307\n!\210)\310\311\312\313\314 !\"\305\315#\2052r\306!q\210\315\211))\207" [proc buffer-read-only str ediprolog-seen-prompt ediprolog-temp-buffer nil process-buffer ediprolog-log re-search-backward format "^%s" regexp-quote ediprolog-prompt t] 5 (#$ . 6808)]) #@741 Load current buffer into Prolog or post query (Do What I Mean). If invoked on a line starting with `:-' or `?-', possibly preceded by `%' and whitespace, call `ediprolog-interact' with the query as argument. Otherwise, call `ediprolog-consult'. With prefix argument 0, kill the Prolog process. With prefix 1, equivalent to `ediprolog-consult'. With prefix 2, equivalent to `ediprolog-consult' with a new Prolog process. With prefix 7, equivalent to `ediprolog-toplevel'. With just C-u, first call `ediprolog-consult' and then, if point is on a query, call `ediprolog-interact' with it as argument. Analogously, C-u C-u for `ediprolog-consult' with a new process. With other prefix arguments, equivalent to `ediprolog-remove-interactions'. (defalias 'ediprolog-dwim #[(&optional arg) "\301=\203\302 \204\303\304!\210\305 \210\306\307!\207\310=\203\311 \207\312=\203)\311\313!\207\314=\203;\315 \2048\303\316!\210\317 \207\320\232\203G\311 \210\321 \207\322\232\203T\311\313!\210\321 \207\204a\321 ?\205c\311 \207\323 \207" [arg 0 ediprolog-running error "No Prolog process running" ediprolog-kill-prolog message "Prolog process killed." 1 ediprolog-consult 2 t 7 ediprolog-more-solutions "No query in progress" ediprolog-toplevel (4) ediprolog-query (16) ediprolog-remove-interactions] 2 (#$ . 7226) "P"]) #@51 Error if the previous query is still in progress. (defalias 'ediprolog-process-ready #[nil "\203\301 \203\302 \203\303\304!\210\305\211\207" [ediprolog-interrupted ediprolog-running ediprolog-more-solutions error "Previous query still in progress, see `ediprolog-toplevel'" nil] 2 (#$ . 8558)]) #@71 If point is on a query, send it to the process and start interaction. (defalias 'ediprolog-query #[nil "\306 \210\205 ?\205o\212\307 \210\310\311!)\205o\312\313!\314\225b\315\316\317\320#\203/`\321\317x\\\2022\322\323!\324 \f\"\325\326!\205H\325\327!\205H\320\326 B!\317\210\330\n\"\261\210\331\332\333\334\335\336 \337\"\340#\"!\210!\203m\327!A!\210,\320\207" [transient-mark-mode mark-active ediprolog-indent-prefix from to query ediprolog-process-ready beginning-of-line looking-at "\\([ ]*\\)%*[ ]*[:?]- *" match-string 1 0 re-search-forward "\\.[ ]*\\(?:%.*\\)?$" nil t " " error "Missing `.' at the end of this query" buffer-substring-no-properties fboundp prepare-change-group undo-amalgamate-change-group "\n" ediprolog-interact format "%s\n" mapconcat identity split-string "\n[ %]*" " " handle ediprolog-prefix] 8 (#$ . 8867)]) #@278 Send QUERY to Prolog process and interact as on a terminal. You can use \[keyboard-quit] to unblock Emacs in the case of longer-running queries. When the query completes and the toplevel asks for input, use \[ediprolog-toplevel] to resume interaction with the Prolog process. (defalias 'ediprolog-interact #[(query) "\306 \204\307 \210\310!`\311\223\210\312p\"\210\313\314\"\210\315\316!\210r q\210\311\317 \210*\311\211\320 !\210\321 \207" [ediprolog-process ediprolog-temp-buffer buffer-read-only ediprolog-seen-prompt ediprolog-read-term query ediprolog-running ediprolog-run-prolog process-mark nil set-process-buffer set-process-filter ediprolog-interact-filter ediprolog-ensure-buffer "temp" erase-buffer ediprolog-send-string ediprolog-toplevel] 4 (#$ . 9737)]) #@43 Send string to Prolog process and log it. (defalias 'ediprolog-send-string #[(str) "\302\303\"\210\304 \"\207" [str ediprolog-process ediprolog-log "cyan" process-send-string] 3 (#$ . 10521)]) #@228 Start or resume Prolog toplevel interaction in the buffer. You can use this function if you have previously quit (with \[keyboard-quit]) waiting for a longer-running query and now want to resume interaction with the toplevel. (defalias 'ediprolog-toplevel #[nil "\203\f\306\307\310!!!\210\3111\247\312 \205\245\313\211\312 \203\213\n\204\213\314!b\210 \203<\315\316!\317P\320\n\f #\210\313\202\3211\200\"\322Y\203O\323\313\211\324#\202r\3252f\326\327\313\330#\211#$B$\331\216\323 +0\211%\325=?\205q%)\211\205|\332 !\2110\202\207\210\333\334!\210\335 \210\202\312 \203\241 \336=\203\235\337!\210\202\241\340\n!\210*\2020\207\210\341\211&\207" [ediprolog-process char str ediprolog-read-term ediprolog-indent-prefix ediprolog-prefix select-window display-buffer process-buffer (quit) ediprolog-more-solutions nil process-mark read-string "Input: " "\n" ediprolog-insert-at-marker (error) 22 read-char 0.1 #1=#:timeout run-with-timer 0.1 #[nil "\300\301\211\"\207" [throw #1#] 3] #[nil "\301!\207" [-with-timeout-timer- cancel-timer] 2] char-to-string message "Non-character key" discard-input 3 interrupt-process ediprolog-send-string t emacs-major-version -with-timeout-timer- with-timeout-timers -with-timeout-value- ediprolog-interrupted] 5 (#$ . 10723) nil]) #@151 Remove all lines starting with `ediprolog-prefix' from buffer. In transient mark mode, if the region is active, the function operates on the region. (defalias 'ediprolog-remove-interactions #[nil "\212\214\203 \203\303 \304 }\210eb\210\305\306\307\n!P!\210*\310\311!\207" [transient-mark-mode mark-active ediprolog-prefix region-beginning region-end flush-lines "^[ ]*" regexp-quote message "Interactions removed."] 4 (#$ . 12032) nil]) #@337 Buffer is loaded into a Prolog process. If NEW-PROCESS is non-nil, start a new process. Otherwise use the existing process, if any. In case of errors, point is moved to the position of the first error, and the mark is left at the previous position. In transient mark mode, if the region is active, the function operates on the region. (defalias 'ediprolog-consult #[(&optional new-process) "\306 \230\203 \307\310!\210\311 !\203!\3121\313 !0\202 \210\202!\210\314!\203+\315!\210\n\2032\316 \210\317 \204:\320 \210\321 \210\322 p\"\210\f\203T \203X\323\f!\323 !\232\204X\324\325!4\203g5\203g\326 \202he4\203w5\203w\327 \202xd67\33076\f\331\332%\210*\333 \334\"\210\3351\312\3318\336\337!\210r9q\210\331:\340 \210*\341\342\343\344\345!\203\262\345\f!\202\263\f\"!\2108?\205\306\346 \210\347\350!\210\202\2660\202\317\210\351\211;\210\352\3534\203\3405\203\340\354\202\341\355\"\210r9q\210\212eb\210\356\357\331\351#)\205\372\360\361\362!!)\211<\205 `=4\2035\203\326 \202eb\210\363=!\210)