aboutsummaryrefslogtreecommitdiffhomepage
path: root/coq/coq-system.el
diff options
context:
space:
mode:
Diffstat (limited to 'coq/coq-system.el')
-rw-r--r--coq/coq-system.el62
1 files changed, 41 insertions, 21 deletions
diff --git a/coq/coq-system.el b/coq/coq-system.el
index 8da4ea23..93c9dd7e 100644
--- a/coq/coq-system.el
+++ b/coq/coq-system.el
@@ -1,9 +1,18 @@
-;; coq-system.el --- common part of compilation feature
-;; Copyright (C) 2015 LFCS Edinburgh.
+;;; coq-system.el --- common part of compilation feature
+
+;; This file is part of Proof General.
+
+;; Portions © Copyright 1994-2012 David Aspinall and University of Edinburgh
+;; Portions © Copyright 2003, 2012, 2014 Free Software Foundation, Inc.
+;; Portions © Copyright 2001-2017 Pierre Courtieu
+;; Portions © Copyright 2010, 2016 Erik Martin-Dorel
+;; Portions © Copyright 2011-2013, 2016-2017 Hendrik Tews
+;; Portions © Copyright 2015-2017 Clément Pit-Claudel
+
;; Authors: Hendrik Tews, Pierre Courtieu
-;; License: GPL (GNU GENERAL PUBLIC LICENSE)
;; Maintainer: Pierre.Courtieu<Pierre.Courtieu@cnam.fr>
-;;
+
+;; License: GPL (GNU GENERAL PUBLIC LICENSE)
;;; Commentary:
;;
@@ -12,6 +21,8 @@
;; support for older versions of coq.
;;
+;;; Code:
+
(require 'proof)
(eval-when-compile
@@ -22,8 +33,17 @@
(defvar coq-prog-args)
(defvar coq-debug))
+;; Arbitrary arguments can already be passed through _CoqProject.
+;; However this is not true for all assistants, so we don't modify the
+;; (defpgcustom prog-args) declaration.
+(defun coq--string-list-p (obj)
+ "Determine if OBJ is a list of strings."
+ (or (null obj) (and (consp obj) (stringp (car obj)) (coq--string-list-p (cdr obj)))))
+
+(put 'coq-prog-args 'safe-local-variable #'coq--string-list-p)
+
(defcustom coq-prog-env nil
- "List of environment settings d to pass to Coq process.
+ "List of environment settings to pass to Coq process.
On Windows you might need something like:
(setq coq-prog-env '(\"HOME=C:\\Program Files\\Coq\\\"))"
:group 'coq)
@@ -322,9 +342,9 @@ request compatibility handling of flags."
((or `(rec ,dir ,alias) `(,dir ,alias))
(list "-R" (expand-file-name dir) alias)))))
-(defun coq-include-options (load-path &optional current-directory pre-v85)
+(defun coq-include-options (loadpath &optional current-directory pre-v85)
"Build the base list of include options for coqc, coqdep and coqtop.
-The options list includes all entries from argument LOAD-PATH
+The options list includes all entries from argument LOADPATH
\(which should be `coq-load-path' of the buffer that invoked the
compilation) prefixed with suitable options and (for coq<8.5), if
`coq-load-path-include-current' is enabled, the directory base of
@@ -335,12 +355,12 @@ CURRENT-DIRECTORY should be an absolute directory name. It can be nil if
`coq-load-path-include-current' is nil.
A non-nil PRE-V85 flag requests compatibility handling of flags."
- (unless (coq-load-path-safep load-path)
+ (unless (coq-load-path-safep loadpath)
(error "Invalid value in coq-load-path"))
(when (and pre-v85 coq-load-path-include-current)
(cl-assert current-directory)
- (push current-directory load-path))
- (cl-loop for entry in load-path
+ (push current-directory loadpath))
+ (cl-loop for entry in loadpath
append (coq-option-of-load-path-entry entry pre-v85)))
(defun coq--options-test-roundtrip-1 (coq-project parsed pre-v85)
@@ -374,31 +394,31 @@ options of a few coq-project files does the right thing."
(coq--options-test-roundtrip "-R /test Test")
(coq--options-test-roundtrip "-I /test")))
-(defun coq-coqdep-prog-args (load-path &optional current-directory pre-v85)
+(defun coq-coqdep-prog-args (loadpath &optional current-directory pre-v85)
"Build a list of options for coqdep.
-LOAD-PATH, CURRENT-DIRECTORY, PRE-V85: see `coq-include-options'."
- (coq-include-options load-path current-directory pre-v85))
+LOADPATH, CURRENT-DIRECTORY, PRE-V85: see `coq-include-options'."
+ (coq-include-options loadpath current-directory pre-v85))
-(defun coq-coqc-prog-args (load-path &optional current-directory pre-v85)
+(defun coq-coqc-prog-args (loadpath &optional current-directory pre-v85)
"Build a list of options for coqc.
-LOAD-PATH, CURRENT-DIRECTORY, PRE-V85: see `coq-include-options'."
+LOADPATH, CURRENT-DIRECTORY, PRE-V85: see `coq-include-options'."
;; coqtop always adds the current directory to the LoadPath, so don't
;; include it in the -Q options.
(append (remove "-emacs" coq-prog-args)
(let ((coq-load-path-include-current nil)) ; Not needed in >=8.5beta3
- (coq-coqdep-prog-args coq-load-path current-directory pre-v85))))
+ (coq-coqdep-prog-args loadpath current-directory pre-v85))))
;;XXXXXXXXXXXXXX
;; coq-coqtop-prog-args is the user-set list of arguments to pass to
;; Coq process, see 'defpacustom prog-args' in pg-custom.el for
;; documentation.
-(defun coq-coqtop-prog-args (load-path &optional current-directory pre-v85)
+(defun coq-coqtop-prog-args (loadpath &optional current-directory pre-v85)
;; coqtop always adds the current directory to the LoadPath, so don't
;; include it in the -Q options. This is not true for coqdep.
"Build a list of options for coqc.
LOAD-PATH, CURRENT-DIRECTORY, PRE-V85: see `coq-coqc-prog-args'."
- (cons "-emacs" (coq-coqc-prog-args load-path current-directory pre-v85)))
+ (cons "-emacs" (coq-coqc-prog-args loadpath current-directory pre-v85)))
(defun coq-prog-args ()
"Recompute `coq-load-path' before calling `coq-coqtop-prog-args'."
@@ -407,8 +427,8 @@ LOAD-PATH, CURRENT-DIRECTORY, PRE-V85: see `coq-coqc-prog-args'."
(coq-coqtop-prog-args coq-load-path))
(defcustom coq-use-project-file t
- "If t, when opening a coq file read the dominating _CoqProject.
-If t, when a coq file is opened, Proof General will look for a
+ "If t, when opening a Coq file read the dominating _CoqProject.
+If t, when a Coq file is opened, Proof General will look for a
project file (see `coq-project-filename') somewhere in the
current directory or its parent directories. If there is one,
its contents are read and used to determine the arguments that
@@ -480,7 +500,7 @@ Returns a mixed list of option-value pairs and strings."
(arity (cdr (assoc switch coq--makefile-switch-arities))))
(push (coq--read-one-option-from-project-file switch arity raw-args) options)
(setq raw-args (nthcdr (or arity 0) raw-args))))
- options))
+ (nreverse options))) ; Order of options is important sometimes (Cf. #7980)
(defun coq--extract-prog-args (options)
"Extract coqtop arguments from _CoqProject options OPTIONS.