]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge changes from CEDET upstream.
authorDavid Engster <dengste@eml.cc>
Sun, 14 Oct 2012 19:20:28 +0000 (21:20 +0200)
committerDavid Engster <dengste@eml.cc>
Sun, 14 Oct 2012 19:20:28 +0000 (21:20 +0200)
* semantic.el (semantic-error-if-unparsed): New function.  Raise
  error if buffer was not parsed by Semantic (bug #12045).
  (navigate-menu, edit-menu, cedet-menu-map): Enable Semantic items
  only if buffer was parsed.  Also, replace ':active' with ':enable'
  where necessary.

* semantic/wisent/python.el
  (semantic-python-get-system-include-path): Use
  `python-shell-internal-send-string' if available to query Python
  for system paths.

* semantic/senator.el (senator-next-tag):
  (senator-previous-tag):
  (senator-go-to-up-reference): Use `semantic-error-if-unparsed'.

* semantic/complete.el (semantic-complete-jump-local):
  (semantic-complete-jump):
  (semantic-complete-jump-local-members):
  (semantic-complete-self-insert): Use `semantic-error-if-unparsed'.
  (semantic-complete-inline-project): Fix autoload cookie.

* semantic/analyze/complete.el
  (semantic-analyze-possible-completions): Check if buffer was
  parsed.  Only raise an error if function was called interactively,
  otherwise silently return nil.

* cedet.el (cedet-menu-map): Fix copy&paste typo in menu creation.

lisp/cedet/ChangeLog
lisp/cedet/cedet.el
lisp/cedet/semantic.el
lisp/cedet/semantic/analyze/complete.el
lisp/cedet/semantic/complete.el
lisp/cedet/semantic/senator.el
lisp/cedet/semantic/wisent/python.el

index 0aeeeebc5625e727506b89dcdaa179a3cbed3edd..754bde475ad112ca80ab6f4242c41007483c5b7a 100644 (file)
@@ -1,3 +1,33 @@
+2012-10-14  David Engster  <deng@randomsample.de>
+
+       * semantic.el (semantic-error-if-unparsed): New function.  Raise
+       error if buffer was not parsed by Semantic (bug #12045).
+       (navigate-menu, edit-menu, cedet-menu-map): Enable Semantic items
+       only if buffer was parsed.  Also, replace ':active' with ':enable'
+       where necessary.
+
+       * semantic/wisent/python.el
+       (semantic-python-get-system-include-path): Use
+       `python-shell-internal-send-string' if available to query Python
+       for system paths.
+
+       * semantic/senator.el (senator-next-tag):
+       (senator-previous-tag):
+       (senator-go-to-up-reference): Use `semantic-error-if-unparsed'.
+
+       * semantic/complete.el (semantic-complete-jump-local):
+       (semantic-complete-jump):
+       (semantic-complete-jump-local-members):
+       (semantic-complete-self-insert): Use `semantic-error-if-unparsed'.
+       (semantic-complete-inline-project): Fix autoload cookie.
+
+       * semantic/analyze/complete.el
+       (semantic-analyze-possible-completions): Check if buffer was
+       parsed.  Only raise an error if function was called interactively,
+       otherwise silently return nil.
+
+       * cedet.el (cedet-menu-map): Fix copy&paste typo in menu creation.
+
 2012-10-07  David Engster  <deng@randomsample.de>
 
        * semantic/wisent/python.el (semantic-ctxt-current-function)
index 5c21e4ab538705ab6bc7e88a0123395c9dbebb94..327a72f9dc7a6d6d78e821aeaef8ec377af8e8ec 100644 (file)
@@ -59,7 +59,7 @@
     (define-key map [navigate-menu]              'undefined)
     (define-key map [semantic-options-separator] 'undefined)
     (define-key map [global-semantic-highlight-func-mode]   'undefined)
-    (define-key map [global-semantic-highlight-func-mode]   'undefined)
+    (define-key map [global-semantic-stickyfunc-mode]   'undefined)
     (define-key map [global-semantic-decoration-mode]       'undefined)
     (define-key map [global-semantic-idle-completions-mode] 'undefined)
     (define-key map [global-semantic-idle-summary-mode]     'undefined)
index e02790cbfa881eab98320491e2fcbe9772f942ff..373864a43d542c66c472da5dc785dce75fbf698c 100644 (file)
@@ -319,6 +319,11 @@ a parse of the buffer.")
   "Return non-nil if the current buffer was set up for parsing."
   semantic-new-buffer-fcn-was-run)
 
+(defsubst semantic-error-if-unparsed ()
+  "Raise an error if current buffer was not parsed by Semantic."
+  (unless semantic-new-buffer-fcn-was-run
+    (error "Buffer was not parsed by Semantic.")))
+
 (defsubst semantic--umatched-syntax-needs-refresh-p  ()
   "Return non-nil if the unmatched syntax cache needs a refresh.
 That is, if it is dirty or if the current parse tree isn't up to date."
@@ -907,75 +912,91 @@ Throw away all the old tags, and recreate the tag database."
   ;; Edit Tags submenu:
   (define-key edit-menu [semantic-analyze-possible-completions]
     '(menu-item "List Completions" semantic-analyze-possible-completions
+               :enable (semantic-active-p)
                :help "Display a list of completions for the tag at point"))
   (define-key edit-menu [semantic-complete-analyze-inline]
     '(menu-item "Complete Tag Inline" semantic-complete-analyze-inline
+               :enable (semantic-active-p)
                :help "Display inline completion for the tag at point"))
   (define-key edit-menu [semantic-completion-separator]
     '("--"))
   (define-key edit-menu [senator-transpose-tags-down]
     '(menu-item "Transpose Tags Down" senator-transpose-tags-down
-               :active (semantic-current-tag)
+               :enable (and (semantic-active-p)
+                            (semantic-current-tag))
                :help "Transpose the current tag and the next tag"))
   (define-key edit-menu [senator-transpose-tags-up]
     '(menu-item "Transpose Tags Up" senator-transpose-tags-up
-               :active (semantic-current-tag)
+               :enable (and (semantic-active-p)
+                            (semantic-current-tag))
                :help "Transpose the current tag and the previous tag"))
   (define-key edit-menu [semantic-edit-separator]
     '("--"))
   (define-key edit-menu [senator-yank-tag]
     '(menu-item "Yank Tag" senator-yank-tag
-               :active (not (ring-empty-p senator-tag-ring))
+               :enable (not (ring-empty-p senator-tag-ring))
                :help "Yank the head of the tag ring into the buffer"))
   (define-key edit-menu [senator-copy-tag-to-register]
     '(menu-item "Copy Tag To Register" senator-copy-tag-to-register
-               :active (semantic-current-tag)
+               :enable (and (semantic-active-p)
+                            (semantic-current-tag))
                :help "Yank the head of the tag ring into the buffer"))
   (define-key edit-menu [senator-copy-tag]
     '(menu-item "Copy Tag" senator-copy-tag
-               :active (semantic-current-tag)
+               :enable (and (semantic-active-p)
+                            (semantic-current-tag))
                :help "Copy the current tag to the tag ring"))
   (define-key edit-menu [senator-kill-tag]
     '(menu-item "Kill Tag" senator-kill-tag
-               :active (semantic-current-tag)
+               :enable (and (semantic-active-p)
+                            (semantic-current-tag))
                :help "Kill the current tag, and copy it to the tag ring"))
 
   ;; Navigate Tags submenu:
   (define-key navigate-menu [senator-narrow-to-defun]
     '(menu-item "Narrow to Tag" senator-narrow-to-defun
-               :active (semantic-current-tag)
+               :enable (and (semantic-active-p)
+                            (semantic-current-tag))
                :help "Narrow the buffer to the bounds of the current tag"))
   (define-key navigate-menu [semantic-narrow-to-defun-separator]
     '("--"))
   (define-key navigate-menu [semantic-symref-symbol]
     '(menu-item "Find Tag References..." semantic-symref-symbol
+               :enable (semantic-active-p)
                :help "Read a tag and list the references to it"))
   (define-key navigate-menu [semantic-complete-jump]
     '(menu-item "Find Tag Globally..." semantic-complete-jump
+               :enable (semantic-active-p)
                :help "Read a tag name and find it in the current project"))
   (define-key navigate-menu [semantic-complete-jump-local-members]
     '(menu-item "Find Local Members ..." semantic-complete-jump-local-members
+               :enable (semantic-active-p)
                :help "Read a tag name and find a local member with that name"))
   (define-key navigate-menu [semantic-complete-jump-local]
     '(menu-item "Find Tag in This Buffer..." semantic-complete-jump-local
+               :enable (semantic-active-p)
                :help "Read a tag name and find it in this buffer"))
   (define-key navigate-menu [semantic-navigation-separator]
     '("--"))
   (define-key navigate-menu [senator-go-to-up-reference]
     '(menu-item "Parent Tag" senator-go-to-up-reference
+               :enable (semantic-active-p)
                :help "Navigate up one reference by tag"))
   (define-key navigate-menu [senator-next-tag]
     '(menu-item "Next Tag" senator-next-tag
+               :enable (semantic-active-p)
                :help "Go to the next tag"))
   (define-key navigate-menu [senator-previous-tag]
     '(menu-item "Previous Tag" senator-previous-tag
+               :enable (semantic-active-p)
                :help "Go to the previous tag"))
 
   ;; Top level menu items:
   (define-key cedet-menu-map [semantic-force-refresh]
     '(menu-item "Reparse Buffer" semantic-force-refresh
                :help "Force a full reparse of the current buffer"
-               :visible semantic-mode))
+               :visible semantic-mode
+               :enable (semantic-active-p)))
   (define-key cedet-menu-map [semantic-edit-menu]
     `(menu-item "Edit Tags" ,edit-menu
                :visible semantic-mode))
index edc3cdc230cabcadb9e111cf8d4ba3e687bd88c5..bb9bbf6352f62a0960ea741d6f829f09bd43e25a 100644 (file)
@@ -87,20 +87,25 @@ in a buffer."
   ;; In theory, we don't need the below since the context will
   ;; do it for us.
   ;;(semantic-refresh-tags-safe)
-  (with-syntax-table semantic-lex-syntax-table
-    (let* ((context (if (semantic-analyze-context-child-p context)
-                        context
-                      (semantic-analyze-current-context context)))
-          (ans (if (not context)
-                   (error "Nothing to complete")
-                 (:override))))
-      ;; If interactive, display them.
-      (when (called-interactively-p 'any)
-       (with-output-to-temp-buffer "*Possible Completions*"
-         (semantic-analyze-princ-sequence ans "" (current-buffer)))
-       (shrink-window-if-larger-than-buffer
-        (get-buffer-window "*Possible Completions*")))
-      ans)))
+  (if (semantic-active-p)
+    (with-syntax-table semantic-lex-syntax-table
+      (let* ((context (if (semantic-analyze-context-child-p context)
+                         context
+                       (semantic-analyze-current-context context)))
+            (ans (if (not context)
+                     (error "Nothing to complete")
+                   (:override))))
+       ;; If interactive, display them.
+       (when (called-interactively-p 'any)
+         (with-output-to-temp-buffer "*Possible Completions*"
+           (semantic-analyze-princ-sequence ans "" (current-buffer)))
+         (shrink-window-if-larger-than-buffer
+          (get-buffer-window "*Possible Completions*")))
+       ans))
+    ;; Buffer was not parsed by Semantic.
+    ;; Raise error if called interactively.
+    (when (cedet-called-interactively-p 'any)
+      (error "Buffer was not parsed by Semantic."))))
 
 (defun semantic-analyze-possible-completions-default (context &optional flags)
   "Default method for producing smart completions.
index 9c2da9faefa8455ec4a371cbf41b1e98195b0ede..59d17f2f8bba29fb6791fa7e96612d7af61e21a7 100644 (file)
@@ -2088,6 +2088,7 @@ completion works."
 (defun semantic-complete-jump-local ()
   "Jump to a local semantic symbol."
   (interactive)
+  (semantic-error-if-unparsed)
   (let ((tag (semantic-complete-read-tag-buffer-deep "Jump to symbol: ")))
     (when (semantic-tag-p tag)
       (push-mark)
@@ -2101,6 +2102,7 @@ completion works."
 (defun semantic-complete-jump ()
   "Jump to a semantic symbol."
   (interactive)
+  (semantic-error-if-unparsed)
   (let* ((tag (semantic-complete-read-tag-project "Jump to symbol: ")))
     (when (semantic-tag-p tag)
       (push-mark)
@@ -2115,6 +2117,7 @@ completion works."
 (defun semantic-complete-jump-local-members ()
   "Jump to a semantic symbol."
   (interactive)
+  (semantic-error-if-unparsed)
   (let* ((tag (semantic-complete-read-tag-local-members "Jump to symbol: ")))
     (when (semantic-tag-p tag)
       (let ((start (condition-case nil (semantic-tag-start tag)
@@ -2216,7 +2219,7 @@ use `semantic-complete-analyze-inline' to complete."
       (error nil))
     ))
 
