mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-19 12:20:17 -08:00
* lisp/emacs-lisp: * emacs-lisp/eieio.el (eieio--defalias, eieio-hook) (eieio-error-unsupported-class-tags, eieio-skip-typecheck) (eieio-optimize-primary-methods-flag, eieio-initializing-object) (eieio-unbound, eieio-default-superclass) (eieio--define-field-accessors, method-static, method-before) (method-primary, method-after, method-num-lists) (method-generic-before, method-generic-primary) (method-generic-after, method-num-slots) (eieio-specialized-key-to-generic-key) (eieio--check-type, class-v, class-p) (eieio-class-name, define-obsolete-function-alias) (eieio-class-parents-fast, eieio-class-children-fast) (same-class-fast-p, class-constructor, generic-p) (generic-primary-only-p, generic-primary-only-one-p) (class-option-assoc, class-option, eieio-object-p) (class-abstract-p, class-method-invocation-order) (eieio-defclass-autoload-map, eieio-defclass-autoload) (eieio-class-un-autoload, eieio-defclass) (eieio-eval-default-p, eieio-perform-slot-validation-for-default) (eieio-add-new-slot, eieio-copy-parents-into-subclass) (eieio--defgeneric-init-form, eieio-defgeneric-form) (eieio-defgeneric-reset-generic-form) (eieio-defgeneric-form-primary-only) (eieio-defgeneric-reset-generic-form-primary-only) (eieio-defgeneric-form-primary-only-one) (eieio-defgeneric-reset-generic-form-primary-only-one) (eieio-unbind-method-implementations) (eieio--defmethod, eieio--typep) (eieio-perform-slot-validation, eieio-validate-slot-value) (eieio-validate-class-slot-value, eieio-barf-if-slot-unbound) (eieio-oref, eieio-oref-default, eieio-default-eval-maybe) (eieio-oset, eieio-oset-default, eieio-slot-originating-class-p) (eieio-slot-name-index, eieio-class-slot-name-index) (eieio-set-defaults, eieio-initarg-to-attribute) (eieio-attribute-to-initarg, eieio-c3-candidate) (eieio-c3-merge-lists, eieio-class-precedence-c3) (eieio-class-precedence-dfs, eieio-class-precedence-bfs) (eieio-class-precedence-list, eieio-generic-call-methodname) (eieio-generic-call-arglst, eieio-generic-call-key) (eieio-generic-call-next-method-list) (eieio-pre-method-execution-functions, eieio-generic-call) (eieio-generic-call-primary-only, eieiomt-method-list) (eieiomt-optimizing-obarray, eieiomt-install) (eieiomt-add, eieiomt-next, eieiomt-sym-optimize) (eieio-generic-form, eieio-defmethod, make-obsolete) (eieio-defgeneric, make-obsolete): Moved to eieio-core.el (defclass): Remove `eval-and-compile' from macro. (call-next-method, shared-initialize): Instead of using `scoped-class' variable, use new eieio--scoped-class, and eieio--with-scoped-class. (initialize-instance): Rename local variable 'scoped-class' to 'this-class' to remove ambiguitity from old global. * emacs-lisp/eieio-core.el: New file. Derived from key parts of eieio.el. (eieio--scoped-class-stack): New variable (eieio--scoped-class): New fcn (eieio--with-scoped-class): New scoping macro. (eieio-defclass): Use pushnew instead of add-to-list. (eieio-defgeneric-form-primary-only-one, eieio-oset-default) (eieio-slot-name-index, eieio-set-defaults, eieio-generic-call) (eieio-generic-call-primary-only, eieiomt-add): Instead of using `scoped-class' variable, use new eieio--scoped-class, and eieio--with-scoped-class. * emacs-lisp/eieio-base.el (cl-lib): Require during compile. * admin/grammars: * grammars/srecode-template.wy (variable): Accept a single number as a variable value. Allows the 'priority' to be set to a number. (wisent-srecode-template-lexer): Move number up so it can be created. * etc/srecode: * srecode/c.srt (header_guard): Add :c parameter so it works standalone * lisp/cedet: * semantic/edit.el (semantic-change-function): Use `save-match-data' around running hooks. * semantic/decorate/mode.el (semantic-decorate-style-predicate-default) (semantic-decorate-style-highlighter-default): New. (semantic-decoration-mode): Do not require `semantic/decorate/include' anymore. (semantic-toggle-decoration-style): Error if an unknown decoration style is toggled. (define-semantic-decoration-style): Add new :load option. When :load is specified, add autoload tokens for the definition functions so that code is loaded when the mode is used. (semantic-decoration-on-includes): New autoload definition for highlighting includes. * semantic/bovine/c.el (semantic-lex-c-ifdef): Allow some misc characters to appear after the tested variable. * semantic/ede-grammar.el (project-compile-target): Calculate full src name via ede-expand-filename instead of the crutch of the current buffer. Enables this target to compile in batch mode. * semantic/idle.el (semantic-idle-symbol-maybe-highlight): Wrap highlighting of remote symbol with `save-excursion'. (semantic-idle-scheduler-work-parse-neighboring-files): Instead of using directory-files on each found mode pattern, collect all the patterns for the current mode, and then for each file, see if it matches any of them. If it does, parse the file. (Patch inspiration from Tomasz Gajewski.) * semantic/ctxt.el (semantic-ctxt-end-of-symbol): New. (semantic-ctxt-current-symbol-default): New. * semantic/bovine/el.el (semantic-default-elisp-setup): Add autoload cookie. Explain existence. (footer): Add local variable for loaddefs. * semantic/db.el (semanticdb-file-table-object): Add new filter, only checking for regular files too. * semantic/wisent/python.el (semantic-format-tag-abbreviate): New override. Cuts back on size of code tags. * srecode/compile.el (srecode-compile-templates): Fix warning punctuation. Remove status messages to clean up testing output * ede/base.el (ede-project-placeholder-cache-file): Update doc to mention 'nil' value. (ede-save-cache): Disable cache save if file is nil. * ede.el (ede-initialize-state-current-buffer): Flush deleted projects. (global-ede-mode): Always append our find-file-hook to the end. (ede-flush-deleted-projects): New command. * ede/cpp-root.el (ede-preprocessor-map): Protect against init problems. * ede/proj.el (ede-proj-target): Added a new "custom" option for custom symbols representing a compiler or linker instead of restricting things to only the predefined compilers and linkers. * semantic.el (semantic-mode-map): To avoid showing showing Development menu twice, only disable menu item if menu-bar is actually enabled, otherwise the popup 'global menu' might display a disabled Development menu. * semantic/complete.el (semantic-displayor-show-request): Fix which slot in obj is set to the max tags.
220 lines
8 KiB
EmacsLisp
220 lines
8 KiB
EmacsLisp
;;; semantic/ede-grammar.el --- EDE support for Semantic Grammar Files
|
|
|
|
;; Copyright (C) 2003-2004, 2007-2013 Free Software Foundation, Inc.
|
|
|
|
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
|
;; Keywords: project, make
|
|
|
|
;; 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:
|
|
;;
|
|
;; Handle .by or .wy files.
|
|
|
|
(require 'semantic)
|
|
(require 'ede/proj)
|
|
(require 'ede/pmake)
|
|
(require 'ede/pconf)
|
|
(require 'ede/proj-elisp)
|
|
(require 'semantic/grammar)
|
|
|
|
;;; Code:
|
|
(defclass semantic-ede-proj-target-grammar (ede-proj-target-elisp)
|
|
((menu :initform nil)
|
|
(keybindings :initform nil)
|
|
(phony :initform t)
|
|
(sourcetype :initform
|
|
(semantic-ede-source-grammar-wisent
|
|
semantic-ede-source-grammar-bovine
|
|
))
|
|
(availablecompilers :initform
|
|
(semantic-ede-grammar-compiler-wisent
|
|
semantic-ede-grammar-compiler-bovine
|
|
))
|
|
(aux-packages :initform '("semantic" "cedet-compat"))
|
|
(pre-load-packages :initform '("cedet-compat" "semantic/grammar" "semantic/bovine/grammar" "semantic/wisent/grammar"))
|
|
)
|
|
"This target consists of a group of grammar files.
|
|
A grammar target consists of grammar files that build Emacs Lisp programs for
|
|
parsing different languages.")
|
|
|
|
(defmethod ede-proj-makefile-dependencies ((this semantic-ede-proj-target-grammar))
|
|
"Return a string representing the dependencies for THIS.
|
|
Some compilers only use the first element in the dependencies, others
|
|
have a list of intermediates (object files), and others don't care.
|
|
This allows customization of how these elements appear.
|
|
For Emacs Lisp, return addsuffix command on source files."
|
|
(let ((source (car (oref this source))))
|
|
(cond
|
|
((string-match "\\.wy$" source)
|
|
(format "$(addsuffix -wy.elc, $(basename $(%s)))"
|
|
(ede-proj-makefile-sourcevar this)))
|
|
((string-match "\\.by$" source)
|
|
(format "$(addsuffix -by.elc, $(basename $(%s)))"
|
|
(ede-proj-makefile-sourcevar this))))))
|
|
|
|
(defvar semantic-ede-source-grammar-wisent
|
|
(ede-sourcecode "semantic-ede-grammar-source-wisent"
|
|
:name "Wisent Grammar"
|
|
:sourcepattern "\\.wy$"
|
|
:garbagepattern '("*-wy.el")
|
|
)
|
|
"Semantic Grammar source code definition for wisent.")
|
|
|
|
(defclass semantic-ede-grammar-compiler-class (ede-compiler)
|
|
nil
|
|
"Specialized compiler for semantic grammars.")
|
|
|
|
(defvar semantic-ede-grammar-compiler-wisent
|
|
(semantic-ede-grammar-compiler-class
|
|
"ede-emacs-wisent-compiler"
|
|
:name "emacs"
|
|
:variables '(("EMACS" . "emacs")
|
|
("EMACSFLAGS" . "-batch --no-site-file --eval '(setq debug-on-error t)'")
|
|
("require" . "$(foreach r,$(1),(require (quote $(r))))"))
|
|
:rules (list (ede-makefile-rule
|
|
"elisp-inference-rule"
|
|
:target "%-wy.el"
|
|
:dependencies "%.wy"
|
|
:rules '("$(EMACS) $(EMACSFLAGS) $(addprefix -L ,$(LOADPATH)) \
|
|
--eval '(progn $(call require,$(PRELOADS)))' -f semantic-grammar-batch-build-packages $^")))
|
|
:sourcetype '(semantic-ede-source-grammar-wisent)
|
|
:objectextention "-wy.el"
|
|
)
|
|
"Compile Emacs Lisp programs.")
|
|
|
|
|
|
(defvar semantic-ede-source-grammar-bovine
|
|
(ede-sourcecode "semantic-ede-grammar-source-bovine"
|
|
:name "Bovine Grammar"
|
|
:sourcepattern "\\.by$"
|
|
:garbagepattern '("*-by.el")
|
|
)
|
|
"Semantic Grammar source code definition for the bovinator.")
|
|
|
|
(defvar semantic-ede-grammar-compiler-bovine
|
|
(semantic-ede-grammar-compiler-class
|
|
"ede-emacs-wisent-compiler"
|
|
:name "emacs"
|
|
:variables '(("EMACS" . "emacs")
|
|
("EMACSFLAGS" . "-batch --no-site-file --eval '(setq debug-on-error t)'")
|
|
("require" . "$(foreach r,$(1),(require (quote $(r))))"))
|
|
:rules (list (ede-makefile-rule
|
|
"elisp-inference-rule"
|
|
:target "%-by.el"
|
|
:dependencies "%.by"
|
|
:rules '("$(EMACS) $(EMACSFLAGS) $(addprefix -L ,$(LOADPATH)) \
|
|
--eval '(progn $(call require,$(PRELOADS)))' -f semantic-grammar-batch-build-packages $^")))
|
|
:sourcetype '(semantic-ede-source-grammar-bovine)
|
|
:objectextention "-by.el"
|
|
)
|
|
"Compile Emacs Lisp programs.")
|
|
|
|
;;; Target options.
|
|
(defmethod ede-buffer-mine ((this semantic-ede-proj-target-grammar) buffer)
|
|
"Return t if object THIS lays claim to the file in BUFFER.
|
|
Lays claim to all -by.el, and -wy.el files."
|
|
;; We need to be a little more careful than this, but at the moment it
|
|
;; is common to have only one target of this class per directory.
|
|
(if (string-match "-[bw]y\\.elc?$" (buffer-file-name buffer))
|
|
t
|
|
(call-next-method) ; The usual thing.
|
|
))
|
|
|
|
(defmethod project-compile-target ((obj semantic-ede-proj-target-grammar))
|
|
"Compile all sources in a Lisp target OBJ."
|
|
(let* ((cb (current-buffer))
|
|
(proj (ede-target-parent obj))
|
|
(default-directory (oref proj directory))
|
|
(comp 0)
|
|
(utd 0))
|
|
(mapc (lambda (src)
|
|
(with-current-buffer (find-file-noselect src)
|
|
(let* ((package (semantic-grammar-create-package))
|
|
(fname (progn (string-match ".*/\\(.+\\.el\\)" package)
|
|
(match-string 1 package)))
|
|
(src (ede-expand-filename obj fname))
|
|
(csrc (concat (file-name-sans-extension src) ".elc")))
|
|
(if (< emacs-major-version 24)
|
|
;; Does not have `byte-recompile-file'
|
|
(if (or (not (file-exists-p csrc))
|
|
(file-newer-than-file-p src csrc))
|
|
(progn
|
|
(setq comp (1+ comp))
|
|
(byte-compile-file src))
|
|
(setq utd (1+ utd)))
|
|
;; Emacs 24 and newer
|
|
(with-no-warnings
|
|
(if (eq (byte-recompile-file src nil 0) t)
|
|
(setq comp (1+ comp))
|
|
(setq utd (1+ utd))))))))
|
|
(oref obj source))
|
|
(message "All Semantic Grammar sources are up to date in %s" (eieio-object-name obj))
|
|
(cons comp utd)))
|
|
|
|
;;; Makefile generation functions
|
|
;;
|
|
(defmethod ede-proj-makefile-sourcevar ((this semantic-ede-proj-target-grammar))
|
|
"Return the variable name for THIS's sources."
|
|
(cond ((ede-proj-automake-p)
|
|
(error "No Automake support for Semantic Grammars"))
|
|
(t (concat (ede-pmake-varname this) "_SEMANTIC_GRAMMAR"))))
|
|
|
|
(defmethod ede-proj-makefile-insert-variables :AFTER ((this semantic-ede-proj-target-grammar))
|
|
"Insert variables needed by target THIS."
|
|
(ede-proj-makefile-insert-loadpath-items
|
|
(ede-proj-elisp-packages-to-loadpath
|
|
(list "eieio" "semantic" "inversion" "ede")))
|
|
;; eieio for object system needed in ede
|
|
;; semantic because it is
|
|
;; Inversion for versioning system.
|
|
;; ede for project regeneration
|
|
(ede-pmake-insert-variable-shared
|
|
(concat (ede-pmake-varname this) "_SEMANTIC_GRAMMAR_EL")
|
|
(insert
|
|
(mapconcat (lambda (src)
|
|
(with-current-buffer (find-file-noselect src)
|
|
(concat (semantic-grammar-package) ".el")))
|
|
(oref this source)
|
|
" ")))
|
|
)
|
|
|
|
(defmethod ede-proj-makefile-insert-rules :after ((this semantic-ede-proj-target-grammar))
|
|
"Insert rules needed by THIS target.
|
|
This raises `max-specpdl-size' and `max-lisp-eval-depth', which can be
|
|
needed for the compilation of the resulting parsers."
|
|
(insert (format "%s: EMACSFLAGS+= --eval '(setq max-specpdl-size 1500 \
|
|
max-lisp-eval-depth 700)'\n"
|
|
(oref this name))))
|
|
|
|
(defmethod ede-proj-makefile-insert-dist-dependencies ((this semantic-ede-proj-target-grammar))
|
|
"Insert dist dependencies, or intermediate targets.
|
|
This makes sure that all grammar lisp files are created before the dist
|
|
runs, so they are always up to date.
|
|
Argument THIS is the target that should insert stuff."
|
|
(call-next-method)
|
|
(insert " $(" (ede-pmake-varname this) "_SEMANTIC_GRAMMAR_EL)")
|
|
)
|
|
|
|
;; (autoload 'ede-proj-target-elisp "ede/proj-elisp"
|
|
;; "Target class for Emacs/Semantic grammar files." nil nil)
|
|
|
|
(ede-proj-register-target "semantic grammar"
|
|
semantic-ede-proj-target-grammar)
|
|
|
|
(provide 'semantic/ede-grammar)
|
|
|
|
;;; semantic/ede-grammar.el ends here
|