diff options
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/cedet/semantic/idle.el | 68 |
2 files changed, 71 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 94f0f388743..6b2b34df0fc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2009-11-15 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * cedet/semantic/idle.el (semantic-idle-summary-mode) | ||
| 4 | (semantic-idle-summary-mode): Define using define-minor-mode | ||
| 5 | instead of define-semantic-idle-service. | ||
| 6 | (semantic-idle-summary-mode): New function. | ||
| 7 | (semantic-idle-summary-mode-setup): Use pre-command-hook to ensure | ||
| 8 | that mouse motion does not reset the echo area. | ||
| 9 | |||
| 1 | 2009-11-15 Juri Linkov <juri@jurta.org> | 10 | 2009-11-15 Juri Linkov <juri@jurta.org> |
| 2 | 11 | ||
| 3 | * simple.el (set-mark-default-inactive): Add :type, :group | 12 | * simple.el (set-mark-default-inactive): Add :type, :group |
diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el index 0c152219a9a..e8be0bb97eb 100644 --- a/lisp/cedet/semantic/idle.el +++ b/lisp/cedet/semantic/idle.el | |||
| @@ -46,6 +46,7 @@ | |||
| 46 | ;; For the semantic-find-tags-by-name macro. | 46 | ;; For the semantic-find-tags-by-name macro. |
| 47 | (eval-when-compile (require 'semantic/find)) | 47 | (eval-when-compile (require 'semantic/find)) |
| 48 | 48 | ||
| 49 | (defvar eldoc-last-message) | ||
| 49 | (declare-function eldoc-message "eldoc") | 50 | (declare-function eldoc-message "eldoc") |
| 50 | (declare-function semantic-analyze-interesting-tag "semantic/analyze") | 51 | (declare-function semantic-analyze-interesting-tag "semantic/analyze") |
| 51 | (declare-function semantic-complete-analyze-inline-idle "semantic/complete") | 52 | (declare-function semantic-complete-analyze-inline-idle "semantic/complete") |
| @@ -151,7 +152,7 @@ If ARG is nil, then toggle." | |||
| 151 | 'semantic-idle-scheduler-mode arg))) | 152 | 'semantic-idle-scheduler-mode arg))) |
| 152 | 153 | ||
| 153 | (defcustom semantic-idle-scheduler-mode-hook nil | 154 | (defcustom semantic-idle-scheduler-mode-hook nil |
| 154 | "*Hook run at the end of function `semantic-idle-scheduler-mode'." | 155 | "Hook run at the end of function `semantic-idle-scheduler-mode'." |
| 155 | :group 'semantic | 156 | :group 'semantic |
| 156 | :type 'hook) | 157 | :type 'hook) |
| 157 | 158 | ||
| @@ -695,7 +696,9 @@ minor mode is enabled.") | |||
| 695 | 696 | ||
| 696 | (defcustom semantic-idle-summary-function | 697 | (defcustom semantic-idle-summary-function |
| 697 | 'semantic-format-tag-summarize-with-file | 698 | 'semantic-format-tag-summarize-with-file |
| 698 | "*Function to use when displaying tag information during idle time. | 699 | "Function to call when displaying tag information during idle time. |
| 700 | This function should take a single argument, a Semantic tag, and | ||
| 701 | return a string to display. | ||
| 699 | Some useful functions are found in `semantic-format-tag-functions'." | 702 | Some useful functions are found in `semantic-format-tag-functions'." |
| 700 | :group 'semantic | 703 | :group 'semantic |
| 701 | :type semantic-format-tag-custom-list) | 704 | :type semantic-format-tag-custom-list) |
| @@ -797,7 +800,12 @@ specific to a major mode. For example, in jde mode: | |||
| 797 | 'semantic-idle-summary-current-symbol-info | 800 | 'semantic-idle-summary-current-symbol-info |
| 798 | "23.2") | 801 | "23.2") |
| 799 | 802 | ||
| 800 | (define-semantic-idle-service semantic-idle-summary | 803 | (defcustom semantic-idle-summary-mode-hook nil |
| 804 | "Hook run at the end of `semantic-idle-summary'." | ||
| 805 | :group 'semantic | ||
| 806 | :type 'hook) | ||
| 807 | |||
| 808 | (defun semantic-idle-summary-idle-function () | ||
| 801 | "Display a tag summary of the lexical token under the cursor. | 809 | "Display a tag summary of the lexical token under the cursor. |
| 802 | Call `semantic-idle-summary-current-symbol-info' for getting the | 810 | Call `semantic-idle-summary-current-symbol-info' for getting the |
| 803 | current tag to display information." | 811 | current tag to display information." |
| @@ -807,16 +815,64 @@ current tag to display information." | |||
| 807 | (str (cond ((stringp found) found) | 815 | (str (cond ((stringp found) found) |
| 808 | ((semantic-tag-p found) | 816 | ((semantic-tag-p found) |
| 809 | (funcall semantic-idle-summary-function | 817 | (funcall semantic-idle-summary-function |
| 810 | found nil t)))) | 818 | found nil t))))) |
| 811 | ) | ||
| 812 | ;; Show the message with eldoc functions | 819 | ;; Show the message with eldoc functions |
| 813 | (require 'eldoc) | ||
| 814 | (unless (and str (boundp 'eldoc-echo-area-use-multiline-p) | 820 | (unless (and str (boundp 'eldoc-echo-area-use-multiline-p) |
| 815 | eldoc-echo-area-use-multiline-p) | 821 | eldoc-echo-area-use-multiline-p) |
| 816 | (let ((w (1- (window-width (minibuffer-window))))) | 822 | (let ((w (1- (window-width (minibuffer-window))))) |
| 817 | (if (> (length str) w) | 823 | (if (> (length str) w) |
| 818 | (setq str (substring str 0 w))))) | 824 | (setq str (substring str 0 w))))) |
| 819 | (eldoc-message str)))) | 825 | (eldoc-message str)))) |
| 826 | |||
| 827 | (define-minor-mode semantic-idle-summary-mode | ||
| 828 | "Toggle Semantic Idle Summary mode. | ||
| 829 | When Semantic Idle Summary mode is enabled, the echo area | ||
| 830 | displays a summary of the lexical token under the cursor whenever | ||
| 831 | Emacs is idle." | ||
| 832 | :group 'semantic | ||
| 833 | :group 'semantic-modes | ||
| 834 | (semantic-idle-summary-mode-setup) | ||
| 835 | (semantic-mode-line-update)) | ||
| 836 | |||
| 837 | (defun semantic-idle-summary-refresh-echo-area () | ||
| 838 | (and semantic-idle-summary-mode | ||
| 839 | eldoc-last-message | ||
| 840 | (if (and (not executing-kbd-macro) | ||
| 841 | (not (and (boundp 'edebug-active) edebug-active)) | ||
| 842 | (not cursor-in-echo-area) | ||
| 843 | (not (eq (selected-window) (minibuffer-window)))) | ||
| 844 | (eldoc-message eldoc-last-message) | ||
| 845 | (setq eldoc-last-message nil)))) | ||
| 846 | |||
| 847 | (defun semantic-idle-summary-mode-setup () | ||
| 848 | "Set up `semantic-idle-summary-mode'." | ||
| 849 | (if semantic-idle-summary-mode | ||
| 850 | ;; Enable the mode | ||
| 851 | (progn | ||
| 852 | (unless (and (featurep 'semantic) (semantic-active-p)) | ||
| 853 | ;; Disable minor mode if semantic stuff not available | ||
| 854 | (setq semantic-idle-summary-mode nil) | ||
| 855 | (error "Buffer %s was not set up for parsing" | ||
| 856 | (buffer-name))) | ||
| 857 | (require 'eldoc) | ||
| 858 | (semantic-idle-scheduler-add 'semantic-idle-summary-idle-function) | ||
| 859 | (add-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)) | ||
| 860 | ;; Disable the mode | ||
| 861 | (semantic-idle-scheduler-remove 'semantic-idle-summary-idle-function) | ||
| 862 | (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t)) | ||
| 863 | semantic-idle-summary-mode) | ||
| 864 | |||
| 865 | (semantic-add-minor-mode 'semantic-idle-summary-mode "") | ||
| 866 | |||
| 867 | (define-minor-mode global-semantic-idle-summary-mode | ||
| 868 | "Toggle global use of `semantic-idle-summary-mode'." | ||
| 869 | :global t | ||
| 870 | :group 'semantic | ||
| 871 | :group 'semantic-modes | ||
| 872 | (semantic-toggle-minor-mode-globally | ||
| 873 | 'semantic-idle-summary-mode | ||
| 874 | (if global-semantic-idle-summary-mode 1 -1))) | ||
| 875 | |||
| 820 | 876 | ||
| 821 | ;;; Current symbol highlight | 877 | ;;; Current symbol highlight |
| 822 | ;; | 878 | ;; |