aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/cedet/semantic/grammar.el96
1 files changed, 33 insertions, 63 deletions
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index 3260ddd5166..e71832fece6 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -940,29 +940,32 @@ Lisp code."
940 (make-backup-files t) 940 (make-backup-files t)
941 (vc-make-backup-files t)) 941 (vc-make-backup-files t))
942 (kill-buffer (current-buffer))) 942 (kill-buffer (current-buffer)))
943 ;; If running interactively, eval declarations and epilogue 943
944 ;; code, then pop to the buffer visiting the generated file. 944 (let ((setupfcn (with-current-buffer semantic--grammar-input-buffer
945 (eval-region (point) (point-max)) 945 (intern (semantic-grammar-setupfunction))))
946 ;; Loop over the defvars and eval them explicitly to force 946 (mode (with-current-buffer semantic--grammar-input-buffer
947 ;; them to be evaluated and ready to use. 947 (semantic-grammar-languagemode))))
948 (goto-char (point-min)) 948 ;; If running interactively, eval declarations and epilogue
949 (while (re-search-forward "(defvar " nil t) 949 ;; code, then pop to the buffer visiting the generated file.
950 (eval-defun nil)) 950 (eval-region (point) (point-max))
951 ;; Move cursor to a logical spot in the generated code. 951 ;; Move cursor to a logical spot in the generated code.
952 (goto-char (point-min)) 952 (goto-char (point-min))
953 (pop-to-buffer (current-buffer)) 953 (pop-to-buffer (current-buffer))
954 ;; The generated code has been evaluated and updated into 954 ;; The generated code has been evaluated and updated into
955 ;; memory. Now find all buffers that match the major modes we 955 ;; memory. Now find all buffers that match the major modes we
956 ;; have created this language for, and force them to call our 956 ;; have created this language for, and force them to call our
957 ;; setup function again, refreshing all semantic data, and 957 ;; setup function again, refreshing all semantic data, and
958 ;; enabling them to work with the new code just created. 958 ;; enabling them to work with the new code just created.
959;;;; FIXME? 959
960 ;; At this point, I don't know any user's defined setup code :-( 960 ;; At this point, I don't know any user's defined setup code :-(
961 ;; At least, what I can do for now, is to run the generated 961 ;; At least, what I can do for now, is to run the generated
962 ;; parser-install function. 962 ;; parser-install function.
963 (semantic-map-mode-buffers 963 (semantic-map-mode-buffers
964 (semantic-grammar-setupfunction) 964 (lambda ()
965 (semantic-grammar-languagemode))) 965 (semantic-clear-toplevel-cache)
966 (funcall setupfcn))
967 mode)
968 ))
966 ) 969 )
967 ;; Return the name of the generated package file. 970 ;; Return the name of the generated package file.
968 output)) 971 output))
@@ -1201,7 +1204,6 @@ END is the limit of the search."
1201 (define-key km ":" 'semantic-grammar-electric-punctuation) 1204 (define-key km ":" 'semantic-grammar-electric-punctuation)
1202 1205
1203 (define-key km "\t" 'semantic-grammar-indent) 1206 (define-key km "\t" 'semantic-grammar-indent)
1204 (define-key km "\M-\t" 'semantic-grammar-complete)
1205 (define-key km "\C-c\C-c" 'semantic-grammar-create-package) 1207 (define-key km "\C-c\C-c" 'semantic-grammar-create-package)
1206 (define-key km "\C-c\C-m" 'semantic-grammar-find-macro-expander) 1208 (define-key km "\C-c\C-m" 'semantic-grammar-find-macro-expander)
1207 (define-key km "\C-c\C-k" 'semantic-grammar-insert-keyword) 1209 (define-key km "\C-c\C-k" 'semantic-grammar-insert-keyword)
@@ -1214,7 +1216,7 @@ END is the limit of the search."
1214(defvar semantic-grammar-menu 1216(defvar semantic-grammar-menu
1215 '("Grammar" 1217 '("Grammar"
1216 ["Indent Line" semantic-grammar-indent] 1218 ["Indent Line" semantic-grammar-indent]
1217 ["Complete Symbol" semantic-grammar-complete] 1219 ["Complete Symbol" completion-at-point]
1218 ["Find Macro" semantic-grammar-find-macro-expander] 1220 ["Find Macro" semantic-grammar-find-macro-expander]
1219 "--" 1221 "--"
1220 ["Insert %keyword" semantic-grammar-insert-keyword] 1222 ["Insert %keyword" semantic-grammar-insert-keyword]
@@ -1322,7 +1324,7 @@ the change bounds to encompass the whole nonterminal tag."
1322 (semantic-grammar-wy--install-parser) 1324 (semantic-grammar-wy--install-parser)
1323 (setq semantic-lex-comment-regex ";;" 1325 (setq semantic-lex-comment-regex ";;"
1324 semantic-lex-analyzer 'semantic-grammar-lexer 1326 semantic-lex-analyzer 'semantic-grammar-lexer
1325 semantic-type-relation-separator-character '(":") 1327 semantic-type-relation-separator-character '()
1326 semantic-symbol->name-assoc-list 1328 semantic-symbol->name-assoc-list
1327 '( 1329 '(
1328 (code . "Setup Code") 1330 (code . "Setup Code")
@@ -1490,39 +1492,6 @@ Use the Lisp or grammar indenter depending on point location."
1490 (save-excursion 1492 (save-excursion
1491 (semantic-grammar-indent))) 1493 (semantic-grammar-indent)))
1492 1494
1493(defun semantic-grammar-complete ()
1494 "Attempt to complete the symbol under point.
1495Completion is position sensitive. If the cursor is in a match section of
1496a rule, then nonterminals symbols are scanned. If the cursor is in a Lisp
1497expression then Lisp symbols are completed."
1498 (interactive)
1499 (if (semantic-grammar-in-lisp-p)
1500 ;; We are in lisp code. Do lisp completion.
1501 (let ((completion-at-point-functions
1502 (append '(lisp-completion-at-point)
1503 completion-at-point-functions)))
1504 (completion-at-point))
1505 ;; We are not in lisp code. Do rule completion.
1506 (let* ((nonterms (semantic-find-tags-by-class 'nonterminal (current-buffer)))
1507 (sym (car (semantic-ctxt-current-symbol)))
1508 (ans (try-completion sym nonterms)))
1509 (cond ((eq ans t)
1510 ;; All done
1511 (message "Symbols is already complete"))
1512 ((and (stringp ans) (string= ans sym))
1513 ;; Max matchable. Show completions.
1514 (with-output-to-temp-buffer "*Completions*"
1515 (display-completion-list (all-completions sym nonterms)))
1516 )
1517 ((stringp ans)
1518 ;; Expand the completions
1519 (forward-sexp -1)
1520 (delete-region (point) (progn (forward-sexp 1) (point)))
1521 (insert ans))
1522 (t (message "No Completions."))
1523 ))
1524 ))
1525
1526(defun semantic-grammar-insert-keyword (name) 1495(defun semantic-grammar-insert-keyword (name)
1527 "Insert a new %keyword declaration with NAME. 1496 "Insert a new %keyword declaration with NAME.
1528Assumes it is typed in with the correct casing." 1497Assumes it is typed in with the correct casing."
@@ -1784,7 +1753,7 @@ Only tags of type 'nonterminal will be so marked."
1784 (if (semantic-grammar-in-lisp-p) 1753 (if (semantic-grammar-in-lisp-p)
1785 (with-mode-local emacs-lisp-mode 1754 (with-mode-local emacs-lisp-mode
1786 (semantic-ctxt-current-class-list)) 1755 (semantic-ctxt-current-class-list))
1787 '(nonterminal keyword)))) 1756 '(nonterminal token keyword))))
1788 1757
1789(define-mode-local-override semantic-ctxt-current-mode 1758(define-mode-local-override semantic-ctxt-current-mode
1790 semantic-grammar-mode (&optional point) 1759 semantic-grammar-mode (&optional point)
@@ -1924,14 +1893,15 @@ Optional argument COLOR determines if color is added to the text."
1924 context-return))) 1893 context-return)))
1925 1894
1926(define-mode-local-override semantic-analyze-possible-completions 1895(define-mode-local-override semantic-analyze-possible-completions
1927 semantic-grammar-mode (context) 1896 semantic-grammar-mode (context &rest flags)
1928 "Return a list of possible completions based on CONTEXT." 1897 "Return a list of possible completions based on CONTEXT.
1898Optional FLAGS are ignored."
1929 (require 'semantic/analyze/complete) 1899 (require 'semantic/analyze/complete)
1930 (if (semantic-grammar-in-lisp-p) 1900 (if (semantic-grammar-in-lisp-p)
1931 (with-mode-local emacs-lisp-mode 1901 (with-mode-local emacs-lisp-mode
1932 (semantic-analyze-possible-completions context)) 1902 (semantic-analyze-possible-completions context))
1933 (with-current-buffer (oref context buffer) 1903 (with-current-buffer (oref context buffer)
1934 (let* ((prefix (car (oref context :prefix))) 1904 (let* ((prefix (car (reverse (oref context :prefix))))
1935 (completetext (cond ((semantic-tag-p prefix) 1905 (completetext (cond ((semantic-tag-p prefix)
1936 (semantic-tag-name prefix)) 1906 (semantic-tag-name prefix))
1937 ((stringp prefix) 1907 ((stringp prefix)