(cond
((listp prj-dir)
- (add-to-list 'prj-dir dir))
+ (cl-pushnew dir prj-dir :test #'equal))
(prj-dir
(setq prj-dir (list dir)))
project))
+(defun gnat-prj-show-path ()
+ "For `ada-prj-show-path'."
+ (interactive)
+ (if (ada-prj-get 'prj_dir)
+ (progn
+ (pop-to-buffer (get-buffer-create "*GNAT project search path*"))
+ (erase-buffer)
+ (dolist (file (ada-prj-get 'prj_dir))
+ (insert (format "%s\n" file))))
+ (message "no GNAT project search path files")
+ ))
+
(defun gnat-prj-parse-emacs-one (name value project)
"Handle gnat-specific Emacs Ada project file settings.
Return new PROJECT if NAME recognized, nil otherwise.
(kill-buffer (gnat-run-buffer-name))); things may have changed, force re-create
(if (ada-prj-get 'gpr_file project)
- (set 'project (gnat-parse-gpr (ada-prj-get 'gpr_file project) project))
+ (setq project (gnat-parse-gpr (ada-prj-get 'gpr_file project) project))
;; add the compiler libraries to src_dir
(setq project (gnat-get-paths project))
(defun gnat-get-paths-1 (src-dirs prj-dirs)
"Append list of source and project dirs in current gpr project to SRC-DIRS, PRJ-DIRS.
-Uses 'gnat list'. Returns new '(src-dirs prj-dirs)."
+Uses 'gnat list'. Returns new (SRC-DIRS PRJ-DIRS)."
(with-current-buffer (gnat-run-buffer)
;; gnat list -v -P can return status 0 or 4; always lists compiler dirs
;;
(forward-line 1)
(while (not (looking-at "^$")) ; terminate on blank line
(back-to-indentation) ; skip whitespace forward
- (if (looking-at "<Current_Directory>")
- (add-to-list 'src-dirs (directory-file-name default-directory))
- (add-to-list 'src-dirs
- (expand-file-name ; canonicalize path part
- (directory-file-name
- (buffer-substring-no-properties (point) (point-at-eol))))))
+ (cl-pushnew
+ (if (looking-at "<Current_Directory>")
+ (directory-file-name default-directory)
+ (expand-file-name ; Canonicalize path part.
+ (directory-file-name
+ (buffer-substring-no-properties (point) (point-at-eol)))))
+ src-dirs
+ :test #'equal)
(forward-line 1))
;; Project path
(while (not (looking-at "^$"))
(back-to-indentation)
(if (looking-at "<Current_Directory>")
- (add-to-list 'prj-dirs ".")
- (add-to-list 'prj-dirs
- (expand-file-name
- (buffer-substring-no-properties (point) (point-at-eol))))
- (add-to-list 'src-dirs
- (expand-file-name
- (buffer-substring-no-properties (point) (point-at-eol)))))
+ (cl-pushnew "." prj-dirs :test #'equal)
+ (let ((f (expand-file-name
+ (buffer-substring-no-properties (point) (point-at-eol)))))
+ (cl-pushnew f prj-dirs :test #'equal)
+ (cl-pushnew f src-dirs :test #'equal)))
(forward-line 1))
)
- ('error
+ (error
(pop-to-buffer (current-buffer))
;; search-forward failed
(error "parse gpr failed")
(let ((src-dirs (ada-prj-get 'src_dir project))
(prj-dirs (ada-prj-get 'prj_dir project)))
- ;; FIXME: use a dispatching function instead, to avoid "require" here,
- ;; which gives "warning: function not known".
+ ;; FIXME: use a dispatching function instead, with autoload, to
+ ;; avoid "require" here, which gives "warning: function not
+ ;; known".
;; Using 'require' at top level gives the wrong default ada-xref-tool
(cl-ecase (ada-prj-get 'xref_tool project)
- ((gnat gnat_inspect)
+ (gnat
(let ((res (gnat-get-paths-1 src-dirs prj-dirs)))
(setq src-dirs (car res))
(setq prj-dirs (cadr res))))
(gpr_query
- (require 'gpr-query)
- (setq src-dirs (gpr-query-get-src-dirs src-dirs))
- (setq prj-dirs (gpr-query-get-prj-dirs prj-dirs)))
+ (when (ada-prj-get 'gpr_file)
+ (require 'gpr-query)
+ (setq src-dirs (gpr-query-get-src-dirs src-dirs))
+ (setq prj-dirs (gpr-query-get-prj-dirs prj-dirs))))
)
(setq project (plist-put project 'src_dir (reverse src-dirs)))
)
buffer)))
+(defun ada-gnat-show-run-buffer ()
+ (interactive)
+ (pop-to-buffer (gnat-run-buffer)))
+
(defun gnat-run (exec command &optional err-msg expected-status)
"Run a gnat command line tool, as \"EXEC COMMAND\".
EXEC must be an executable found on `exec-path'.
;; need -f gnat stub option. We won't get here if there is an
;; existing body file.
(save-some-buffers t)
- (add-to-list 'opts "-f")
+ (cl-pushnew "-f" opts :test #'equal)
(with-current-buffer (gnat-run-buffer)
- ;; FIXME: gnat-run-buffer requires a project, but we don't
- ;; actually need one. Just use a temp buffer. Same for other
- ;; uses of gnat-run-no-prj.
(gnat-run-no-prj
(append (list "stub") opts (list start-file "-cargs") switches)
(file-name-directory body-file-name))