-;;;;###autoload
+;;;###autoload
 (defun semantic-complete-inline-project ()
   "Perform inline completion for any symbol in the current project.
 `semantic-analyze-possible-completions' is used to determine the
index 64f99a8ad6f881f9478012ec069a43a934ff6a6d..1138c13096abf52de773f0ff1a11b002a176a7c4 100644 (file)
@@ -255,6 +255,7 @@ TEXT, BOUND, NOERROR, and COUNT arguments are interpreted."
   "Navigate to the next Semantic tag.
 Return the tag or nil if at end of buffer."
   (interactive)
+  (semantic-error-if-unparsed)
   (let ((pos (point))
         (tag (semantic-current-tag))
         where)
@@ -294,6 +295,7 @@ Return the tag or nil if at end of buffer."
   "Navigate to the previous Semantic tag.
 Return the tag or nil if at beginning of buffer."
   (interactive)
+  (semantic-error-if-unparsed)
   (let ((pos (point))
         (tag (semantic-current-tag))
         where)
@@ -519,6 +521,7 @@ If that parent which is only a reference in the function tag
 is found, we can jump to it.
 Some tags such as includes have other reference features."
   (interactive)
+  (semantic-error-if-unparsed)
   (let ((result (semantic-up-reference (or tag (semantic-current-tag)))))
     (if (not result)
         (error "No up reference found")
index a0ea488f0fe99c06c689b8c95ae047c161af9614..89c0499b7dabb394f04278e76a3cd073fef7ee2f 100644 (file)
 
 (defun semantic-python-get-system-include-path ()
   "Evaluate some Python code that determines the system include path."
-  (python-proc)
-  (if python-buffer
-      (with-current-buffer python-buffer
-       (set (make-local-variable 'python-preoutput-result) nil)
-       (python-send-string
-        "import sys; print '_emacs_out ' + '\\0'.join(sys.path)")
-       (accept-process-output (python-proc) 2)
-       (if python-preoutput-result
-           (split-string python-preoutput-result "[\0\n]" t)
-         ;; Try a second, Python3k compatible shot
-         (python-send-string
-          "import sys; print('_emacs_out ' + '\\0'.join(sys.path))")
-         (accept-process-output (python-proc) 2)
-         (if python-preoutput-result
-             (split-string python-preoutput-result "[\0\n]" t)
-           (message "Timeout while querying Python for system include path.")
-           nil)))
-    (message "Python seems to be unavailable on this system.")))
+  (delq nil
+       (mapcar
+        (lambda (dir)
+          (when (file-directory-p dir)
+            dir))
+        (split-string
+         (python-shell-internal-send-string
+          "import sys;print ('\\n'.join(sys.path))")
+         "\n" t))))
 
 (defcustom-mode-local-semantic-dependency-system-include-path
   python-mode semantic-python-dependency-system-include-path