Function: prolog-build-prolog-command
prolog-build-prolog-command is a byte-compiled function defined in
prolog.el.gz.
Signature
(prolog-build-prolog-command COMPILEP FILE BUFFERNAME &optional FIRST-LINE)
Documentation
Make Prolog command for FILE compilation/consulting.
If COMPILEP is non-nil, consider compilation, otherwise consulting.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/prolog.el.gz
(defun prolog-build-prolog-command (compilep file buffername
&optional first-line)
"Make Prolog command for FILE compilation/consulting.
If COMPILEP is non-nil, consider compilation, otherwise consulting."
(let* ((compile-string
;; FIXME: If the process is not running yet, the auto-detection of
;; prolog-system won't help here, so we should make sure
;; we first run Prolog and then build the command.
(if compilep (prolog-compile-string) (prolog-consult-string)))
(module (prolog-buffer-module))
(file-name (concat "'" (prolog-bsts file) "'"))
(module-name (if module (concat "'" module "'")))
(module-file (if module
(concat module-name ":" file-name)
file-name))
strbeg strend
(lineoffset (if first-line
(- first-line 1)
0)))
;; Assure that there is a buffer name
(if (not buffername)
(error "The buffer is not saved"))
(if (not (string-match "\\`'.*'\\'" buffername)) ; Add quotes
(setq buffername (concat "'" buffername "'")))
(while (string-match "%m" compile-string)
(setq strbeg (substring compile-string 0 (match-beginning 0)))
(setq strend (substring compile-string (match-end 0)))
(setq compile-string (concat strbeg module-file strend)))
;; FIXME: The code below will %-expand any %[fbl] that appears in
;; module-file.
(while (string-match "%f" compile-string)
(setq strbeg (substring compile-string 0 (match-beginning 0)))
(setq strend (substring compile-string (match-end 0)))
(setq compile-string (concat strbeg file-name strend)))
(while (string-match "%b" compile-string)
(setq strbeg (substring compile-string 0 (match-beginning 0)))
(setq strend (substring compile-string (match-end 0)))
(setq compile-string (concat strbeg buffername strend)))
(while (string-match "%l" compile-string)
(setq strbeg (substring compile-string 0 (match-beginning 0)))
(setq strend (substring compile-string (match-end 0)))
(setq compile-string (concat strbeg (format "%d" lineoffset) strend)))
(concat compile-string "\n")))