]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/wisent/python.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / wisent / python.el
index a0ea488f0fe99c06c689b8c95ae047c161af9614..a8348d2ab81ef263fd386f07efda653ea62abbb4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; wisent-python.el --- Semantic support for Python
 
-;; Copyright (C) 2002, 2004, 2006-201 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004, 2006-2015 Free Software Foundation, Inc.
 
 ;; Author: Richard Kim  <emacs18@gmail.com>
 ;; Maintainer: Richard Kim  <emacs18@gmail.com>
@@ -39,6 +39,7 @@
 (require 'semantic/find)
 (require 'semantic/dep)
 (require 'semantic/ctxt)
+(require 'semantic/format)
 
 (eval-when-compile
   (require 'cl))
 
 (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
@@ -494,6 +486,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'.
 ;;