Re[3]: [cedet-semantic] Question on the se-show example
Brought to you by:
zappo
From: Eric M. L. <er...@si...> - 2003-05-23 11:32:37
|
semantic has adapted eldoc to also display C/C++ summaries. Here is an example of what you want. (defsubst senator-find-current-symbol-tag (sym) "Search for a semantic tag with name SYM. Return the tag found or nil if not found." (car (if (and (featurep 'semanticdb) semanticdb-current-database) (cdar (semanticdb-deep-find-tags-by-name sym)) (semantic-deep-find-tags-by-name sym (current-buffer))))) (defun senator-eldoc-print-current-symbol-info-default () "Return a string message describing the current context." (let (sym found) (and ;; 1- Look for a tag with current symbol name (setq sym (car (semantic-ctxt-current-symbol))) (not (setq found (senator-find-current-symbol-tag sym))) ;; 2- Look for a keyword with that name (semantic-lex-keyword-p sym) (not (setq found (semantic-lex-keyword-get sym 'summary))) ;; 3- Look for a tag with current function name (setq sym (car (semantic-ctxt-current-function))) (not (setq found (senator-find-current-symbol-tag sym))) ;; 4- Look for a keyword with that name (semantic-lex-keyword-p sym) (setq found (semantic-lex-keyword-get sym 'summary))) found)) (defun senator-eldoc-print-current-symbol-info () "Print information using `eldoc-message' while in function `eldoc-mode'. You can override the info collecting part with `eldoc-current-symbol-info'." (let* ((s (semantic-fetch-overload 'eldoc-current-symbol-info)) found) (if s (setq found (funcall s)) (setq found (senator-eldoc-print-current-symbol-info-default))) (eldoc-message (cond ((stringp found) found) ((semantic-tag-p found) (semantic-format-tag-summarize found nil senator-eldoc-use-color)) (t nil) )))) (defadvice eldoc-print-current-symbol-info (around senator activate) "Enable ELDOC in non Emacs Lisp, but semantic-enabled modes." (if (eq major-mode 'emacs-lisp-mode) ad-do-it (if (semantic-active-p) (if (eldoc-display-message-p) (senator-eldoc-print-current-symbol-info)) (eldoc-mode -1)))) Eric >>> hen...@se... seems to think that: >I tried invoking global-semantic-summary-mode. This seems to invoke eldoc as >well. I'm using C/C++, I think that eldoc only is for lisp. I didn't get much >wiser reading the doc strings in semantic-utils-modes.el. > >Could someone give some small snippet including semantic-ctxt-current-symbol. I >can't get it to work. > >/henrik > > > > > >"Eric M. Ludlam" <er...@si...> on 2003-05-22 17:05:37 > > >To: Henrik Jonsson/SE/Transport/Bombardier@Transport >cc: ced...@li... > >Security Level:? Internal > >Subject: Re[1]: [cedet-semantic] Question on the se-show example > > > >Does `global-semantic-summary-mode' do what you want? > >You may find a long list of useful minor modes in >semantic-util-modes.el > >To answer your more specific question, you can use >`semantic-ctxt-current-symbol' to get the text from the buffer which >you can then use to lookup your symbol. > >Eric > >>>> hen...@se... seems to think that: >>Hi! >> >>I'm a semantic newcomer. I would like to have a function that displays the >>arguments to the function that I am about to call in the message area. I found >>se-show in the semantic-example.el file and it almost do what I want. If I call >>it it asks for a symbol name, however the default value is already inserted, so >>I only need to press enter to see a beatifull function argument list in the >>message area. >> >>How can I avoid the question of the symbol and only let it read my newly >written >>function name? >>It sounds simple, and I have tried to do some changes without success. >> >>(defun se-show (name) >> "Show important information about some token with NAME. >>Shows how to: >> * Create a variable with `semantic-token->text-functions'. >> * Create the colorized text." >> (interactive (list (semantic-read-symbol "Symbol: "))) >> (let ((tok (semantic-find-nonterminal-by-name name (current-buffer) t)) >> parent >> msg) >> (if tok >> (save-excursion >> ;; Token text functions can take a PARENT argument. To find this >> ;; really quickly, jump to TOK, then use the overlay mechanism to >> ;; Find it. >> (goto-char (semantic-token-start tok)) >> (setq parent (semantic-current-nonterminal-parent)) >> ;; Create a message >> (setq msg (funcall se-summary-function tok parent t)) >> ;; Display it >> (message msg))))) >> >> >>Regards >> >>Henrik >> >> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: ObjectStore. >>If flattening out C++ or Java code to make your application fit in a >>relational database is painful, don't do it! Check out ObjectStore. >>Now part of Progress Software. http://www.objectstore.net/sourceforge >>_______________________________________________ >>cedet-semantic mailing list >>ced...@li... >>https://lists.sourceforge.net/lists/listinfo/cedet-semantic >> > >-- > Eric Ludlam: za...@gn..., er...@si... > Home: http://www.ludlam.net Siege: www.siege-engine.com >Emacs: http://cedet.sourceforge.net GNU: www.gnu.org > > >------------------------------------------------------- >This SF.net email is sponsored by: ObjectStore. >If flattening out C++ or Java code to make your application fit in a >relational database is painful, don't do it! Check out ObjectStore. >Now part of Progress Software. http://www.objectstore.net/sourceforge >_______________________________________________ >cedet-semantic mailing list >ced...@li... >https://lists.sourceforge.net/lists/listinfo/cedet-semantic > > > > > > > >------------------------------------------------------- >This SF.net email is sponsored by: ObjectStore. >If flattening out C++ or Java code to make your application fit in a >relational database is painful, don't do it! Check out ObjectStore. >Now part of Progress Software. http://www.objectstore.net/sourceforge >_______________________________________________ >cedet-semantic mailing list >ced...@li... >https://lists.sourceforge.net/lists/listinfo/cedet-semantic > |