mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-20 12:40:56 -08:00
* grammars/c.by (template-type): Add :template-specifier and :typevar to capture extra details about the template. (opt-post-fcn-modifiers): Splice in the found symbol into the return value correctly. (QUESTION): New punctuation. (expression): Add ternary conditional support. * grammars/scheme.by (MODULE): New token. (scheme): Handle expanding the MODULE tag. (scheme-list): Remove closeparen required match. (scheme-in-list): Remove extraneous matches for DEFINE. Add support for MODULE Simplify matching for code & make work. (name-args, name-arg-list, name-arg-expand): Make it work. * semantic.el (semantic-mode): Add/remove 3 completion-at-point-functions. (semantic-completion-at-point-function): Removed. (semantic-analyze-completion-at-point-function) (semantic-analyze-notc-completion-at-point-function) (semantic-analyze-nolongprefix-completion-at-point-function): New completion at point functions. * semantic/doc.el (semantic-doc-snarf-comment-for-tag): Fix case when comment-end is empty string. * semantic/debug.el (semantic-debug-parser-debugger-source): New buffer local variable. (semantic-debug-interface): Add 'nil' initform to overlays. (semantic-debug-mode): Remove read-only tags from buffers on exit. (semantic-debug): Add autoload cookie. Force the language specific debugger to load. * semantic/db.el (generic::semanticdb-full-filename): New generic method to allow this method to be used on buffer names via an associated database. * semantic/symref.el (semantic-symref-cleanup-recent-buffers-fcn): When cleaning up buffers, don't clean up buffers that are being used (i.e., in a window) when the hook fires. (semantic-symref-recently-opened-buffers): New tracking variable. (semantic-symref-cleanup-recent-buffers-fcn): New hook fcn. (semantic-symref-result-get-tags): Move logic into `semantic-symref-hit-to-tag-via-buffer', and cleanup buffers via the symref cleanup function in post-command-hook. (semantic-symref-hit-to-tag-via-buffer): Logic that used to be from above. (semantic-symref-hit-to-tag-via-db): New. * semantic/analyze.el: (semantic-analyze-find-tag-sequence-default): If first entry in sequence is the only one, apply tagclass filter. (semantic-analyze-princ-sequence): Show slot even if empty. (semantic-analyze-find-tag-sequence) (semantic-analyze-find-tag-sequence-default): Add flags argument. Add support for forcing the final entry of the sequence to be of class variable. (semantic-analyze-find-tag): Fix bug where input class filter was ignored if there was a typecache match. (semantic-analyze-current-context-default): For assignments, the assignee now must be of class variable. * semantic/analyze/complete.el (semantic-analyze-possible-completions-default): Add 'no-longprefix' flag. When used, the prefix and prefixtypes are shortened to just the last symbol. * semantic/bovine/c.el (semantic-c-do-lex-if): Catch errors from 'hideif', and push to the parser warning stack. (semantic-lex-cpp-define): When a comment is at the end of a macro, do not subtract an extra 1 from the found position. Fixes bug with: #define foo (a)/**/ adding an extra ')' to the stream. * semantic/bovine/scm.el (semantic-lex-scheme-symbol): Allow symbols to be one char long. * semantic/bovine/grammar.el (bovine-grammar-calculate-source-on-path): New. (bovine-grammar-setupcode-builder): Use it. * ede.el (ede/detect): New require. (ede-version): Bump version (ede-initialize-state-current-buffer): Use new `ede-detect-directory-for-project' to detect projects first instead of depending on currente dir only. (ede-delete-project-from-global-list): New. (ede-flush-deleted-projects): Use above. (ede-check-project-query-fcn): New variable (ede-check-project-directory): Use above when querying the user. Added to support unit testing of this security measure. (ede-initialize-state-current-buffer): Use `ede-directory-project-cons' instead of the -detect- fcn to take advantage of the cache. Pass found project into `ede-load-project-file'. (ede-load-project-file): Add new input DETECTIN. (ede-rescan-toplevel): Get the proj root a better way. (ede-load-project-file): Return the loaded object. When asking for existing project, ask for an exact match. (ede-initialize-state-current-buffer): Simplify some conditional logic. (ede-load-project-file): Simplify conditional logic. (ede-global-list-sanity-check): New Testing fcn. (ede-parent-project): Replace old code with call to faster `ede-find-subproject-for-directory'. (ede-load-project-file): Use `ede-directory-get-toplevel-open-project' instead of above deleted. Rename "pfc" to "autoloader". Use `ede-directory-project-cons' to detect a project. Delete no project found case where we search up the tree. * ede/auto.el (ede-project-autoload): Fix doc typo. Add `:root-only' slot. (ede-auto-load-project): Doc update: warn to not use. (ede-dir-to-projectfile): Deleted. (ede-project-autoload-dirmatch): Add subdir-only slot. Make configdatastash unbound by default. (ede-do-dirmatch): If subdir-only is true, then don't allow exact matches. Account for configdatastash as unbound. Assume value of nil means no tool installed. Make sure loaded path matches from beginning. Stash the regexp, not the raw string. (ede-project-class-files): Note that makefile and automake are not root only. (ede-auto-detect-in-dir): New (for use with `ede/detect.el'). (ede-project-dirmatch-p): Deleted. (ede-project-root-directory): Remove body, return nil. (ede-project-autoload): :proj-root-dirmatch can be null & doc fix. (ede-auto-detect-in-dir): If there is no :proj-file, check for a dirmatch. * ede/generic.el (ede/config): Replace require of ede. (ede-generic-new-autoloader): Generic projects are now safe by default. Note this is NOT a root only project. (project-rescan, ede-project-root, ede-generic-target-java) (ede-java-classpath, ede-find-subproject-for-directory): New. (ede-enable-generic-projects): Add new autoloaders for git, bzr, hg, sv, CVS. (ede-generic-vc-project) (ede-generic-vc-project::ede-generic-setup-configuration): New. (ede-generic-config): Remove slots: c-include-path, c-preprocessor-table, c-preprocessor-files, classpath, build-command, debug-command, run command. Inherit from ede-extra-config-build, ede-extra-config-program. Make run-command :value match :custom so only strings are accepted. Add some more :group slot specifiers. (ede-generic-project): Add mixins `ede-project-with-config-c' and `ede-project-with-config-java'. Inherit from `ede-project-with-config-build', `ede-project-with-config-program'. Subclass `ede-project-with-config'. Remove duplication from new baseclass. (ede-generic-target): Inherit from `ede-target-with-config-build', `ede-target-with-config-program'. Subclass `ede-target-with-config'. (ede-generic-target-c-cpp): Add mixin `ede-target-with-config-c'. (ede-generic-target-java): Add mixin `ede-target-with-config-java'. (ede-preprocessor-map, ede-system-include-path) (edejava-classpath): Deleted, moved to config.el. (project-compile-project, project-compile-target) (project-debug-target, project-run-target): Deleted. (ede-generic-get-configuration, ede-generic-setup-configuration) (ede-commit-project, project-rescan) (ede-generic-project::ede-customize) (ede-generic-target::ede-customize) (ede-generic-config::eieio-done-customizing) (ede-generic-config::ede-commit): Deleted. Subsumed by new baseclass. (ede-preprocessor-map, ede-system-include-path) (project-debug-target, project-run-target): Call new `ede-config-get-configuration' instead of old version. (ede-generic-load): Do not add to global list here. * ede/files.el (ede-find-project-root) (ede-files-find-existing) (ede-directory-get-toplevel-open-project-new): Deleted. (ede-project-root-directory): Use `ede-project-root' first. (ede-project-directory-remove-hash) (ede--directory-project-from-hash) (ede--directory-project-add-description-to-hash): Rename to make internal symbols (via --). Expand input dir first. (ede-directory-project-p): Doc fix (note obsoleted.) (ede-toplevel-project-or-nil): Alias to `ede-toplevel-project'. (ede-toplevel-project): Doc Fix. Delete commented out old code. Simplify returning result from ede-detect-directory-for-project. (ede-directory-get-open-project): Support when inodes are disabled. If disabled to str compare on root project. (ede-directory-get-toplevel-open-project): Enabled nested projects. When doing directory name matching, save the 'short' version of an answer (non-exact match) and eventually select the shortest answer at the end. Expand the filename of tested projects. Better support for when inodes are disabled. Add 'exact' option so that it will return a project that is an exact match. (ede-find-subproject-for-directory): Small optimization to run `file-truename' less often. (ede-directory-project-p): Move content, then use `ede-directory-project-cons'. Use `ede-detect-directory-for-project', replacing old detection loop. (ede-directory-project-cons): New, from above. (ede-toplevel-project): Toss old scanning code. Use `ede-detect-directory-for-project' instead. (ede-directory-get-toplevel-open-project-new): New. * ede/linux.el (ede-linux-project-root): Deleted. (ede-project-autoload): Remove dirmatch entry - it is no longer needed. * lisp/cedet/ede/proj.el (project-rescan): Replace direct manipulation of `ede-projects' with equivalent and better functions. (ede-proj-load): Replace call to test if dir has project to explicity ask filesystem if Project.ede is there. * ede/config.el: * ede/detect.el: New files. * ede/project-am.el (project-run-target): Add "./" to program to run for systems where '.' isn't in PATH. (project-am-load): Remove old code regarding `ede-constructing'. Just read in the makefiles. * ede/linux.el (ede-linux-load): Do not add to global list here. Don't check for existing anymore. (project-rescan): New. (ede-linux-project-list, ede-linux-file-existing): Deleted. (ede-linux-project-root): Delete body. Need symbol for autoloads for now. (ede-linux-project): No longer instance tracker. (ede-project-autoload): Don't provide :proj-root * ede/emacs.el (ede-emacs-load): Do not add project to global list here. Don't look for existing first. (ede-project-autoload): Remove dirmatch entry - it is no longer needed. Don't provide proj-root anymore. (ede-emacs-project-list, ede-emacs-file-existing): Delete. (ede-emacs-project-root): Remove body (need symbol for loaddefs still). (ede-emacs-project): Do not instance track anymore. * ede/cpp-root.el (initialize-instance): Remove commented code. Add note about why we are adding the project to the master list. Make sure if we are replacing a prev version, remove from global list. (ede-cpp-root-file-existing) (ede-cpp-root-project-file-for-dir) (ede-cpp-root-count, ede-cpp-root-project-root, ede-cpp-root-load) (ede-project-autoload cpp-root): Deleted. (ede-project-root-directory): Return :directory instead of calculating from :file. (project-rescan): New. * ede/base.el (ede-toplevel): Only use buffer cached value if subproj not passed in. * srecode/java.el (srecode-semantic-handle-:java): Fix case when an EDE project didn't support java paths. * lisp/cedet/ede/proj-elisp.el (ede-proj-target-elisp::ede-proj-tweak-autoconf): Kill buffer after saving modified elisp-comp script, as to avoid "file has changed on disk; really edit the buffer" questions when script gets rewritten. * emacs-lisp/eieio-custom.el (eieio-customize-object): Set eieio-cog (current group) to g, which is an improved form of input group. * srecode/doc-cpp.srt (mode): Set to c mode so this works with both C and C++.
655 lines
22 KiB
EmacsLisp
655 lines
22 KiB
EmacsLisp
;;; ede/base.el --- Baseclasses for EDE.
|
||
|
||
;; Copyright (C) 2010-2014 Free Software Foundation, Inc.
|
||
|
||
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
||
|
||
;; 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/>.
|
||
|
||
;;; Commentary:
|
||
;;
|
||
;; Baseclasses for EDE.
|
||
;;
|
||
;; Contains all the base structures needed by EDE.
|
||
|
||
;;; Code:
|
||
(require 'eieio)
|
||
(require 'eieio-speedbar)
|
||
(require 'ede/auto)
|
||
|
||
;; Defined in ede.el:
|
||
(defvar ede-projects)
|
||
(defvar ede-object)
|
||
(defvar ede-object-root-project)
|
||
|
||
(declare-function data-debug-new-buffer "data-debug")
|
||
(declare-function data-debug-insert-object-slots "eieio-datadebug")
|
||
(declare-function ede-parent-project "ede" (&optional obj))
|
||
(declare-function ede-current-project "ede" (&optional dir))
|
||
|
||
;;; TARGET
|
||
;;
|
||
;; The TARGET is an entity in a project that knows about files
|
||
;; and features of those files.
|
||
|
||
(defclass ede-target (eieio-speedbar-directory-button)
|
||
((buttonface :initform speedbar-file-face) ;override for superclass
|
||
(name :initarg :name
|
||
:type string
|
||
:custom string
|
||
:label "Name"
|
||
:group (default name)
|
||
:documentation "Name of this target.")
|
||
;; @todo - I think this should be "dir", and not "path".
|
||
(path :initarg :path
|
||
:type string
|
||
;:custom string
|
||
;:label "Path to target"
|
||
;:group (default name)
|
||
:documentation "The path to the sources of this target.
|
||
Relative to the path of the project it belongs to.")
|
||
(source :initarg :source
|
||
:initform nil
|
||
;; I'd prefer a list of strings.
|
||
:type list
|
||
:custom (repeat (string :tag "File"))
|
||
:label "Source Files"
|
||
:group (default source)
|
||
:documentation "Source files in this target.")
|
||
(versionsource :initarg :versionsource
|
||
:initform nil
|
||
:type list
|
||
:custom (repeat (string :tag "File"))
|
||
:label "Source Files with Version String"
|
||
:group (source)
|
||
:documentation
|
||
"Source files with a version string in them.
|
||
These files are checked for a version string whenever the EDE version
|
||
of the master project is changed. When strings are found, the version
|
||
previously there is updated.")
|
||
;; Class level slots
|
||
;;
|
||
(sourcetype :allocation :class
|
||
:type list ;; list of symbols
|
||
:documentation
|
||
"A list of `ede-sourcecode' objects this class will handle.
|
||
This is used to match target objects with the compilers they can use, and
|
||
which files this object is interested in."
|
||
:accessor ede-object-sourcecode)
|
||
(keybindings :allocation :class
|
||
:initform (("D" . ede-debug-target))
|
||
:documentation
|
||
"Keybindings specialized to this type of target."
|
||
:accessor ede-object-keybindings)
|
||
(menu :allocation :class
|
||
:initform ( [ "Debug target" ede-debug-target
|
||
(ede-buffer-belongs-to-target-p) ]
|
||
[ "Run target" ede-run-target
|
||
(ede-buffer-belongs-to-target-p) ]
|
||
)
|
||
:documentation "Menu specialized to this type of target."
|
||
:accessor ede-object-menu)
|
||
)
|
||
"A target is a structure that describes a file set that produces something.
|
||
Targets, as with 'Make', is an entity that will manage a file set
|
||
and knows how to compile or otherwise transform those files into some
|
||
other desired outcome.")
|
||
|
||
;;; PROJECT/PLACEHOLDER
|
||
;;
|
||
;; Project placeholders are minimum parts of a project used
|
||
;; by the project cache. The project cache can refer to these placeholders,
|
||
;; and swap them out with the real-deal when that project is loaded.
|
||
;;
|
||
(defclass ede-project-placeholder (eieio-speedbar-directory-button)
|
||
((name :initarg :name
|
||
:initform "Untitled"
|
||
:type string
|
||
:custom string
|
||
:label "Name"
|
||
:group (default name)
|
||
:documentation "The name used when generating distribution files.")
|
||
(version :initarg :version
|
||
:initform "1.0"
|
||
:type string
|
||
:custom string
|
||
:label "Version"
|
||
:group (default name)
|
||
:documentation "The version number used when distributing files.")
|
||
(directory :type string
|
||
:initarg :directory
|
||
:documentation "Directory this project is associated with.")
|
||
(dirinode :documentation "The inode id for :directory.")
|
||
(file :type string
|
||
:initarg :file
|
||
:documentation "The File uniquely tagging this project instance.
|
||
For some project types, this will be the file that stores the project configuration.
|
||
In other projects types, this file is merely a unique identifier to this type of project.")
|
||
(rootproject ; :initarg - no initarg, don't save this slot!
|
||
:initform nil
|
||
:type (or null ede-project-placeholder-child)
|
||
:documentation "Pointer to our root project.")
|
||
)
|
||
"Placeholder object for projects not loaded into memory.
|
||
Projects placeholders will be stored in a user specific location
|
||
and querying them will cause the actual project to get loaded.")
|
||
|
||
;;; PROJECT
|
||
;;
|
||
;; An EDE project controls a set of TARGETS, and can also contain
|
||
;; multiple SUBPROJECTS.
|
||
;;
|
||
;; The project defines a set of features that need to be built from
|
||
;; files, in addition as to controlling what to do with the file set,
|
||
;; such as creating distributions, compilation, and web sites.
|
||
;;
|
||
;; Projects can also affect how EDE works, by changing what appears in
|
||
;; the EDE menu, or how some keys are bound.
|
||
;;
|
||
(defclass ede-project (ede-project-placeholder)
|
||
((subproj :initform nil
|
||
:type list
|
||
:documentation "Sub projects controlled by this project.
|
||
For Automake based projects, each directory is treated as a project.")
|
||
(targets :initarg :targets
|
||
:type ede-target-list
|
||
:custom (repeat (object :objectcreatefcn ede-new-target-custom))
|
||
:label "Local Targets"
|
||
:group (targets)
|
||
:documentation "List of top level targets in this project.")
|
||
(locate-obj :type (or null ede-locate-base-child)
|
||
:documentation
|
||
"A locate object to use as a backup to `ede-expand-filename'.")
|
||
(tool-cache :initarg :tool-cache
|
||
:type list
|
||
:custom (repeat object)
|
||
:label "Tool: "
|
||
:group tools
|
||
:documentation "List of tool cache configurations in this project.
|
||
This allows any tool to create, manage, and persist project-specific settings.")
|
||
(mailinglist :initarg :mailinglist
|
||
:initform ""
|
||
:type string
|
||
:custom string
|
||
:label "Mailing List Address"
|
||
:group name
|
||
:documentation
|
||
"An email address where users might send email for help.")
|
||
(web-site-url :initarg :web-site-url
|
||
:initform ""
|
||
:type string
|
||
:custom string
|
||
:label "Web Site URL"
|
||
:group name
|
||
:documentation "URL to this projects web site.
|
||
This is a URL to be sent to a web site for documentation.")
|
||
(web-site-directory :initarg :web-site-directory
|
||
:initform ""
|
||
:custom string
|
||
:label "Web Page Directory"
|
||
:group name
|
||
:documentation
|
||
"A directory where web pages can be found by Emacs.
|
||
For remote locations use a path compatible with ange-ftp or EFS.
|
||
You can also use TRAMP for use with rcp & scp.")
|
||
(web-site-file :initarg :web-site-file
|
||
:initform ""
|
||
:custom string
|
||
:label "Web Page File"
|
||
:group name
|
||
:documentation
|
||
"A file which contains the home page for this project.
|
||
This file can be relative to slot `web-site-directory'.
|
||
This can be a local file, use ange-ftp, EFS, or TRAMP.")
|
||
(ftp-site :initarg :ftp-site
|
||
:initform ""
|
||
:type string
|
||
:custom string
|
||
:label "FTP site"
|
||
:group name
|
||
:documentation
|
||
"FTP site where this project's distribution can be found.
|
||
This FTP site should be in Emacs form, as needed by `ange-ftp', but can
|
||
also be of a form used by TRAMP for use with scp, or rcp.")
|
||
(ftp-upload-site :initarg :ftp-upload-site
|
||
:initform ""
|
||
:type string
|
||
:custom string
|
||
:label "FTP Upload site"
|
||
:group name
|
||
:documentation
|
||
"FTP Site to upload new distributions to.
|
||
This FTP site should be in Emacs form as needed by `ange-ftp'.
|
||
If this slot is nil, then use `ftp-site' instead.")
|
||
(configurations :initarg :configurations
|
||
:initform ("debug" "release")
|
||
:type list
|
||
:custom (repeat string)
|
||
:label "Configuration Options"
|
||
:group (settings)
|
||
:documentation "List of available configuration types.
|
||
Individual target/project types can form associations between a configuration,
|
||
and target specific elements such as build variables.")
|
||
(configuration-default :initarg :configuration-default
|
||
:initform "debug"
|
||
:custom string
|
||
:label "Current Configuration"
|
||
:group (settings)
|
||
:documentation "The default configuration.")
|
||
(local-variables :initarg :local-variables
|
||
:initform nil
|
||
:custom (repeat (cons (sexp :tag "Variable")
|
||
(sexp :tag "Value")))
|
||
:label "Project Local Variables"
|
||
:group (settings)
|
||
:documentation "Project local variables")
|
||
(keybindings :allocation :class
|
||
:initform (("D" . ede-debug-target)
|
||
("R" . ede-run-target))
|
||
:documentation "Keybindings specialized to this type of target."
|
||
:accessor ede-object-keybindings)
|
||
(menu :allocation :class
|
||
:initform
|
||
(
|
||
[ "Update Version" ede-update-version ede-object ]
|
||
[ "Version Control Status" ede-vc-project-directory ede-object ]
|
||
[ "Edit Project Homepage" ede-edit-web-page
|
||
(and ede-object (oref (ede-toplevel) web-site-file)) ]
|
||
[ "Browse Project URL" ede-web-browse-home
|
||
(and ede-object
|
||
(not (string= "" (oref (ede-toplevel) web-site-url)))) ]
|
||
"--"
|
||
[ "Rescan Project Files" ede-rescan-toplevel t ]
|
||
[ "Edit Projectfile" ede-edit-file-target
|
||
(ede-buffer-belongs-to-project-p) ]
|
||
)
|
||
:documentation "Menu specialized to this type of target."
|
||
:accessor ede-object-menu)
|
||
)
|
||
"Top level EDE project specification.
|
||
All specific project types must derive from this project."
|
||
:method-invocation-order :depth-first)
|
||
|
||
;;; Important macros for doing commands.
|
||
;;
|
||
(defmacro ede-with-projectfile (obj &rest forms)
|
||
"For the project in which OBJ resides, execute FORMS."
|
||
`(save-window-excursion
|
||
(let* ((pf (if (obj-of-class-p ,obj ede-target)
|
||
(ede-target-parent ,obj)
|
||
,obj))
|
||
(dbka (get-file-buffer (oref pf file))))
|
||
(if (not dbka) (find-file (oref pf file))
|
||
(switch-to-buffer dbka))
|
||
,@forms
|
||
(if (not dbka) (kill-buffer (current-buffer))))))
|
||
(put 'ede-with-projectfile 'lisp-indent-function 1)
|
||
|
||
;;; The EDE persistent cache.
|
||
;;
|
||
;; The cache is a way to mark where all known projects live without
|
||
;; loading those projects into memory, or scanning for them each time
|
||
;; emacs starts.
|
||
;;
|
||
(defcustom ede-project-placeholder-cache-file
|
||
(locate-user-emacs-file "ede-projects.el" ".projects.ede")
|
||
"File containing the list of projects EDE has viewed.
|
||
If set to nil, then the cache is not saved."
|
||
:group 'ede
|
||
:type 'file)
|
||
|
||
(defvar ede-project-cache-files nil
|
||
"List of project files EDE has seen before.")
|
||
|
||
(defun ede-save-cache ()
|
||
"Save a cache of EDE objects that Emacs has seen before."
|
||
(interactive)
|
||
(when ede-project-placeholder-cache-file
|
||
(let ((p ede-projects)
|
||
(c ede-project-cache-files)
|
||
(recentf-exclude '( (lambda (f) t) ))
|
||
)
|
||
(condition-case nil
|
||
(progn
|
||
(set-buffer (find-file-noselect ede-project-placeholder-cache-file t))
|
||
(erase-buffer)
|
||
(insert ";; EDE project cache file.
|
||
;; This contains a list of projects you have visited.\n(")
|
||
(while p
|
||
(when (and (car p) (ede-project-p p))
|
||
(let ((f (oref (car p) file)))
|
||
(when (file-exists-p f)
|
||
(insert "\n \"" f "\""))))
|
||
(setq p (cdr p)))
|
||
(while c
|
||
(insert "\n \"" (car c) "\"")
|
||
(setq c (cdr c)))
|
||
(insert "\n)\n")
|
||
(condition-case nil
|
||
(save-buffer 0)
|
||
(error
|
||
(message "File %s could not be saved."
|
||
ede-project-placeholder-cache-file)))
|
||
(kill-buffer (current-buffer))
|
||
)
|
||
(error
|
||
(message "File %s could not be read."
|
||
ede-project-placeholder-cache-file))
|
||
|
||
))))
|
||
|
||
(defun ede-load-cache ()
|
||
"Load the cache of EDE projects."
|
||
(save-excursion
|
||
(let ((cachebuffer (get-buffer-create "*ede cache*")))
|
||
(condition-case nil
|
||
(with-current-buffer cachebuffer
|
||
(erase-buffer)
|
||
(when (file-exists-p ede-project-placeholder-cache-file)
|
||
(insert-file-contents ede-project-placeholder-cache-file))
|
||
(goto-char (point-min))
|
||
(let ((c (read (current-buffer)))
|
||
(new nil)
|
||
(p ede-projects))
|
||
;; Remove loaded projects from the cache.
|
||
(while p
|
||
(setq c (delete (oref (car p) file) c))
|
||
(setq p (cdr p)))
|
||
;; Remove projects that aren't on the filesystem
|
||
;; anymore.
|
||
(while c
|
||
(when (file-exists-p (car c))
|
||
(setq new (cons (car c) new)))
|
||
(setq c (cdr c)))
|
||
;; Save it
|
||
(setq ede-project-cache-files (nreverse new))))
|
||
(error nil))
|
||
(when cachebuffer (kill-buffer cachebuffer))
|
||
)))
|
||
|
||
;;; Get the cache usable.
|
||
|
||
;; @TODO - Remove this cache setup, or use this for something helpful.
|
||
;;(add-hook 'kill-emacs-hook 'ede-save-cache)
|
||
;;(when (not noninteractive)
|
||
;; ;; No need to load the EDE cache if we aren't interactive.
|
||
;; ;; This occurs during batch byte-compiling of other tools.
|
||
;; (ede-load-cache))
|
||
|
||
|
||
;;; METHODS
|
||
;;
|
||
;; The methods in ede-base handle project related behavior, and DO NOT
|
||
;; related to EDE mode commands directory, such as keybindings.
|
||
;;
|
||
;; Mode related methods are in ede.el. These methods are related
|
||
;; project specific activities not directly tied to a keybinding.
|
||
(defmethod ede-subproject-relative-path ((proj ede-project) &optional parent-in)
|
||
"Get a path name for PROJ which is relative to the parent project.
|
||
If PARENT is specified, then be relative to the PARENT project.
|
||
Specifying PARENT is useful for sub-sub projects relative to the root project."
|
||
(let* ((parent (or parent-in (ede-parent-project proj)))
|
||
(dir (file-name-directory (oref proj file))))
|
||
(if (and parent (not (eq parent proj)))
|
||
(file-relative-name dir (file-name-directory (oref parent file)))
|
||
"")))
|
||
|
||
(defmethod ede-subproject-p ((proj ede-project))
|
||
"Return non-nil if PROJ is a sub project."
|
||
;; @TODO - Use this in more places, and also pay attention to
|
||
;; metasubproject in ede/proj.el
|
||
(ede-parent-project proj))
|
||
|
||
|
||
;;; Default descriptive methods for EDE classes
|
||
;;
|
||
;; These are methods which you might want to override, but there is
|
||
;; no need to in most situations because they are either a) simple, or
|
||
;; b) cosmetic.
|
||
|
||
(defmethod ede-name ((this ede-target))
|
||
"Return the name of THIS target."
|
||
(oref this name))
|
||
|
||
(defmethod ede-target-name ((this ede-target))
|
||
"Return the name of THIS target, suitable for make or debug style commands."
|
||
(oref this name))
|
||
|
||
(defmethod ede-name ((this ede-project))
|
||
"Return a short-name for THIS project file.
|
||
Do this by extracting the lowest directory name."
|
||
(oref this name))
|
||
|
||
(defmethod ede-description ((this ede-project))
|
||
"Return a description suitable for the minibuffer about THIS."
|
||
(format "Project %s: %d subprojects, %d targets."
|
||
(ede-name this) (length (oref this subproj))
|
||
(length (oref this targets))))
|
||
|
||
(defmethod ede-description ((this ede-target))
|
||
"Return a description suitable for the minibuffer about THIS."
|
||
(format "Target %s: with %d source files."
|
||
(ede-name this) (length (oref this source))))
|
||
|
||
;;; HEADERS/DOC
|
||
;;
|
||
;; Targets and projects are often associated with other files, such as
|
||
;; header files, documentation files and the like. Have strong
|
||
;; associations can make useful user commands to quickly navigate
|
||
;; between the files based on their associations.
|
||
;;
|
||
(defun ede-header-file ()
|
||
"Return the header file for the current buffer.
|
||
Not all buffers need headers, so return nil if no applicable."
|
||
(if ede-object
|
||
(ede-buffer-header-file ede-object (current-buffer))
|
||
nil))
|
||
|
||
(defmethod ede-buffer-header-file ((this ede-project) buffer)
|
||
"Return nil, projects don't have header files."
|
||
nil)
|
||
|
||
(defmethod ede-buffer-header-file ((this ede-target) buffer)
|
||
"There are no default header files in EDE.
|
||
Do a quick check to see if there is a Header tag in this buffer."
|
||
(with-current-buffer buffer
|
||
(if (re-search-forward "::Header:: \\([a-zA-Z0-9.]+\\)" nil t)
|
||
(buffer-substring-no-properties (match-beginning 1)
|
||
(match-end 1))
|
||
(let ((src (ede-target-sourcecode this))
|
||
(found nil))
|
||
(while (and src (not found))
|
||
(setq found (ede-buffer-header-file (car src) (buffer-file-name))
|
||
src (cdr src)))
|
||
found))))
|
||
|
||
(defun ede-documentation-files ()
|
||
"Return the documentation files for the current buffer.
|
||
Not all buffers need documentations, so return nil if no applicable.
|
||
Some projects may have multiple documentation files, so return a list."
|
||
(if ede-object
|
||
(ede-buffer-documentation-files ede-object (current-buffer))
|
||
nil))
|
||
|
||
(defmethod ede-buffer-documentation-files ((this ede-project) buffer)
|
||
"Return all documentation in project THIS based on BUFFER."
|
||
;; Find the info node.
|
||
(ede-documentation this))
|
||
|
||
(defmethod ede-buffer-documentation-files ((this ede-target) buffer)
|
||
"Check for some documentation files for THIS.
|
||
Also do a quick check to see if there is a Documentation tag in this BUFFER."
|
||
(with-current-buffer buffer
|
||
(if (re-search-forward "::Documentation:: \\([a-zA-Z0-9.]+\\)" nil t)
|
||
(buffer-substring-no-properties (match-beginning 1)
|
||
(match-end 1))
|
||
;; Check the master project
|
||
(let ((cp (ede-toplevel)))
|
||
(ede-buffer-documentation-files cp (current-buffer))))))
|
||
|
||
(defmethod ede-documentation ((this ede-project))
|
||
"Return a list of files that provide documentation.
|
||
Documentation is not for object THIS, but is provided by THIS for other
|
||
files in the project."
|
||
(let ((targ (oref this targets))
|
||
(proj (oref this subproj))
|
||
(found nil))
|
||
(while targ
|
||
(setq found (append (ede-documentation (car targ)) found)
|
||
targ (cdr targ)))
|
||
(while proj
|
||
(setq found (append (ede-documentation (car proj)) found)
|
||
proj (cdr proj)))
|
||
found))
|
||
|
||
(defmethod ede-documentation ((this ede-target))
|
||
"Return a list of files that provide documentation.
|
||
Documentation is not for object THIS, but is provided by THIS for other
|
||
files in the project."
|
||
nil)
|
||
|
||
(defun ede-html-documentation-files ()
|
||
"Return a list of HTML documentation files associated with this project."
|
||
(ede-html-documentation (ede-toplevel))
|
||
)
|
||
|
||
(defmethod ede-html-documentation ((this ede-project))
|
||
"Return a list of HTML files provided by project THIS."
|
||
|
||
)
|
||
|
||
;;; Default "WANT" methods.
|
||
;;
|
||
;; These methods are used to determine if a target "wants", or could
|
||
;; somehow handle a file, or some source type.
|
||
;;
|
||
(defmethod ede-want-file-p ((this ede-target) file)
|
||
"Return non-nil if THIS target wants FILE."
|
||
;; By default, all targets reference the source object, and let it decide.
|
||
(let ((src (ede-target-sourcecode this)))
|
||
(while (and src (not (ede-want-file-p (car src) file)))
|
||
(setq src (cdr src)))
|
||
src))
|
||
|
||
(defmethod ede-want-file-source-p ((this ede-target) file)
|
||
"Return non-nil if THIS target wants FILE."
|
||
;; By default, all targets reference the source object, and let it decide.
|
||
(let ((src (ede-target-sourcecode this)))
|
||
(while (and src (not (ede-want-file-source-p (car src) file)))
|
||
(setq src (cdr src)))
|
||
src))
|
||
|
||
(defmethod ede-target-sourcecode ((this ede-target))
|
||
"Return the sourcecode objects which THIS permits."
|
||
(let ((sc (oref this sourcetype))
|
||
(rs nil))
|
||
(while (and (listp sc) sc)
|
||
(setq rs (cons (symbol-value (car sc)) rs)
|
||
sc (cdr sc)))
|
||
rs))
|
||
|
||
|
||
;;; Debugging.
|
||
;;
|
||
(defun ede-adebug-project ()
|
||
"Run adebug against the current EDE project.
|
||
Display the results as a debug list."
|
||
(interactive)
|
||
(require 'data-debug)
|
||
(when (ede-current-project)
|
||
(data-debug-new-buffer "*Analyzer ADEBUG*")
|
||
(data-debug-insert-object-slots (ede-current-project) "")
|
||
))
|
||
|
||
(defun ede-adebug-project-parent ()
|
||
"Run adebug against the current EDE parent project.
|
||
Display the results as a debug list."
|
||
(interactive)
|
||
(require 'data-debug)
|
||
(when (ede-parent-project)
|
||
(data-debug-new-buffer "*Analyzer ADEBUG*")
|
||
(data-debug-insert-object-slots (ede-parent-project) "")
|
||
))
|
||
|
||
(defun ede-adebug-project-root ()
|
||
"Run adebug against the current EDE parent project.
|
||
Display the results as a debug list."
|
||
(interactive)
|
||
(require 'data-debug)
|
||
(when (ede-toplevel)
|
||
(data-debug-new-buffer "*Analyzer ADEBUG*")
|
||
(data-debug-insert-object-slots (ede-toplevel) "")
|
||
))
|
||
|
||
|
||
|
||
;;; TOPLEVEL PROJECT
|
||
;;
|
||
;; The toplevel project is a way to identify the EDE structure that belongs
|
||
;; to the top of a project.
|
||
|
||
(defun ede-toplevel (&optional subproj)
|
||
"Return the ede project which is the root of the current project.
|
||
Optional argument SUBPROJ indicates a subproject to start from
|
||
instead of the current project."
|
||
(or (when (not subproj) ede-object-root-project)
|
||
(let* ((cp (or subproj (ede-current-project))))
|
||
(or (and cp (ede-project-root cp))
|
||
(progn
|
||
(while (ede-parent-project cp)
|
||
(setq cp (ede-parent-project cp)))
|
||
cp)))))
|
||
|
||
|
||
;;; Utility functions
|
||
;;
|
||
|
||
(defun ede-normalize-file/directory (this project-file-name)
|
||
"Fills :directory or :file slots if they're missing in project THIS.
|
||
The other slot will be used to calculate values.
|
||
PROJECT-FILE-NAME is a name of project file (short name, like 'pom.xml', etc."
|
||
(when (and (or (not (slot-boundp this :file))
|
||
(not (oref this :file)))
|
||
(slot-boundp this :directory)
|
||
(oref this :directory))
|
||
(oset this :file (expand-file-name project-file-name (oref this :directory))))
|
||
(when (and (or (not (slot-boundp this :directory))
|
||
(not (oref this :directory)))
|
||
(slot-boundp this :file)
|
||
(oref this :file))
|
||
(oset this :directory (file-name-directory (oref this :file))))
|
||
)
|
||
|
||
|
||
|
||
|
||
;;; Hooks & Autoloads
|
||
;;
|
||
;; These let us watch various activities, and respond appropriately.
|
||
|
||
;; (add-hook 'edebug-setup-hook
|
||
;; (lambda ()
|
||
;; (def-edebug-spec ede-with-projectfile
|
||
;; (form def-body))))
|
||
|
||
(provide 'ede/base)
|
||
|
||
;; Local variables:
|
||
;; generated-autoload-file: "loaddefs.el"
|
||
;; generated-autoload-load-name: "ede/base"
|
||
;; End:
|
||
|
||
;;; ede/base.el ends here
|