diff options
author | David Engster <dengste@eml.cc> | 2013-06-02 18:39:32 +0200 |
---|---|---|
committer | David Engster <dengste@eml.cc> | 2013-06-02 18:39:32 +0200 |
commit | 6b7a9e0eb195db4f7a0b48467eb9860d04d92486 (patch) | |
tree | 8e9a407a17f616a33b8c310e2b60d76be1801fe8 /lisp/cedet/semantic | |
parent | d105b0e26f965b41452153ad405efe98ff142de6 (diff) | |
parent | caaeb0e88cb0f62a1726ee7e1b4db62f7e4287a6 (diff) | |
download | emacs-6b7a9e0eb195db4f7a0b48467eb9860d04d92486.tar.gz emacs-6b7a9e0eb195db4f7a0b48467eb9860d04d92486.tar.bz2 emacs-6b7a9e0eb195db4f7a0b48467eb9860d04d92486.zip |
Merge with CEDET upstream (rev. 8564).
Diffstat (limited to 'lisp/cedet/semantic')
-rw-r--r-- | lisp/cedet/semantic/bovine/c.el | 2 | ||||
-rw-r--r-- | lisp/cedet/semantic/bovine/el.el | 9 | ||||
-rw-r--r-- | lisp/cedet/semantic/complete.el | 2 | ||||
-rw-r--r-- | lisp/cedet/semantic/ctxt.el | 83 | ||||
-rw-r--r-- | lisp/cedet/semantic/db.el | 2 | ||||
-rw-r--r-- | lisp/cedet/semantic/decorate/mode.el | 44 | ||||
-rw-r--r-- | lisp/cedet/semantic/ede-grammar.el | 2 | ||||
-rw-r--r-- | lisp/cedet/semantic/edit.el | 5 | ||||
-rw-r--r-- | lisp/cedet/semantic/idle.el | 54 | ||||
-rw-r--r-- | lisp/cedet/semantic/wisent/python.el | 14 |
10 files changed, 185 insertions, 32 deletions
diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el index 2f8cf08af3e..3c991ea8555 100644 --- a/lisp/cedet/semantic/bovine/c.el +++ b/lisp/cedet/semantic/bovine/c.el @@ -529,7 +529,7 @@ code to parse." (define-lex-regex-analyzer semantic-lex-c-ifdef "Code blocks wrapped up in #ifdef. Uses known macro tables in SPP to determine what block to skip." - "^\\s-*#\\s-*\\(ifndef\\|ifdef\\)\\s-+\\(\\(\\sw\\|\\s_\\)+\\)$" + "^\\s-*#\\s-*\\(ifndef\\|ifdef\\)\\s-+\\(\\(\\sw\\|\\s_\\)+\\)\\([ \t\C-m].*\\)?$" (semantic-c-do-lex-ifdef)) (defun semantic-c-do-lex-ifdef () diff --git a/lisp/cedet/semantic/bovine/el.el b/lisp/cedet/semantic/bovine/el.el index a8ddbe106f7..07e0e08bbaf 100644 --- a/lisp/cedet/semantic/bovine/el.el +++ b/lisp/cedet/semantic/bovine/el.el @@ -940,8 +940,11 @@ ELisp variables can be pretty long, so track this one too.") (define-child-mode lisp-mode emacs-lisp-mode "Make `lisp-mode' inherit mode local behavior from `emacs-lisp-mode'.") +;;;###autoload (defun semantic-default-elisp-setup () "Setup hook function for Emacs Lisp files and Semantic." + ;; This is here mostly to get this file loaded when a .el file is + ;; loaded into Emacs. ) (add-hook 'emacs-lisp-mode-hook 'semantic-default-elisp-setup) @@ -960,6 +963,12 @@ ELisp variables can be pretty long, so track this one too.") '(require 'semantic/db-el) ) + (provide 'semantic/bovine/el) +;; Local variables: +;; generated-autoload-file: "../loaddefs.el" +;; generated-autoload-load-name: "semantic/bovine/el" +;; End: + ;;; semantic/bovine/el.el ends here diff --git a/lisp/cedet/semantic/complete.el b/lisp/cedet/semantic/complete.el index 6c2b97a677a..b42e24fb9c0 100644 --- a/lisp/cedet/semantic/complete.el +++ b/lisp/cedet/semantic/complete.el @@ -1667,7 +1667,7 @@ Display mechanism using tooltip for a list of possible completions.") (setq msg "..."))) ((eq mode 'verbose) ;; Always show extended match set. - (oset obj max-tags semantic-displayor-tooltip-max-tags) + (oset obj max-tags-initial semantic-displayor-tooltip-max-tags) (setq max-tags semantic-displayor-tooltip-max-tags))) (unless msg (oset obj shown t) diff --git a/lisp/cedet/semantic/ctxt.el b/lisp/cedet/semantic/ctxt.el index 2c0b428c195..efaec4f63b4 100644 --- a/lisp/cedet/semantic/ctxt.el +++ b/lisp/cedet/semantic/ctxt.el @@ -357,6 +357,87 @@ beginning and end of a command." (def-edebug-spec semantic-with-buffer-narrowed-to-command (def-body)))) +(define-overloadable-function semantic-ctxt-end-of-symbol (&optional point) + "Move point to the end of the current symbol under POINT. +This skips forward over symbols in a complex reference. +For example, in the C statement: + this.that().entry; + +If the cursor is on 'this', will move point to the ; after entry.") + +(defun semantic-ctxt-end-of-symbol-default (&optional point) + "Move poin to the end of the current symbol under POINT. +This will move past type/field names when applicable. +Depends on `semantic-type-relation-separator-character', and will +work on C like languages." + (if point (goto-char point)) + (let* ((fieldsep1 (mapconcat (lambda (a) (regexp-quote a)) + semantic-type-relation-separator-character + "\\|")) + ;; NOTE: The [ \n] expression below should used \\s-, but that + ;; doesn't work in C since \n means end-of-comment, and isn't + ;; really whitespace. + (fieldsep (concat "[ \t\n\r]*\\(" fieldsep1 "\\)[ \t\n\r]*\\(\\w\\|\\s_\\)")) + (case-fold-search semantic-case-fold) + (continuesearch t) + (end nil) + ) + (with-syntax-table semantic-lex-syntax-table + (cond ((looking-at "\\w\\|\\s_") + ;; In the middle of a symbol, move to the end. + (forward-sexp 1)) + ((looking-at fieldsep1) + ;; We are in a fine spot.. do nothing. + nil + ) + ((save-excursion + (and (condition-case nil + (progn (forward-sexp -1) + (forward-sexp 1) + t) + (error nil)) + (looking-at fieldsep1))) + (setq symlist (list "")) + (forward-sexp -1) + ;; Skip array expressions. + (while (looking-at "\\s(") (forward-sexp -1)) + (forward-sexp 1)) + ) + ;; Set the current end marker. + (setq end (point)) + + ;; Cursor is at the safe end of some symbol. Look until we + ;; find the logical end of this current complex symbol. + (condition-case nil + (while continuesearch + ;; If there are functional arguments, arrays, etc, skip them. + (when (looking-at "\\s(") + (forward-sexp 1)) + + ;; If there is a field separator, then skip that, plus + ;; the next expected symbol. + (if (not (looking-at fieldsep1)) + ;; We hit the end. + (error nil) + + ;; Skip the separator and the symbol. + (goto-char (match-end 0)) + + (if (looking-at "\\w\\|\\s_") + ;; Skip symbols + (forward-sexp 1) + ;; No symbol, exit the search... + (setq continuesearch nil)) + + (setq end (point))) + + ;; Cont... + ) + + ;; Restore position if we go to far.... + (error (goto-char end)) ) + + ))) (define-overloadable-function semantic-ctxt-current-symbol (&optional point) "Return the current symbol the cursor is on at POINT in a list. @@ -391,7 +472,7 @@ Depends on `semantic-type-relation-separator-character'." ;; In the middle of a symbol, move to the end. (forward-sexp 1)) ((looking-at fieldsep1) - ;; We are in a find spot.. do nothing. + ;; We are in a fine spot.. do nothing. nil ) ((save-excursion diff --git a/lisp/cedet/semantic/db.el b/lisp/cedet/semantic/db.el index e8784c4f85c..8d9cfcccd7d 100644 --- a/lisp/cedet/semantic/db.el +++ b/lisp/cedet/semantic/db.el @@ -899,7 +899,7 @@ If file does not have tags available, and DONTLOAD is nil, then load the tags for FILE, and create a new table object for it. DONTLOAD does not affect the creation of new database objects." ;; (message "Object Translate: %s" file) - (when (and file (file-exists-p file)) + (when (and file (file-exists-p file) (file-regular-p file)) (let* ((default-directory (file-name-directory file)) (tab (semanticdb-file-table-object-from-hash file)) (fullfile nil)) diff --git a/lisp/cedet/semantic/decorate/mode.el b/lisp/cedet/semantic/decorate/mode.el index fc791f52da1..3487e615168 100644 --- a/lisp/cedet/semantic/decorate/mode.el +++ b/lisp/cedet/semantic/decorate/mode.el @@ -64,6 +64,14 @@ add items to this list." "Return the STYLE's highlighter function." (intern (format "%s-highlight" style))) +(defsubst semantic-decorate-style-predicate-default (style) + "Return the STYLE's predicate function." + (intern (format "%s-p-default" style))) + +(defsubst semantic-decorate-style-highlighter-default (style) + "Return the STYLE's highlighter function." + (intern (format "%s-highlight-default" style))) + ;;; Base decoration API ;; (defsubst semantic-decoration-p (object) @@ -265,8 +273,6 @@ minor mode is enabled." (semantic-make-local-hook 'semantic-after-toplevel-cache-change-hook) (add-hook 'semantic-after-toplevel-cache-change-hook 'semantic-decorate-tags-after-full-reparse nil t) - ;; Decorate includes by default - (require 'semantic/decorate/include) ;; Add decorations to available tags. The above hooks ensure ;; that new tags will be decorated when they become available. (semantic-decorate-add-decorations (semantic-fetch-available-tags))) @@ -325,6 +331,8 @@ Return non-nil if the decoration style is enabled." (flag (if arg (> (prefix-numeric-value arg) 0) (not (cdr style))))) + (when (null style) + (error "Unknown decoration style %s" name)) (unless (eq (cdr style) flag) ;; Store the new flag. (setcdr style flag) @@ -368,7 +376,8 @@ DOC is a documentation string describing the decoration style NAME. It is appended to auto-generated doc strings. An Optional list of FLAGS can also be specified. Flags are: :enabled <value> - specify the default enabled value for NAME. - + :load <value> - specify a feature (as a string) with the rest of + the definition for decoration mode NAME. This defines two new overload functions respectively called `NAME-p' and `NAME-highlight', for which you must provide a default @@ -386,9 +395,14 @@ To add other kind of decorations on a tag, `NAME-highlight' must use decoration API found in this library." (let ((predicate (semantic-decorate-style-predicate name)) (highlighter (semantic-decorate-style-highlighter name)) + (predicatedef (semantic-decorate-style-predicate-default name)) + (highlighterdef (semantic-decorate-style-highlighter-default name)) (defaultenable (if (plist-member flags :enabled) (plist-get flags :enabled) t)) + (loadfile (if (plist-member flags :load) + (plist-get flags :load) + nil)) ) `(progn ;; Clear the menu cache so that new items are added when @@ -408,7 +422,19 @@ decoration API found in this library." (add-to-list 'semantic-decoration-styles (cons ',(symbol-name name) ,defaultenable)) - ))) + ;; If there is a load file, then create the autload tokens for + ;; those functions to load the token, but only if the fsym + ;; doesn't exist yet. + (when (stringp ,loadfile) + (unless (fboundp ',predicatedef) + (autoload ',predicatedef ',loadfile "Return non-nil to decorate TAG." + nil 'function)) + + (unless (fboundp ',highlighterdef) + (autoload ',highlighterdef ',loadfile "Decorate TAG." + nil 'function)) + )) + )) ;;; Predefined decoration styles ;; @@ -514,6 +540,16 @@ Use a primary decoration." (semantic-set-tag-face tag 'semantic-decoration-on-protected-members-face)) +;;; Decoration Modes in other files +;; +(define-semantic-decoration-style semantic-decoration-on-includes + "Highlight class members that are includes. +This mode provides a nice context menu on the include statements." + :enabled t + :load "semantic/decorate/include") + + + (provide 'semantic/decorate/mode) ;; Local variables: diff --git a/lisp/cedet/semantic/ede-grammar.el b/lisp/cedet/semantic/ede-grammar.el index cb2a1faaac0..17859e232a3 100644 --- a/lisp/cedet/semantic/ede-grammar.el +++ b/lisp/cedet/semantic/ede-grammar.el @@ -146,7 +146,7 @@ Lays claim to all -by.el, and -wy.el files." (let* ((package (semantic-grammar-create-package)) (fname (progn (string-match ".*/\\(.+\\.el\\)" package) (match-string 1 package))) - (src (with-current-buffer fname (buffer-file-name))) + (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' diff --git a/lisp/cedet/semantic/edit.el b/lisp/cedet/semantic/edit.el index b0540af373d..a27eab5404c 100644 --- a/lisp/cedet/semantic/edit.el +++ b/lisp/cedet/semantic/edit.el @@ -141,8 +141,9 @@ Argument START, END, and LENGTH specify the bounds of the change." (setq semantic-unmatched-syntax-cache-check t) (let ((inhibit-point-motion-hooks t) ) - (run-hook-with-args 'semantic-change-functions start end length) - )) + (save-match-data + (run-hook-with-args 'semantic-change-functions start end length) + ))) (defun semantic-changes-in-region (start end &optional buffer) "Find change overlays which exist in whole or in part between START and END. diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el index 9899ab974f7..6c223c2b9f2 100644 --- a/lisp/cedet/semantic/idle.el +++ b/lisp/cedet/semantic/idle.el @@ -434,16 +434,27 @@ datasets." (defun semantic-idle-scheduler-work-parse-neighboring-files () "Parse all the files in similar directories to buffers being edited." - ;; Let's check to see if EDE matters. - (let ((ede-auto-add-method 'never)) - (dolist (a auto-mode-alist) - (when (eq (cdr a) major-mode) - (dolist (file (directory-files default-directory t (car a) t)) - (semantic-throw-on-input 'parsing-mode-buffers) - (save-excursion - (semanticdb-file-table-object file) - )))) - )) + ;; Let's tell EDE to ignore all the files we're about to load + (let ((ede-auto-add-method 'never) + (matching-auto-mode-patterns nil)) + ;; Collect all patterns matching files of the same mode we edit. + (mapc (lambda (pat) (and (eq (cdr pat) major-mode) + (push (car pat) matching-auto-mode-patterns))) + auto-mode-alist) + ;; Loop over all files, and if one matches our mode, we force its + ;; table to load. + (dolist (file (directory-files default-directory t ".*" t)) + (catch 'found + (mapc (lambda (pat) + (semantic-throw-on-input 'parsing-mode-buffers) + ;; We use string-match instead of passing the pattern + ;; into directory files, because some patterns don't + ;; work with directory files. + (and (string-match pat file) + (save-excursion + (semanticdb-file-table-object file)) + (throw 'found t))) + matching-auto-mode-patterns))))) ;;; REPARSING @@ -840,17 +851,18 @@ visible, then highlight it." ) (cond ((semantic-overlay-p region) (with-current-buffer (semantic-overlay-buffer region) - (goto-char (semantic-overlay-start region)) - (when (pos-visible-in-window-p - (point) (get-buffer-window (current-buffer) 'visible)) - (if (< (semantic-overlay-end region) (point-at-eol)) - (pulse-momentary-highlight-overlay - region semantic-idle-symbol-highlight-face) - ;; Not the same - (pulse-momentary-highlight-region - (semantic-overlay-start region) - (point-at-eol) - semantic-idle-symbol-highlight-face))) + (save-excursion + (goto-char (semantic-overlay-start region)) + (when (pos-visible-in-window-p + (point) (get-buffer-window (current-buffer) 'visible)) + (if (< (semantic-overlay-end region) (point-at-eol)) + (pulse-momentary-highlight-overlay + region semantic-idle-symbol-highlight-face) + ;; Not the same + (pulse-momentary-highlight-region + (semantic-overlay-start region) + (point-at-eol) + semantic-idle-symbol-highlight-face)))) )) ((vectorp region) (let ((start (aref region 0)) diff --git a/lisp/cedet/semantic/wisent/python.el b/lisp/cedet/semantic/wisent/python.el index 8ca398ef271..719868f7635 100644 --- a/lisp/cedet/semantic/wisent/python.el +++ b/lisp/cedet/semantic/wisent/python.el @@ -485,6 +485,20 @@ Return a list as per `semantic-ctxt-current-symbol'. Return nil if there is nothing relevant." nil) +;;; Tag Formatting +;; +(define-mode-local-override semantic-format-tag-abbreviate python-mode (tag &optional parent color) + "Format an abbreviated tag for python. +Shortens 'code' tags, but passes through for others." + (cond ((semantic-tag-of-class-p tag 'code) + ;; Just take the first line. + (let ((name (semantic-tag-name tag))) + (when (string-match "\n" name) + (setq name (substring name 0 (match-beginning 0)))) + name)) + (t + (semantic-format-tag-abbreviate-default tag parent color)))) + ;;; Enable Semantic in `python-mode'. ;; |