diff options
| author | Chong Yidong | 2009-09-21 15:59:48 +0000 |
|---|---|---|
| committer | Chong Yidong | 2009-09-21 15:59:48 +0000 |
| commit | af7b5a91b2c7e4f3ee18f72192d7baa572d03735 (patch) | |
| tree | 2e891245bc618f1a24e8c084cc5f021d571522d4 | |
| parent | 602a8d7e4fa3616878f9161c4431bdd4b3b0fb04 (diff) | |
| download | emacs-af7b5a91b2c7e4f3ee18f72192d7baa572d03735.tar.gz emacs-af7b5a91b2c7e4f3ee18f72192d7baa572d03735.zip | |
* cedet/semantic.el: Add autoloads for semantic/idle functions.
* cedet/semantic/util.el (semantic--completion-cache): New var.
(semantic-symbol-start, semantic-find-tag-for-completion)
(semantic-complete-symbol): New functions, adapted from Senator.
* bindings.el (complete-symbol): Try semantic-complete-symbol if
no tag table is active.
* cedet/semantic/idle.el (define-semantic-idle-service): Doc fix.
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/bindings.el | 21 | ||||
| -rw-r--r-- | lisp/cedet/semantic.el | 31 | ||||
| -rw-r--r-- | lisp/cedet/semantic/idle.el | 2 | ||||
| -rw-r--r-- | lisp/cedet/semantic/util.el | 76 |
5 files changed, 135 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3f4b8f705ae..e9805247938 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2009-09-21 Chong Yidong <cyd@stupidchicken.com> | 1 | 2009-09-21 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 2 | ||
| 3 | * cedet/semantic.el: Add autoloads for semantic/idle functions. | ||
| 4 | |||
| 5 | * cedet/semantic/util.el (semantic--completion-cache): New var. | ||
| 6 | (semantic-symbol-start, semantic-find-tag-for-completion) | ||
| 7 | (semantic-complete-symbol): New functions, adapted from Senator. | ||
| 8 | |||
| 9 | * bindings.el (complete-symbol): Try semantic-complete-symbol if | ||
| 10 | no tag table is active. | ||
| 11 | |||
| 12 | * cedet/semantic/idle.el (define-semantic-idle-service): Doc fix. | ||
| 13 | |||
| 14 | 2009-09-21 Chong Yidong <cyd@stupidchicken.com> | ||
| 15 | |||
| 3 | * menu-bar.el: Remove ediff-misc from Tools menu. | 16 | * menu-bar.el: Remove ediff-misc from Tools menu. |
| 4 | 17 | ||
| 5 | * cedet/semantic.el (semantic-init-hook) | 18 | * cedet/semantic.el (semantic-init-hook) |
diff --git a/lisp/bindings.el b/lisp/bindings.el index c4c1c78674d..6e23b972ad9 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -678,13 +678,20 @@ With a prefix argument, this command does completion within | |||
| 678 | the collection of symbols listed in the index of the manual for the | 678 | the collection of symbols listed in the index of the manual for the |
| 679 | language you are using." | 679 | language you are using." |
| 680 | (interactive "P") | 680 | (interactive "P") |
| 681 | (if arg | 681 | (cond (arg |
| 682 | (info-complete-symbol) | 682 | (info-complete-symbol)) |
| 683 | (if (fboundp 'complete-tag) | 683 | ;; Don't autoload etags if we have no tags table. |
| 684 | (complete-tag) | 684 | ((or tags-table-list |
| 685 | ;; Don't autoload etags if we have no tags table. | 685 | tags-file-name) |
| 686 | (error "%s" (substitute-command-keys | 686 | (complete-tag)) |
| 687 | "No tags table loaded; use \\[visit-tags-table] to load one"))))) | 687 | ((and (fboundp 'semantic-active-p) |
| 688 | (semantic-active-p) | ||
| 689 | (fboundp 'semantic-complete-symbol)) | ||
| 690 | (semantic-complete-symbol)) | ||
| 691 | (t | ||
| 692 | (error "%s" (substitute-command-keys | ||
| 693 | "No tags table loaded; \ | ||
| 694 | use \\[visit-tags-table] to load one"))))) | ||
| 688 | 695 | ||
| 689 | ;; Reduce total amount of space we must allocate during this function | 696 | ;; Reduce total amount of space we must allocate during this function |
| 690 | ;; that we will not need to keep permanently. | 697 | ;; that we will not need to keep permanently. |
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el index 5596bda981b..17c31a65c7f 100644 --- a/lisp/cedet/semantic.el +++ b/lisp/cedet/semantic.el | |||
| @@ -906,6 +906,37 @@ Semantic mode." | |||
| 906 | (if (and (boundp mode) (eval mode)) | 906 | (if (and (boundp mode) (eval mode)) |
| 907 | (funcall mode -1))))) | 907 | (funcall mode -1))))) |
| 908 | 908 | ||
| 909 | ;;; Autoload some functions that are not in semantic/loaddefs | ||
| 910 | |||
| 911 | (autoload 'global-semantic-idle-completions-mode "semantic/idle" | ||
| 912 | "Toggle global use of `semantic-idle-completions-mode'. | ||
| 913 | If ARG is positive, enable, if it is negative, disable. | ||
| 914 | If ARG is nil, then toggle." t nil) | ||
| 915 | |||
| 916 | (autoload 'semantic-idle-completions-mode "semantic/idle" | ||
| 917 | "Display a list of possible completions in a tooltip. | ||
| 918 | |||
| 919 | This is a minor mode which performs actions during idle time. | ||
| 920 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 921 | minor mode can be turned on only if semantic feature is available and | ||
| 922 | the current buffer was set up for parsing. Return non-nil if the | ||
| 923 | minor mode is enabled." t nil) | ||
| 924 | |||
| 925 | (autoload 'global-semantic-idle-summary-mode "semantic/idle" | ||
| 926 | "Toggle global use of `semantic-idle-summary-mode'. | ||
| 927 | If ARG is positive, enable, if it is negative, disable. | ||
| 928 | If ARG is nil, then toggle." t nil) | ||
| 929 | |||
| 930 | (autoload 'semantic-idle-summary-mode "semantic/idle" | ||
| 931 | "Display a tag summary of the lexical token under the cursor. | ||
| 932 | Call `semantic-idle-summary-current-symbol-info' for getting the | ||
| 933 | current tag to display information. | ||
| 934 | |||
| 935 | This is a minor mode which performs actions during idle time. | ||
| 936 | With prefix argument ARG, turn on if positive, otherwise off. The | ||
| 937 | minor mode can be turned on only if semantic feature is available and | ||
| 938 | the current buffer was set up for parsing. Return non-nil if the | ||
| 939 | minor mode is enabled." t nil) | ||
| 909 | 940 | ||
| 910 | (provide 'semantic) | 941 | (provide 'semantic) |
| 911 | 942 | ||
diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el index e3ae984ae98..87da3cbd2cc 100644 --- a/lisp/cedet/semantic/idle.el +++ b/lisp/cedet/semantic/idle.el | |||
| @@ -612,7 +612,7 @@ This routines creates the following functions and variables:" | |||
| 612 | 612 | ||
| 613 | `(eval-and-compile | 613 | `(eval-and-compile |
| 614 | (defun ,global (&optional arg) | 614 | (defun ,global (&optional arg) |
| 615 | ,(concat "Toggle global use of option `" (symbol-name mode) "'. | 615 | ,(concat "Toggle global use of `" (symbol-name mode) "'. |
| 616 | If ARG is positive, enable, if it is negative, disable. | 616 | If ARG is positive, enable, if it is negative, disable. |
| 617 | If ARG is nil, then toggle.") | 617 | If ARG is nil, then toggle.") |
| 618 | (interactive "P") | 618 | (interactive "P") |
diff --git a/lisp/cedet/semantic/util.el b/lisp/cedet/semantic/util.el index 7981f75c30c..5d22cd068bd 100644 --- a/lisp/cedet/semantic/util.el +++ b/lisp/cedet/semantic/util.el | |||
| @@ -437,6 +437,82 @@ NOTFIRST indicates that this was not the first call in the recursive use." | |||
| 437 | (message "Remaining overlays: %S" o))) | 437 | (message "Remaining overlays: %S" o))) |
| 438 | over) | 438 | over) |
| 439 | 439 | ||
| 440 | ;;; Interactive commands (from Senator). | ||
| 441 | |||
| 442 | ;; The Senator library from upstream CEDET is not included in the | ||
| 443 | ;; built-in version of Emacs. The plan is to fold it into the | ||
| 444 | ;; different parts of CEDET and Emacs, so that it works | ||
| 445 | ;; "transparently". Here are some interactive commands based on | ||
| 446 | ;; Senator. | ||
| 447 | |||
| 448 | (defvar semantic--completion-cache nil | ||
| 449 | "Internal variable used by `senator-complete-symbol'.") | ||
| 450 | |||
| 451 | (defsubst semantic-symbol-start (pos) | ||
| 452 | "Return the start of the symbol at buffer position POS." | ||
| 453 | (car (nth 2 (semantic-ctxt-current-symbol-and-bounds pos)))) | ||
| 454 | |||
| 455 | (defun semantic-find-tag-for-completion (prefix) | ||
| 456 | "Find all tags with name starting with PREFIX. | ||
| 457 | This uses `semanticdb' when available." | ||
| 458 | (let (result ctxt) | ||
| 459 | (condition-case nil | ||
| 460 | (and (featurep 'semantic/analyze) | ||
| 461 | (setq ctxt (semantic-analyze-current-context)) | ||
| 462 | (setq result (semantic-analyze-possible-completions ctxt))) | ||
| 463 | (error nil)) | ||
| 464 | (or result | ||
| 465 | ;; If the analyzer fails, then go into boring completion. | ||
| 466 | (if (and (featurep 'semantic/db) (semanticdb-minor-mode-p)) | ||
| 467 | (semanticdb-fast-strip-find-results | ||
| 468 | (semanticdb-deep-find-tags-for-completion prefix)) | ||
| 469 | (semantic-deep-find-tags-for-completion prefix (current-buffer)))))) | ||
| 470 | |||
| 471 | (defun semantic-complete-symbol (&optional predicate) | ||
| 472 | "Complete the symbol under point, using Semantic facilities. | ||
| 473 | When called from a program, optional arg PREDICATE is a predicate | ||
| 474 | determining which symbols are considered." | ||
| 475 | (interactive) | ||
| 476 | (let* ((start (car (nth 2 (semantic-ctxt-current-symbol-and-bounds | ||
| 477 | (point))))) | ||
| 478 | (pattern (regexp-quote (buffer-substring start (point)))) | ||
| 479 | collection completion) | ||
| 480 | (when start | ||
| 481 | (if (and semantic--completion-cache | ||
| 482 | (eq (nth 0 semantic--completion-cache) (current-buffer)) | ||
| 483 | (= (nth 1 semantic--completion-cache) start) | ||
| 484 | (save-excursion | ||
| 485 | (goto-char start) | ||
| 486 | (looking-at (nth 3 semantic--completion-cache)))) | ||
| 487 | ;; Use cached value. | ||
| 488 | (setq collection (nthcdr 4 semantic--completion-cache)) | ||
| 489 | ;; Perform new query. | ||
| 490 | (setq collection (semantic-find-tag-for-completion pattern)) | ||
| 491 | (setq semantic--completion-cache | ||
| 492 | (append (list (current-buffer) start 0 pattern) | ||
| 493 | collection)))) | ||
| 494 | (if (null collection) | ||
| 495 | (let ((str (if pattern (format " for \"%s\"" pattern) ""))) | ||
| 496 | (if (window-minibuffer-p (selected-window)) | ||
| 497 | (minibuffer-message (format " [No completions%s]" str)) | ||
| 498 | (message "Can't find completion%s" str))) | ||
| 499 | (setq completion (try-completion pattern collection predicate)) | ||
| 500 | (if (string= pattern completion) | ||
| 501 | (let ((list (all-completions pattern collection predicate))) | ||
| 502 | (setq list (sort list 'string<)) | ||
| 503 | (if (> (length list) 1) | ||
| 504 | (with-output-to-temp-buffer "*Completions*" | ||
| 505 | (display-completion-list list pattern)) | ||
| 506 | ;; Bury any out-of-date completions buffer. | ||
| 507 | (let ((win (get-buffer-window "*Completions*" 0))) | ||
| 508 | (if win (with-selected-window win (bury-buffer)))))) | ||
| 509 | ;; Exact match | ||
| 510 | (delete-region start (point)) | ||
| 511 | (insert completion) | ||
| 512 | ;; Bury any out-of-date completions buffer. | ||
| 513 | (let ((win (get-buffer-window "*Completions*" 0))) | ||
| 514 | (if win (with-selected-window win (bury-buffer)))))))) | ||
| 515 | |||
| 440 | (provide 'semantic/util) | 516 | (provide 'semantic/util) |
| 441 | 517 | ||
| 442 | ;;; Minor modes | 518 | ;;; Minor modes |