From: Eshel Yaron Date: Sat, 3 Dec 2022 16:09:18 +0000 (+0200) Subject: ADDED: ability to pass command line args directly to swipl X-Git-Tag: V9.0.1~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7439d4ca1236c5f0f035398fc388423a19e5cb2d;p=dict.git ADDED: ability to pass command line args directly to swipl * sweeprolog.el (sweeprolog-handle-command-line-args): new function, sets up command line argument handling using... (sweeprolog-command-line-function): new function. --- diff --git a/sweeprolog.el b/sweeprolog.el index 4bf303b..df231b9 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -51,6 +51,8 @@ (defvar sweeprolog-top-level-signal-goal-history nil) +(defvar sweeprolog--extra-init-args nil) + (defvar sweeprolog-insert-term-functions '(sweeprolog-maybe-insert-next-clause sweeprolog-maybe-define-predicate) @@ -284,6 +286,7 @@ inserted to the input history in `sweeprolog-top-level-mode' buffers." "--no-signals" "-g" "create_prolog_flag(sweep,true,[access(read_only),type(boolean)])" + "-l" (expand-file-name "sweep.pl" sweeprolog--directory)) @@ -565,7 +568,9 @@ extra initialization arguments." (unless sweeprolog--initialized (apply #'sweeprolog-initialize (cons (or sweeprolog-swipl-path (executable-find "swipl")) - (append sweeprolog-init-args args))) + (append sweeprolog-init-args + (append sweeprolog--extra-init-args + args)))) (setq sweeprolog--initialized t) (sweeprolog-setup-message-hook))) @@ -4218,6 +4223,26 @@ propely." :group 'sweeprolog) +;;;; Command line argument handling + +(defun sweeprolog-command-line-function () + (when (string= argi "--swipl-args") + (let ((current-arg nil) + (swipl-args nil) + (go t)) + (while (and go command-line-args-left) + (setq current-arg (car command-line-args-left)) + (setq command-line-args-left (cdr command-line-args-left)) + (if (string= current-arg ";") + (setq go nil) + (push current-arg swipl-args))) + (setq sweeprolog--extra-init-args (reverse swipl-args))))) + +;;;###autoload +(defun sweeprolog-handle-command-line-args () + (add-to-list 'command-line-functions + #'sweeprolog-command-line-function)) + ;;;; Footer (provide 'sweeprolog)