]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/ia.el
Merge from emacs-24
[gnu-emacs] / lisp / cedet / semantic / ia.el
index 69b1dba0bcfb51909a3e471c8909714e5d8286e2..8a5cbac41293b15d3b4ca1e82869b646dbf19393 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic/ia.el --- Interactive Analysis functions
 
-;;; Copyright (C) 2000-2011 Free Software Foundation, Inc.
+;;; Copyright (C) 2000-2014 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: syntax
 (require 'semantic/analyze)
 (require 'semantic/format)
 (require 'pulse)
+(require 'semantic/senator)
+(require 'semantic/analyze/refs)
 (eval-when-compile
   (require 'semantic/analyze)
-  (require 'semantic/analyze/refs)
   (require 'semantic/find))
 
 (declare-function imenu--mouse-menu "imenu")
@@ -115,14 +116,15 @@ Completion options are calculated with `semantic-analyze-possible-completions'."
       (if (null syms)
          (if (semantic-analyze-context-p a)
              ;; This is a clever hack.  If we were unable to find any
-             ;; smart completions, lets divert to how senator derives
+             ;; smart completions, let's divert to how senator derives
              ;; completions.
              ;;
              ;; This is a way of making this fcn more useful since
-             ;; the smart completion engine sometimes failes.
+             ;; the smart completion engine sometimes fails.
              (semantic-complete-symbol))
        ;; Use try completion to seek a common substring.
-       (let ((tc (try-completion (or pre "")  syms)))
+       (let* ((completion-ignore-case (string= (downcase pre) pre))
+              (tc (try-completion (or pre "")  syms)))
          (if (and (stringp tc) (not (string= tc (or pre ""))))
              (let ((tok (semantic-find-first-tag-by-name
                          tc syms)))
@@ -143,11 +145,53 @@ Completion options are calculated with `semantic-analyze-possible-completions'."
               (mapcar semantic-ia-completion-format-tag-function syms)))))))))
 
 (defcustom semantic-ia-completion-menu-format-tag-function
-  'semantic-uml-concise-prototype-nonterminal
+  'semantic-format-tag-uml-concise-prototype
   "*Function used to convert a tag to a string during completion."
   :group 'semantic
   :type semantic-format-tag-custom-list)
 
+;;;###autoload
+(defun semantic-ia-complete-symbol-menu (point)
+  "Complete the current symbol via a menu based at POINT.
+Completion options are calculated with `semantic-analyze-possible-completions'."
+  (interactive "d")
+  (require 'imenu)
+  (let* ((a (semantic-analyze-current-context point))
+        (syms (semantic-analyze-possible-completions a))
+        )
+    ;; Complete this symbol.
+    (if (not syms)
+       (progn
+         (message "No smart completions found.")
+          ;; Disabled - see http://debbugs.gnu.org/14522
+         ;; (message "No smart completions found.  Trying Senator.")
+         ;; (when (semantic-analyze-context-p a)
+         ;;   ;; This is a quick way of getting a nice completion list
+         ;;   ;; in the menu if the regular context mechanism fails.
+         ;;   (senator-completion-menu-popup))
+          )
+
+      (let* ((menu
+             (mapcar
+              (lambda (tag)
+                (cons
+                 (funcall semantic-ia-completion-menu-format-tag-function tag)
+                 (vector tag)))
+              syms))
+            (ans
+             (imenu--mouse-menu
+              ;; XEmacs needs that the menu has at least 2 items.  So,
+              ;; include a nil item that will be ignored by imenu.
+              (cons nil menu)
+              `(down-mouse-1 ,(posn-at-point))
+              "Completions")))
+       (when ans
+         (if (not (semantic-tag-p ans))
+             (setq ans (aref (cdr ans) 0)))
+         (delete-region (car (oref a bounds)) (cdr (oref a bounds)))
+         (semantic-ia-insert-tag ans))
+       ))))
+
 ;;; Completions Tip
 ;;
 ;; This functions shows how to get the list of completions,
@@ -199,7 +243,7 @@ Completion options are calculated with `semantic-analyze-possible-completions'."
        )
     (if pf
        (message "%s" (semantic-format-tag-summarize pf nil t))
-      (message "No summary info availalble"))))
+      (message "No summary info available"))))
 
 ;;; Variants
 ;;
@@ -245,14 +289,14 @@ Completion options are calculated with `semantic-analyze-possible-completions'."
 ;; Jump to a destination based on the local context.
 ;;
 ;; This shows how to use the analyzer context, and the
-;; analyer references objects to choose a good destination.
+;; analyzer references objects to choose a good destination.
 
 (defun semantic-ia--fast-jump-helper (dest)
   "Jump to DEST, a Semantic tag.
 This helper manages the mark, buffer switching, and pulsing."
   ;; We have a tag, but in C++, we usually get a prototype instead
-  ;; because of header files.  Lets try to find the actual
-  ;; implementaion instead.
+  ;; because of header files.  Let's try to find the actual
+  ;; implementation instead.
   (when (semantic-tag-prototype-p dest)
     (let* ((refs (semantic-analyze-tag-references dest))
           (impl (semantic-analyze-refs-impl refs t))
@@ -335,6 +379,13 @@ origin of the code at point."
      ((semantic-tag-of-class-p (semantic-current-tag) 'include)
       ;; Just borrow this cool fcn.
       (require 'semantic/decorate/include)
+
+      ;; Push the mark, so you can pop global mark back, or
+      ;; use semantic-mru-bookmark mode to do so.
+      (push-mark)
+      (when (fboundp 'push-tag-mark)
+       (push-tag-mark))
+
       (semantic-decoration-include-visit)
       )