aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Engster2012-10-14 21:20:28 +0200
committerDavid Engster2012-10-14 21:20:28 +0200
commitbf659b3f5819b9c3664c08fb01a7e51efff01fe4 (patch)
treed771152303dd23f2aed4844bd6f73daf2d754225
parent740877cd2346da5fa3e2085185cd51912eebf0a0 (diff)
downloademacs-bf659b3f5819b9c3664c08fb01a7e51efff01fe4.tar.gz
emacs-bf659b3f5819b9c3664c08fb01a7e51efff01fe4.zip
Merge changes from CEDET upstream.
* 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.
-rw-r--r--lisp/cedet/ChangeLog30
-rw-r--r--lisp/cedet/cedet.el2
-rw-r--r--lisp/cedet/semantic.el37
-rw-r--r--lisp/cedet/semantic/analyze/complete.el33
-rw-r--r--lisp/cedet/semantic/complete.el5
-rw-r--r--lisp/cedet/semantic/senator.el3
-rw-r--r--lisp/cedet/semantic/wisent/python.el27
7 files changed, 95 insertions, 42 deletions
diff --git a/lisp/cedet/ChangeLog b/lisp/cedet/ChangeLog
index 0aeeeebc562..754bde475ad 100644
--- a/lisp/cedet/ChangeLog
+++ b/lisp/cedet/ChangeLog
@@ -1,3 +1,33 @@
12012-10-14 David Engster <deng@randomsample.de>
2
3 * semantic.el (semantic-error-if-unparsed): New function. Raise
4 error if buffer was not parsed by Semantic (bug #12045).
5 (navigate-menu, edit-menu, cedet-menu-map): Enable Semantic items
6 only if buffer was parsed. Also, replace ':active' with ':enable'
7 where necessary.
8
9 * semantic/wisent/python.el
10 (semantic-python-get-system-include-path): Use
11 `python-shell-internal-send-string' if available to query Python
12 for system paths.
13
14 * semantic/senator.el (senator-next-tag):
15 (senator-previous-tag):
16 (senator-go-to-up-reference): Use `semantic-error-if-unparsed'.
17
18 * semantic/complete.el (semantic-complete-jump-local):
19 (semantic-complete-jump):
20 (semantic-complete-jump-local-members):
21 (semantic-complete-self-insert): Use `semantic-error-if-unparsed'.
22 (semantic-complete-inline-project): Fix autoload cookie.
23
24 * semantic/analyze/complete.el
25 (semantic-analyze-possible-completions): Check if buffer was
26 parsed. Only raise an error if function was called interactively,
27 otherwise silently return nil.
28
29 * cedet.el (cedet-menu-map): Fix copy&paste typo in menu creation.
30
12012-10-07 David Engster <deng@randomsample.de> 312012-10-07 David Engster <deng@randomsample.de>
2 32
3 * semantic/wisent/python.el (semantic-ctxt-current-function) 33 * semantic/wisent/python.el (semantic-ctxt-current-function)
diff --git a/lisp/cedet/cedet.el b/lisp/cedet/cedet.el
index 5c21e4ab538..327a72f9dc7 100644
--- a/lisp/cedet/cedet.el
+++ b/lisp/cedet/cedet.el
@@ -59,7 +59,7 @@
59 (define-key map [navigate-menu] 'undefined) 59 (define-key map [navigate-menu] 'undefined)
60 (define-key map [semantic-options-separator] 'undefined) 60 (define-key map [semantic-options-separator] 'undefined)
61 (define-key map [global-semantic-highlight-func-mode] 'undefined) 61 (define-key map [global-semantic-highlight-func-mode] 'undefined)
62 (define-key map [global-semantic-highlight-func-mode] 'undefined) 62 (define-key map [global-semantic-stickyfunc-mode] 'undefined)
63 (define-key map [global-semantic-decoration-mode] 'undefined) 63 (define-key map [global-semantic-decoration-mode] 'undefined)
64 (define-key map [global-semantic-idle-completions-mode] 'undefined) 64 (define-key map [global-semantic-idle-completions-mode] 'undefined)
65 (define-key map [global-semantic-idle-summary-mode] 'undefined) 65 (define-key map [global-semantic-idle-summary-mode] 'undefined)
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index e02790cbfa8..373864a43d5 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -319,6 +319,11 @@ a parse of the buffer.")
319 "Return non-nil if the current buffer was set up for parsing." 319 "Return non-nil if the current buffer was set up for parsing."
320 semantic-new-buffer-fcn-was-run) 320 semantic-new-buffer-fcn-was-run)
321 321
322(defsubst semantic-error-if-unparsed ()
323 "Raise an error if current buffer was not parsed by Semantic."
324 (unless semantic-new-buffer-fcn-was-run
325 (error "Buffer was not parsed by Semantic.")))
326
322(defsubst semantic--umatched-syntax-needs-refresh-p () 327(defsubst semantic--umatched-syntax-needs-refresh-p ()
323 "Return non-nil if the unmatched syntax cache needs a refresh. 328 "Return non-nil if the unmatched syntax cache needs a refresh.
324That is, if it is dirty or if the current parse tree isn't up to date." 329That 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."
907 ;; Edit Tags submenu: 912 ;; Edit Tags submenu:
908 (define-key edit-menu [semantic-analyze-possible-completions] 913 (define-key edit-menu [semantic-analyze-possible-completions]
909 '(menu-item "List Completions" semantic-analyze-possible-completions 914 '(menu-item "List Completions" semantic-analyze-possible-completions
915 :enable (semantic-active-p)
910 :help "Display a list of completions for the tag at point")) 916 :help "Display a list of completions for the tag at point"))
911 (define-key edit-menu [semantic-complete-analyze-inline] 917 (define-key edit-menu [semantic-complete-analyze-inline]
912 '(menu-item "Complete Tag Inline" semantic-complete-analyze-inline 918 '(menu-item "Complete Tag Inline" semantic-complete-analyze-inline
919 :enable (semantic-active-p)
913 :help "Display inline completion for the tag at point")) 920 :help "Display inline completion for the tag at point"))
914 (define-key edit-menu [semantic-completion-separator] 921 (define-key edit-menu [semantic-completion-separator]
915 '("--")) 922 '("--"))
916 (define-key edit-menu [senator-transpose-tags-down] 923 (define-key edit-menu [senator-transpose-tags-down]
917 '(menu-item "Transpose Tags Down" senator-transpose-tags-down 924 '(menu-item "Transpose Tags Down" senator-transpose-tags-down
918 :active (semantic-current-tag) 925 :enable (and (semantic-active-p)
926 (semantic-current-tag))
919 :help "Transpose the current tag and the next tag")) 927 :help "Transpose the current tag and the next tag"))
920 (define-key edit-menu [senator-transpose-tags-up] 928 (define-key edit-menu [senator-transpose-tags-up]
921 '(menu-item "Transpose Tags Up" senator-transpose-tags-up 929 '(menu-item "Transpose Tags Up" senator-transpose-tags-up
922 :active (semantic-current-tag) 930 :enable (and (semantic-active-p)
931 (semantic-current-tag))
923 :help "Transpose the current tag and the previous tag")) 932 :help "Transpose the current tag and the previous tag"))
924 (define-key edit-menu [semantic-edit-separator] 933 (define-key edit-menu [semantic-edit-separator]
925 '("--")) 934 '("--"))
926 (define-key edit-menu [senator-yank-tag] 935 (define-key edit-menu [senator-yank-tag]
927 '(menu-item "Yank Tag" senator-yank-tag 936 '(menu-item "Yank Tag" senator-yank-tag
928 :active (not (ring-empty-p senator-tag-ring)) 937 :enable (not (ring-empty-p senator-tag-ring))
929 :help "Yank the head of the tag ring into the buffer")) 938 :help "Yank the head of the tag ring into the buffer"))
930 (define-key edit-menu [senator-copy-tag-to-register] 939 (define-key edit-menu [senator-copy-tag-to-register]
931 '(menu-item "Copy Tag To Register" senator-copy-tag-to-register 940 '(menu-item "Copy Tag To Register" senator-copy-tag-to-register
932 :active (semantic-current-tag) 941 :enable (and (semantic-active-p)
942 (semantic-current-tag))
933 :help "Yank the head of the tag ring into the buffer")) 943 :help "Yank the head of the tag ring into the buffer"))
934 (define-key edit-menu [senator-copy-tag] 944 (define-key edit-menu [senator-copy-tag]
935 '(menu-item "Copy Tag" senator-copy-tag 945 '(menu-item "Copy Tag" senator-copy-tag
936 :active (semantic-current-tag) 946 :enable (and (semantic-active-p)
947 (semantic-current-tag))
937 :help "Copy the current tag to the tag ring")) 948 :help "Copy the current tag to the tag ring"))
938 (define-key edit-menu [senator-kill-tag] 949 (define-key edit-menu [senator-kill-tag]
939 '(menu-item "Kill Tag" senator-kill-tag 950 '(menu-item "Kill Tag" senator-kill-tag
940 :active (semantic-current-tag) 951 :enable (and (semantic-active-p)
952 (semantic-current-tag))
941 :help "Kill the current tag, and copy it to the tag ring")) 953 :help "Kill the current tag, and copy it to the tag ring"))
942 954
943 ;; Navigate Tags submenu: 955 ;; Navigate Tags submenu:
944 (define-key navigate-menu [senator-narrow-to-defun] 956 (define-key navigate-menu [senator-narrow-to-defun]
945 '(menu-item "Narrow to Tag" senator-narrow-to-defun 957 '(menu-item "Narrow to Tag" senator-narrow-to-defun
946 :active (semantic-current-tag) 958 :enable (and (semantic-active-p)
959 (semantic-current-tag))
947 :help "Narrow the buffer to the bounds of the current tag")) 960 :help "Narrow the buffer to the bounds of the current tag"))
948 (define-key navigate-menu [semantic-narrow-to-defun-separator] 961 (define-key navigate-menu [semantic-narrow-to-defun-separator]
949 '("--")) 962 '("--"))
950 (define-key navigate-menu [semantic-symref-symbol] 963 (define-key navigate-menu [semantic-symref-symbol]
951 '(menu-item "Find Tag References..." semantic-symref-symbol 964 '(menu-item "Find Tag References..." semantic-symref-symbol
965 :enable (semantic-active-p)
952 :help "Read a tag and list the references to it")) 966 :help "Read a tag and list the references to it"))
953 (define-key navigate-menu [semantic-complete-jump] 967 (define-key navigate-menu [semantic-complete-jump]
954 '(menu-item "Find Tag Globally..." semantic-complete-jump 968 '(menu-item "Find Tag Globally..." semantic-complete-jump
969 :enable (semantic-active-p)
955 :help "Read a tag name and find it in the current project")) 970 :help "Read a tag name and find it in the current project"))
956 (define-key navigate-menu [semantic-complete-jump-local-members] 971 (define-key navigate-menu [semantic-complete-jump-local-members]
957 '(menu-item "Find Local Members ..." semantic-complete-jump-local-members 972 '(menu-item "Find Local Members ..." semantic-complete-jump-local-members
973 :enable (semantic-active-p)
958 :help "Read a tag name and find a local member with that name")) 974 :help "Read a tag name and find a local member with that name"))
959 (define-key navigate-menu [semantic-complete-jump-local] 975 (define-key navigate-menu [semantic-complete-jump-local]
960 '(menu-item "Find Tag in This Buffer..." semantic-complete-jump-local 976 '(menu-item "Find Tag in This Buffer..." semantic-complete-jump-local
977 :enable (semantic-active-p)
961 :help "Read a tag name and find it in this buffer")) 978 :help "Read a tag name and find it in this buffer"))
962 (define-key navigate-menu [semantic-navigation-separator] 979 (define-key navigate-menu [semantic-navigation-separator]
963 '("--")) 980 '("--"))
964 (define-key navigate-menu [senator-go-to-up-reference] 981 (define-key navigate-menu [senator-go-to-up-reference]
965 '(menu-item "Parent Tag" senator-go-to-up-reference 982 '(menu-item "Parent Tag" senator-go-to-up-reference
983 :enable (semantic-active-p)
966 :help "Navigate up one reference by tag")) 984 :help "Navigate up one reference by tag"))
967 (define-key navigate-menu [senator-next-tag] 985 (define-key navigate-menu [senator-next-tag]
968 '(menu-item "Next Tag" senator-next-tag 986 '(menu-item "Next Tag" senator-next-tag
987 :enable (semantic-active-p)
969 :help "Go to the next tag")) 988 :help "Go to the next tag"))
970 (define-key navigate-menu [senator-previous-tag] 989 (define-key navigate-menu [senator-previous-tag]
971 '(menu-item "Previous Tag" senator-previous-tag 990 '(menu-item "Previous Tag" senator-previous-tag
991 :enable (semantic-active-p)
972 :help "Go to the previous tag")) 992 :help "Go to the previous tag"))
973 993
974 ;; Top level menu items: 994 ;; Top level menu items:
975 (define-key cedet-menu-map [semantic-force-refresh] 995 (define-key cedet-menu-map [semantic-force-refresh]
976 '(menu-item "Reparse Buffer" semantic-force-refresh 996 '(menu-item "Reparse Buffer" semantic-force-refresh
977 :help "Force a full reparse of the current buffer" 997 :help "Force a full reparse of the current buffer"
978 :visible semantic-mode)) 998 :visible semantic-mode
999 :enable (semantic-active-p)))
979 (define-key cedet-menu-map [semantic-edit-menu] 1000 (define-key cedet-menu-map [semantic-edit-menu]
980 `(menu-item "Edit Tags" ,edit-menu 1001 `(menu-item "Edit Tags" ,edit-menu
981 :visible semantic-mode)) 1002 :visible semantic-mode))
diff --git a/lisp/cedet/semantic/analyze/complete.el b/lisp/cedet/semantic/analyze/complete.el
index edc3cdc230c..bb9bbf6352f 100644
--- a/lisp/cedet/semantic/analyze/complete.el
+++ b/lisp/cedet/semantic/analyze/complete.el
@@ -87,20 +87,25 @@ in a buffer."
87 ;; In theory, we don't need the below since the context will 87 ;; In theory, we don't need the below since the context will
88 ;; do it for us. 88 ;; do it for us.
89 ;;(semantic-refresh-tags-safe) 89 ;;(semantic-refresh-tags-safe)
90 (with-syntax-table semantic-lex-syntax-table 90 (if (semantic-active-p)
91 (let* ((context (if (semantic-analyze-context-child-p context) 91 (with-syntax-table semantic-lex-syntax-table
92 context 92 (let* ((context (if (semantic-analyze-context-child-p context)
93 (semantic-analyze-current-context context))) 93 context
94 (ans (if (not context) 94 (semantic-analyze-current-context context)))
95 (error "Nothing to complete") 95 (ans (if (not context)
96 (:override)))) 96 (error "Nothing to complete")
97 ;; If interactive, display them. 97 (:override))))
98 (when (called-interactively-p 'any) 98 ;; If interactive, display them.
99 (with-output-to-temp-buffer "*Possible Completions*" 99 (when (called-interactively-p 'any)
100 (semantic-analyze-princ-sequence ans "" (current-buffer))) 100 (with-output-to-temp-buffer "*Possible Completions*"
101 (shrink-window-if-larger-than-buffer 101 (semantic-analyze-princ-sequence ans "" (current-buffer)))
102 (get-buffer-window "*Possible Completions*"))) 102 (shrink-window-if-larger-than-buffer
103 ans))) 103 (get-buffer-window "*Possible Completions*")))
104 ans))
105 ;; Buffer was not parsed by Semantic.
106 ;; Raise error if called interactively.
107 (when (cedet-called-interactively-p 'any)
108 (error "Buffer was not parsed by Semantic."))))
104 109
105(defun semantic-analyze-possible-completions-default (context &optional flags) 110(defun semantic-analyze-possible-completions-default (context &optional flags)
106 "Default method for producing smart completions. 111 "Default method for producing smart completions.
diff --git a/lisp/cedet/semantic/complete.el b/lisp/cedet/semantic/complete.el
index 9c2da9faefa..59d17f2f8bb 100644
--- a/lisp/cedet/semantic/complete.el
+++ b/lisp/cedet/semantic/complete.el
@@ -2088,6 +2088,7 @@ completion works."
2088(defun semantic-complete-jump-local () 2088(defun semantic-complete-jump-local ()
2089 "Jump to a local semantic symbol." 2089 "Jump to a local semantic symbol."
2090 (interactive) 2090 (interactive)
2091 (semantic-error-if-unparsed)
2091 (let ((tag (semantic-complete-read-tag-buffer-deep "Jump to symbol: "))) 2092 (let ((tag (semantic-complete-read-tag-buffer-deep "Jump to symbol: ")))
2092 (when (semantic-tag-p tag) 2093 (when (semantic-tag-p tag)
2093 (push-mark) 2094 (push-mark)
@@ -2101,6 +2102,7 @@ completion works."
2101(defun semantic-complete-jump () 2102(defun semantic-complete-jump ()
2102 "Jump to a semantic symbol." 2103 "Jump to a semantic symbol."
2103 (interactive) 2104 (interactive)
2105 (semantic-error-if-unparsed)
2104 (let* ((tag (semantic-complete-read-tag-project "Jump to symbol: "))) 2106 (let* ((tag (semantic-complete-read-tag-project "Jump to symbol: ")))
2105 (when (semantic-tag-p tag) 2107 (when (semantic-tag-p tag)
2106 (push-mark) 2108 (push-mark)
@@ -2115,6 +2117,7 @@ completion works."
2115(defun semantic-complete-jump-local-members () 2117(defun semantic-complete-jump-local-members ()
2116 "Jump to a semantic symbol." 2118 "Jump to a semantic symbol."
2117 (interactive) 2119 (interactive)
2120 (semantic-error-if-unparsed)
2118 (let* ((tag (semantic-complete-read-tag-local-members "Jump to symbol: "))) 2121 (let* ((tag (semantic-complete-read-tag-local-members "Jump to symbol: ")))
2119 (when (semantic-tag-p tag) 2122 (when (semantic-tag-p tag)
2120 (let ((start (condition-case nil (semantic-tag-start tag) 2123 (let ((start (condition-case nil (semantic-tag-start tag)
@@ -2216,7 +2219,7 @@ use `semantic-complete-analyze-inline' to complete."
2216 (error nil)) 2219 (error nil))
2217 )) 2220 ))
2218 2221
2219;;;;###autoload 2222;;;###autoload
2220(defun semantic-complete-inline-project () 2223(defun semantic-complete-inline-project ()
2221 "Perform inline completion for any symbol in the current project. 2224 "Perform inline completion for any symbol in the current project.
2222`semantic-analyze-possible-completions' is used to determine the 2225`semantic-analyze-possible-completions' is used to determine the
diff --git a/lisp/cedet/semantic/senator.el b/lisp/cedet/semantic/senator.el
index 64f99a8ad6f..1138c13096a 100644
--- a/lisp/cedet/semantic/senator.el
+++ b/lisp/cedet/semantic/senator.el
@@ -255,6 +255,7 @@ TEXT, BOUND, NOERROR, and COUNT arguments are interpreted."
255 "Navigate to the next Semantic tag. 255 "Navigate to the next Semantic tag.
256Return the tag or nil if at end of buffer." 256Return the tag or nil if at end of buffer."
257 (interactive) 257 (interactive)
258 (semantic-error-if-unparsed)
258 (let ((pos (point)) 259 (let ((pos (point))
259 (tag (semantic-current-tag)) 260 (tag (semantic-current-tag))
260 where) 261 where)
@@ -294,6 +295,7 @@ Return the tag or nil if at end of buffer."
294 "Navigate to the previous Semantic tag. 295 "Navigate to the previous Semantic tag.
295Return the tag or nil if at beginning of buffer." 296Return the tag or nil if at beginning of buffer."
296 (interactive) 297 (interactive)
298 (semantic-error-if-unparsed)
297 (let ((pos (point)) 299 (let ((pos (point))
298 (tag (semantic-current-tag)) 300 (tag (semantic-current-tag))
299 where) 301 where)
@@ -519,6 +521,7 @@ If that parent which is only a reference in the function tag
519is found, we can jump to it. 521is found, we can jump to it.
520Some tags such as includes have other reference features." 522Some tags such as includes have other reference features."
521 (interactive) 523 (interactive)
524 (semantic-error-if-unparsed)
522 (let ((result (semantic-up-reference (or tag (semantic-current-tag))))) 525 (let ((result (semantic-up-reference (or tag (semantic-current-tag)))))
523 (if (not result) 526 (if (not result)
524 (error "No up reference found") 527 (error "No up reference found")
diff --git a/lisp/cedet/semantic/wisent/python.el b/lisp/cedet/semantic/wisent/python.el
index a0ea488f0fe..89c0499b7da 100644
--- a/lisp/cedet/semantic/wisent/python.el
+++ b/lisp/cedet/semantic/wisent/python.el
@@ -48,24 +48,15 @@
48 48
49(defun semantic-python-get-system-include-path () 49(defun semantic-python-get-system-include-path ()
50 "Evaluate some Python code that determines the system include path." 50 "Evaluate some Python code that determines the system include path."
51 (python-proc) 51 (delq nil
52 (if python-buffer 52 (mapcar
53 (with-current-buffer python-buffer 53 (lambda (dir)
54 (set (make-local-variable 'python-preoutput-result) nil) 54 (when (file-directory-p dir)
55 (python-send-string 55 dir))
56 "import sys; print '_emacs_out ' + '\\0'.join(sys.path)") 56 (split-string
57 (accept-process-output (python-proc) 2) 57 (python-shell-internal-send-string
58 (if python-preoutput-result 58 "import sys;print ('\\n'.join(sys.path))")
59 (split-string python-preoutput-result "[\0\n]" t) 59 "\n" t))))
60 ;; Try a second, Python3k compatible shot
61 (python-send-string
62 "import sys; print('_emacs_out ' + '\\0'.join(sys.path))")
63 (accept-process-output (python-proc) 2)
64 (if python-preoutput-result
65 (split-string python-preoutput-result "[\0\n]" t)
66 (message "Timeout while querying Python for system include path.")
67 nil)))
68 (message "Python seems to be unavailable on this system.")))
69 60
70(defcustom-mode-local-semantic-dependency-system-include-path 61(defcustom-mode-local-semantic-dependency-system-include-path
71 python-mode semantic-python-dependency-system-include-path 62 python-mode semantic-python-dependency-system-include-path