[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5511be7: Add new files in ada-mode; package version not bu
From: |
Stephen Leake |
Subject: |
[elpa] master 5511be7: Add new files in ada-mode; package version not bumped |
Date: |
Wed, 16 Jan 2019 17:00:14 -0500 (EST) |
branch: master
commit 5511be7a40e4c02c1ea38f24c6ce92c5aee32a11
Author: Stephen Leake <address@hidden>
Commit: Stephen Leake <address@hidden>
Add new files in ada-mode; package version not bumped
* packages/ada-mode/ada-project.el: New file.
* packages/ada-mode/env-project.el: New file.
---
packages/ada-mode/ada-project.el | 81 ++++++++++++++++++++++++++++++++++++++++
packages/ada-mode/env-project.el | 70 ++++++++++++++++++++++++++++++++++
2 files changed, 151 insertions(+)
diff --git a/packages/ada-mode/ada-project.el b/packages/ada-mode/ada-project.el
new file mode 100644
index 0000000..e917ec3
--- /dev/null
+++ b/packages/ada-mode/ada-project.el
@@ -0,0 +1,81 @@
+;; ada-project.el - project.el backend for ada-mode projects -*-
lexical-binding: t =*-
+;;
+;; Copyright (C) 2017, 2018, 2019 Free Software Foundation, Inc.
+;;
+;; Author: Stephen Leake <address@hidden>
+;; Maintainer: Stephen Leake <address@hidden>
+;; Keywords: projects
+;; Version: 1.0.0
+;; package-requires: ((emacs "25.0"))
+;;
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+(require 'ada-mode)
+(require 'project-patches)
+(require 'env-project)
+(require 'uniquify-files)
+
+(cl-defstruct (ada-project
+ (:include env-project)
+ (:constructor nil) ;; no default
+ (:constructor make-ada-project
+ (&key
+ env-vars
+ ada-prj-file
+ &aux
+ (ada-prj (expand-file-name ada-prj-file))))
+ )
+ ada-prj
+ ;; The ada-mode project file name (absolute).
+ )
+
+(cl-defmethod project-id ((prj ada-project))
+ ;; project-id is experimental
+ (ada-project-ada-prj prj))
+
+(cl-defmethod project-library-roots ((prj ada-project))
+ ;; Called from project-find-file; result is passed to
+ ;; project--file-completion-table, where it is ignored.
+ nil)
+
+(cl-defmethod project-roots ((prj ada-project))
+ ;; Called from project-find-file; result is passed to
+ ;; project--file-completion-table, where it is ignored.
+ nil)
+
+(cl-defmethod project-file-completion-table ((prj ada-project) _dirs)
+ ;; (ada-prj-get 'src_dir) is more accurate than project-*roots
+ (let ((iter (make-path-iterator
+ :user-path-non-recursive (ada-prj-get 'src_dir)
+ :user-path-recursive nil
+ :ignore-function nil)))
+ (apply-partially #'uniq-file-completion-table iter)
+ ))
+
+(cl-defmethod project-select :after ((prj ada-project))
+ ;; :after ensures env-project project-select is run first, setting env vars.
+ (ada-select-prj-file (ada-project-ada-prj prj)))
+
+(cl-defmethod project-deselect :before ((prj ada-project))
+ ;; :before ensures env vars are not erased before we are done with them.
+ (ada-deselect-prj (ada-project-ada-prj prj)))
+
+(cl-defmethod project-refresh ((_prj ada-project))
+ ;; assume prj is current
+ (ada-refresh-prj-file))
+(provide 'ada-project)
+
+;; end of file
diff --git a/packages/ada-mode/env-project.el b/packages/ada-mode/env-project.el
new file mode 100644
index 0000000..53dc99b
--- /dev/null
+++ b/packages/ada-mode/env-project.el
@@ -0,0 +1,70 @@
+;;; env-project.el --- provide a root project type that holds a list of env
vars -*- lexical-binding:t -*-
+;;
+;; Copyright (C) 2017, 2019 Free Software Foundation, Inc.
+;;
+;; Author: Stephen Leake <address@hidden>
+;; Maintainer: Stephen Leake <address@hidden>
+;; Keywords: projects
+;; Version: 0
+;; package-requires: ((emacs "25.0"))
+;;
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+(require 'cl-lib)
+(require 'cl-generic)
+(require 'project)
+
+(eval-and-compile
+ (unless (fboundp 'refresh-project)
+ ;; In emacs 27
+
+ (cl-defgeneric project-refresh (prj)
+ "Refresh all cached data in PRJ.")
+
+ (defun refresh-project ()
+ (interactive)
+ (project-refresh (project-current)))
+
+ (cl-defgeneric project-select (prj)
+ "User has selected PRJ as the active project; take actions to make that
so."
+ (setq compilation-search-path
+ (append (project-roots prj)
+ (project-external-roots prj)))
+ )
+
+ (cl-defgeneric project-deselect (_prj)
+ "PRJ is the current project; user has selected another project.
+Undo actions done in `project-select'."
+ (setq compilation-search-path nil)
+ )
+ ))
+
+(cl-defstruct env-project
+ env-vars ;; a list of (NAME . VALUE)
+ )
+
+(cl-defmethod project-select :before ((prj env-project))
+ "Set the project env vars in ’process-environment’."
+ (dolist (pair (env-project-env-vars prj))
+ (setenv (car pair) (cdr pair))))
+
+(cl-defmethod project-deselect :after ((prj env-project))
+ "Unset the project env vars in ’process-environment’."
+ (dolist (pair (env-project-env-vars prj))
+ (setenv (car pair) nil)))
+
+(provide 'env-project)
+;; end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master 5511be7: Add new files in ada-mode; package version not bumped,
Stephen Leake <=