annotate lisp/cedet/semantic/idle.el @ 110523:a5ad4f188e19

Synch Semantic to CEDET 1.0. Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog. * semantic.el (semantic-version): Update to 2.0. (semantic-mode-map): Add "," and "m" bindings. (navigate-menu): Update. * semantic/symref.el (semantic-symref-calculate-rootdir): New function. (semantic-symref-detect-symref-tool): Use it. * semantic/symref/grep.el (semantic-symref-grep-shell): New var. (semantic-symref-perform-search): Use it. Calculate root dir with semantic-symref-calculate-rootdir. (semantic-symref-derive-find-filepatterns): Improve error message. * semantic/symref/list.el (semantic-symref-results-mode-map): New bindings. (semantic-symref-auto-expand-results): New option. (semantic-symref-results-dump): Obey auto-expand. (semantic-symref-list-expand-all, semantic-symref-regexp) (semantic-symref-list-contract-all) (semantic-symref-list-map-open-hits) (semantic-symref-list-update-open-hits) (semantic-symref-list-create-macro-on-open-hit) (semantic-symref-list-call-macro-on-open-hits): New functions. (semantic-symref-list-menu-entries) (semantic-symref-list-menu): New vars. (semantic-symref-list-map-open-hits): Move cursor to beginning of match before calling the mapped function. * semantic/doc.el (semantic-documentation-comment-preceeding-tag): Do nothing if the mode doesn't provide comment-start-skip. * semantic/scope.el (semantic-analyze-scope-nested-tags-default): Strip duplicates. (semantic-analyze-scoped-inherited-tag-map): Take the tag we are looking for as part of the scoped tags list. * semantic/html.el (semantic-default-html-setup): Add senator-step-at-tag-classes. * semantic/decorate/include.el (semantic-decoration-on-unknown-includes): Change light bgcolor. (semantic-decoration-on-includes-highlight-default): Check that the include tag has a postion. * semantic/complete.el (semantic-collector-local-members): (semantic-complete-read-tag-local-members) (semantic-complete-jump-local-members): New class and functions. (semantic-complete-self-insert): Save excursion before completing. * semantic/analyze/complete.el (semantic-analyze-possible-completions-default): If no completions are found, return the raw by-name-only completion list. Add FLAGS arguments. Add support for 'no-tc (type constraint) and 'no-unique, or no stripping duplicates. (semantic-analyze-possible-completions-default): Add FLAGS arg. * semantic/util-modes.el (semantic-stickyfunc-show-only-functions-p): New option. (semantic-stickyfunc-fetch-stickyline): Don't show stickytext for the very first line in a buffer. * semantic/util.el (semantic-hack-search) (semantic-recursive-find-nonterminal-by-name) (semantic-current-tag-interactive): Deleted. (semantic-describe-buffer): Fix expand-nonterminal. Add lex-syntax-mods, type relation separator char, and command separation char. (semantic-sanity-check): Only message if called interactively. * semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the :filename property and the tag position. * semantic/lex-spp.el (semantic-lex-spp-lex-text-string): Add recursion limit. * semantic/imenu.el (semantic-imenu-bucketize-type-members): Make this buffer local, not the obsoleted variable. * semantic/idle.el: Add breadcrumbs support. (semantic-idle-summary-current-symbol-info-default) (semantic-idle-tag-highlight) (semantic-idle-completion-list-default): Use semanticdb-without-unloaded-file-searches for speed, and to conform to the controls that specify if the idle timer is supposed to be parsing unparsed includes. (semantic-idle-symbol-highlight-face) (semantic-idle-symbol-maybe-highlight): Rename from *-summary-*. Callers changed. (semantic-idle-work-parse-neighboring-files-flag): Default to nil. (semantic-idle-work-update-headers-flag): New var. (semantic-idle-work-for-one-buffer): Use it. (semantic-idle-local-symbol-highlight): Rename from semantic-idle-tag-highlight. (semantic-idle-truncate-long-summaries): New option. * semantic/ia.el (semantic-ia-cache) (semantic-ia-get-completions): Deleted. Callers changed. (semantic-ia-show-variants): New command. (semantic-ia-show-doc): If doc is empty, don't make a temp buffer. (semantic-ia-show-summary): If there isn't anything to show, say so. * semantic/grammar.el (semantic-grammar-create-package): Save the buffer even in batch mode. * semantic/fw.el (semanticdb-without-unloaded-file-searches): New macro. * semantic/dep.el (semantic-dependency-find-file-on-path): Fix case dereferencing ede-object when it is a list. * semantic/db-typecache.el (semanticdb-expand-nested-tag) (semanticdb-typecache-faux-namespace): New functions. (semanticdb-typecache-file-tags) (semanticdb-typecache-merge-streams): Use them. (semanticdb-typecache-file-tags): When deriving tags from a file, give the mode a chance to monkey with the tag copy. (semanticdb-typecache-find-default): Wrap find in save-excursion. (semanticdb-typecache-find-by-name-helper): Merge found names down. * semantic/db-global.el (semanticdb-enable-gnu-global-in-buffer): Don't show messages if GNU Global is not available and we don't want to throw an error. * semantic/db-find.el (semanticdb-find-result-nth-in-buffer): When trying to normalize the tag to a buffer, don't error if set-buffer method doesn't exist. * semantic/db-file.el (semanticdb-save-db): Simplify msg. * semantic/db.el (semanticdb-refresh-table): If forcing a refresh on a file not in a buffer, use semantic-find-file-noselect and delete the buffer after use. (semanticdb-current-database-list): When calculating root via hooks, force it through true-filename and skip the list of possible roots. * semantic/ctxt.el (semantic-ctxt-imported-packages): New. * semantic/analyze/debug.el (semantic-analyzer-debug-insert-tag): Reset standard output to current buffer. (semantic-analyzer-debug-global-symbol) (semantic-analyzer-debug-missing-innertype): Change "prefix" to "symbol" in messages. * semantic/analyze/refs.el: (semantic-analyze-refs-impl) (semantic-analyze-refs-proto): When calculating value, make sure the found tag is 'similar' to the originating tag. (semantic--analyze-refs-find-tags-with-parent): Attempt to identify matches via imported symbols of parents. (semantic--analyze-refs-full-lookup-with-parents): Do a deep search during the brute search. * semantic/analyze.el (semantic-analyze-find-tag-sequence-default): Be robust to calculated scopes being nil. * semantic/bovine/c.el (semantic-c-describe-environment): Add project macro symbol array. (semantic-c-parse-lexical-token): Add recursion limit. (semantic-ctxt-imported-packages, semanticdb-expand-nested-tag): New overrides. (semantic-expand-c-tag-namelist): Split a full type from a typedef out to its own tag. (semantic-expand-c-tag-namelist): Do not split out a typedef'd inline type if it is an anonymous type. (semantic-c-reconstitute-token): Use the optional initializers as a clue that some function is probably a constructor. When defining the type of these constructors, split the parent name, and use only the class part, if applicable. * semantic/bovine/c-by.el: * semantic/wisent/python-wy.el: Regenerate.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 18 Sep 2010 22:49:54 -0400
parents 181539c8b6a4
children b799d38f522a 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; idle.el --- Schedule parsing tasks in idle time
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106211
diff changeset
3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
4 ;; Free Software Foundation, Inc.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Keywords: syntax
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; (at your option) any later version.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Originally, `semantic-auto-parse-mode' handled refreshing the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; tags in a buffer in idle time. Other activities can be scheduled
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; in idle time, all of which require up-to-date tag tables.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; Having a specialized idle time scheduler that first refreshes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; the tags buffer, and then enables other idle time tasks reduces
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; the amount of work needed. Any specialized idle tasks need not
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; ask for a fresh tags list.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; NOTE ON SEMANTIC_ANALYZE
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; Some of the idle modes use the semantic analyzer. The analyzer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;; automatically caches the created context, so it is shared amongst
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;; all idle modes that will need it.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
40 (require 'semantic)
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
41 (require 'semantic/ctxt)
104447
273e528a9f9b * emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
42 (require 'semantic/format)
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
43 (require 'semantic/tag)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (require 'timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
46 ;; For the semantic-find-tags-by-name macro.
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
47 (eval-when-compile (require 'semantic/find))
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
48
106029
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
49 (defvar eldoc-last-message)
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
50 (declare-function eldoc-message "eldoc")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
51 (declare-function semantic-analyze-interesting-tag "semantic/analyze")
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
52 (declare-function semantic-analyze-unsplit-name "semantic/analyze/fcn")
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
53 (declare-function semantic-complete-analyze-inline-idle "semantic/complete")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
54 (declare-function semanticdb-deep-find-tags-by-name "semantic/db-find")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
55 (declare-function semanticdb-save-all-db-idle "semantic/db")
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
56 (declare-function semanticdb-typecache-refresh-for-buffer "semantic/db-typecache")
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
57 (declare-function semantic-decorate-flush-pending-decorations
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
58 "semantic/decorate/mode")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
59 (declare-function pulse-momentary-highlight-region "pulse")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
60 (declare-function pulse-momentary-highlight-overlay "pulse")
104454
e4842bf0f303 lisp/cedet/semantic/symref/filter.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
61 (declare-function semantic-symref-hits-in-region "semantic/symref/filter")
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
62
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;;; Code:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;;; TIMER RELATED FUNCTIONS
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 (defvar semantic-idle-scheduler-timer nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 "Timer used to schedule tasks in idle time.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 (defvar semantic-idle-scheduler-work-timer nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 "Timer used to schedule tasks in idle time that may take a while.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (defcustom semantic-idle-scheduler-verbose-flag nil
104519
934691bc93ed * cedet/semantic/idle.el (semantic-idle-scheduler-work-timer):
Chong Yidong <cyd@stupidchicken.com>
parents: 104514
diff changeset
74 "Non-nil means that the idle scheduler should provide debug messages.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 Use this setting to debug idle activities."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 :type 'boolean)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78
104519
934691bc93ed * cedet/semantic/idle.el (semantic-idle-scheduler-work-timer):
Chong Yidong <cyd@stupidchicken.com>
parents: 104514
diff changeset
79 (defcustom semantic-idle-scheduler-idle-time 1
934691bc93ed * cedet/semantic/idle.el (semantic-idle-scheduler-work-timer):
Chong Yidong <cyd@stupidchicken.com>
parents: 104514
diff changeset
80 "Time in seconds of idle before scheduling events.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 This time should be short enough to ensure that idle-scheduler will be
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 run as soon as Emacs is idle."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 :type 'number
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 :set (lambda (sym val)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 (set-default sym val)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (when (timerp semantic-idle-scheduler-timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 (cancel-timer semantic-idle-scheduler-timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (setq semantic-idle-scheduler-timer nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (semantic-idle-scheduler-setup-timers))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (defcustom semantic-idle-scheduler-work-idle-time 60
104519
934691bc93ed * cedet/semantic/idle.el (semantic-idle-scheduler-work-timer):
Chong Yidong <cyd@stupidchicken.com>
parents: 104514
diff changeset
93 "Time in seconds of idle before scheduling big work.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 This time should be long enough that once any big work is started, it is
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 unlikely the user would be ready to type again right away."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 :type 'number
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 :set (lambda (sym val)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (set-default sym val)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (when (timerp semantic-idle-scheduler-timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (cancel-timer semantic-idle-scheduler-timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (setq semantic-idle-scheduler-timer nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (semantic-idle-scheduler-setup-timers))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (defun semantic-idle-scheduler-setup-timers ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 "Lazy initialization of the auto parse idle timer."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 ;; REFRESH THIS FUNCTION for XEMACS FOIBLES
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (or (timerp semantic-idle-scheduler-timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (setq semantic-idle-scheduler-timer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (run-with-idle-timer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 semantic-idle-scheduler-idle-time t
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 #'semantic-idle-scheduler-function)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 (or (timerp semantic-idle-scheduler-work-timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (setq semantic-idle-scheduler-work-timer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (run-with-idle-timer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 semantic-idle-scheduler-work-idle-time t
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 #'semantic-idle-scheduler-work-function)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (defun semantic-idle-scheduler-kill-timer ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 "Kill the auto parse idle timer."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (if (timerp semantic-idle-scheduler-timer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 (cancel-timer semantic-idle-scheduler-timer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (setq semantic-idle-scheduler-timer nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 ;;; MINOR MODE
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ;; The minor mode portion of this code just sets up the minor mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 ;; which does the initial scheduling of the idle timers.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 ;;
104463
e4788b39543d lisp/cedet/semantic/idle.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104454
diff changeset
132 ;;;###autoload
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 (defcustom global-semantic-idle-scheduler-mode nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 "*If non-nil, enable global use of idle-scheduler mode."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 :group 'semantic-modes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 :type 'boolean
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 :require 'semantic/idle
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 :initialize 'custom-initialize-default
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 :set (lambda (sym val)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (global-semantic-idle-scheduler-mode (if val 1 -1))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (defcustom semantic-idle-scheduler-mode-hook nil
106150
269b53d49dd9 * cedet/cedet.el (cedet-menu-map): Re-order menu items.
Chong Yidong <cyd@stupidchicken.com>
parents: 106029
diff changeset
144 "Hook run at the end of the function `semantic-idle-scheduler-mode'."
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 :type 'hook)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (defvar semantic-idle-scheduler-mode nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 "Non-nil if idle-scheduler minor mode is enabled.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 Use the command `semantic-idle-scheduler-mode' to change this variable.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 (make-variable-buffer-local 'semantic-idle-scheduler-mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (defcustom semantic-idle-scheduler-max-buffer-size 0
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 "*Maximum size in bytes of buffers where idle-scheduler is enabled.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 If this value is less than or equal to 0, idle-scheduler is enabled in
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 all buffers regardless of their size."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 :type 'number)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (defsubst semantic-idle-scheduler-enabled-p ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 "Return non-nil if idle-scheduler is enabled for this buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 idle-scheduler is disabled when debugging or if the buffer size
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 exceeds the `semantic-idle-scheduler-max-buffer-size' threshold."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (and semantic-idle-scheduler-mode
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
165 (not (and (boundp 'semantic-debug-enabled)
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104429
diff changeset
166 semantic-debug-enabled))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (not semantic-lex-debug)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (or (<= semantic-idle-scheduler-max-buffer-size 0)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (< (buffer-size) semantic-idle-scheduler-max-buffer-size))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (defun semantic-idle-scheduler-mode-setup ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 "Setup option `semantic-idle-scheduler-mode'.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 The minor mode can be turned on only if semantic feature is available
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 and the current buffer was set up for parsing. When minor mode is
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 enabled parse the current buffer if needed. Return non-nil if the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 minor mode is enabled."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (if semantic-idle-scheduler-mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (if (not (and (featurep 'semantic) (semantic-active-p)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (progn
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 ;; Disable minor mode if semantic stuff not available
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (setq semantic-idle-scheduler-mode nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (error "Buffer %s was not set up idle time scheduling"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (buffer-name)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (semantic-idle-scheduler-setup-timers)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 semantic-idle-scheduler-mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186
104463
e4788b39543d lisp/cedet/semantic/idle.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104454
diff changeset
187 ;;;###autoload
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (defun semantic-idle-scheduler-mode (&optional arg)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 "Minor mode to auto parse buffer following a change.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 When this mode is off, a buffer is only rescanned for tokens when
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 some command requests the list of available tokens. When idle-scheduler
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 is enabled, Emacs periodically checks to see if the buffer is out of
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 date, and reparses while the user is idle (not typing.)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 With prefix argument ARG, turn on if positive, otherwise off. The
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 minor mode can be turned on only if semantic feature is available and
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 the current buffer was set up for parsing. Return non-nil if the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 minor mode is enabled."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (interactive
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (list (or current-prefix-arg
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (if semantic-idle-scheduler-mode 0 1))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (setq semantic-idle-scheduler-mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (if arg
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (>
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (prefix-numeric-value arg)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 0)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (not semantic-idle-scheduler-mode)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 (semantic-idle-scheduler-mode-setup)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (run-hooks 'semantic-idle-scheduler-mode-hook)
106197
019d906c8f48 * cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents: 106165
diff changeset
210 (if (called-interactively-p 'interactive)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 (message "idle-scheduler minor mode %sabled"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (if semantic-idle-scheduler-mode "en" "dis")))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (semantic-mode-line-update)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 semantic-idle-scheduler-mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (semantic-add-minor-mode 'semantic-idle-scheduler-mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 "ARP"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 ;;; SERVICES services
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 ;; These are services for managing idle services.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (defvar semantic-idle-scheduler-queue nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 "List of functions to execute during idle time.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 These functions will be called in the current buffer after that
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 buffer has had its tags made up to date. These functions
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 will not be called if there are errors parsing the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 current buffer.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (defun semantic-idle-scheduler-add (function)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 "Schedule FUNCTION to occur during idle time."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (add-to-list 'semantic-idle-scheduler-queue function))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (defun semantic-idle-scheduler-remove (function)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 "Unschedule FUNCTION to occur during idle time."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 (setq semantic-idle-scheduler-queue
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 (delete function semantic-idle-scheduler-queue)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 ;;; IDLE Function
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (defun semantic-idle-core-handler ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 "Core idle function that handles reparsing.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 And also manages services that depend on tag values."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (message "IDLE: Core handler..."))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (semantic-exit-on-input 'idle-timer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (let* ((inhibit-quit nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (buffers (delq (current-buffer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 (delq nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (mapcar #'(lambda (b)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (and (buffer-file-name b)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 b))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (buffer-list)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 safe ;; This safe is not used, but could be.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 others
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (when (semantic-idle-scheduler-enabled-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 ;; First, reparse the current buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (setq mode major-mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 safe (semantic-safe "Idle Parse Error: %S"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 ;(error "Goofy error 1")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (semantic-idle-scheduler-refresh-tags)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 ;; Now loop over other buffers with same major mode, trying to
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 ;; update them as well. Stop on keypress.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (dolist (b buffers)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (semantic-throw-on-input 'parsing-mode-buffers)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (with-current-buffer b
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (if (eq major-mode mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (and (semantic-idle-scheduler-enabled-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (semantic-safe "Idle Parse Error: %S"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 ;(error "Goofy error")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 (semantic-idle-scheduler-refresh-tags)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (push (current-buffer) others))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (setq buffers others))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 ;; If re-parse of current buffer completed, evaluate all other
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 ;; services. Stop on keypress.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 ;; NOTE ON COMMENTED SAFE HERE
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 ;; We used to not execute the services if the buffer wsa
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 ;; unparseable. We now assume that they are lexically
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 ;; safe to do, because we have marked the buffer unparseable
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 ;; if there was a problem.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 ;;(when safe
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (dolist (service semantic-idle-scheduler-queue)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (semantic-throw-on-input 'idle-queue)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (message "IDLE: execture service %s..." service))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (semantic-safe (format "Idle Service Error %s: %%S" service)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (funcall service))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (message "IDLE: execture service %s...done" service))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 )))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ;;)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 ;; Finally loop over remaining buffers, trying to update them as
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 ;; well. Stop on keypress.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (dolist (b buffers)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 (semantic-throw-on-input 'parsing-other-buffers)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (with-current-buffer b
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (and (semantic-idle-scheduler-enabled-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (semantic-idle-scheduler-refresh-tags)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (message "IDLE: Core handler...done")))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (defun semantic-debug-idle-function ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 "Run the Semantic idle function with debugging turned on."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (interactive)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (let ((debug-on-error t))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (semantic-idle-core-handler)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (defun semantic-idle-scheduler-function ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 "Function run when after `semantic-idle-scheduler-idle-time'.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 This function will reparse the current buffer, and if successful,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 call additional functions registered with the timer calls."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (when (zerop (recursion-depth))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (let ((debug-on-error nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (save-match-data (semantic-idle-core-handler))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 )))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 ;;; WORK FUNCTION
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 ;; Unlike the shorter timer, the WORK timer will kick of tasks that
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 ;; may take a long time to complete.
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
332 (defcustom semantic-idle-work-parse-neighboring-files-flag nil
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 "*Non-nil means to parse files in the same dir as the current buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 Disable to prevent lots of excessive parsing in idle time."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 :type 'boolean)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
338 (defcustom semantic-idle-work-update-headers-flag nil
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
339 "*Non-nil means to parse through header files in idle time.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
340 Disable to prevent idle time parsing of many files. If completion
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
341 is called that work will be done then instead."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
342 :group 'semantic
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
343 :type 'boolean)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (defun semantic-idle-work-for-one-buffer (buffer)
106860
4cf58c2379f4 Mario Lang <mlang@delysid.org>: Remove some duplicated words.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
346 "Do long-processing work for BUFFER.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 Uses `semantic-safe' and returns the output.
106878
ba25499d625a (semantic-idle-work-for-one-buffer): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106860
diff changeset
348 Returns t if all processing succeeded."
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105789
diff changeset
349 (with-current-buffer buffer
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (not (and
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 ;; Just in case
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (semantic-safe "Idle Work Parse Error: %S"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (semantic-idle-scheduler-refresh-tags)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 t)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
356 ;; Option to disable this work.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
357 semantic-idle-work-update-headers-flag
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
358
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 ;; Force all our include files to get read in so we
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 ;; are ready to provide good smart completion and idle
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 ;; summary information
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (semantic-safe "Idle Work Including Error: %S"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 ;; Get the include related path.
104447
273e528a9f9b * emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
364 (when (and (featurep 'semantic/db) (semanticdb-minor-mode-p))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (require 'semantic/db-find)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (semanticdb-find-translate-path buffer nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 t)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 ;; Pre-build the typecaches as needed.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 (semantic-safe "Idle Work Typecaching Error: %S"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (when (featurep 'semantic/db-typecache)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (semanticdb-typecache-refresh-for-buffer buffer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 t)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 (defun semantic-idle-work-core-handler ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 "Core handler for idle work processing of long running tasks.
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106878
diff changeset
380 Visits Semantic controlled buffers, and makes sure all needed
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 include files have been parsed, and that the typecache is up to date.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 Uses `semantic-idle-work-for-on-buffer' to do the work."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (let ((errbuf nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (interrupted
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (semantic-exit-on-input 'idle-work-timer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (let* ((inhibit-quit nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (cb (current-buffer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (buffers (delq (current-buffer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (delq nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (mapcar #'(lambda (b)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (and (buffer-file-name b)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 b))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (buffer-list)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 safe errbuf)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 ;; First, handle long tasks in the current buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (when (semantic-idle-scheduler-enabled-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (setq safe (semantic-idle-work-for-one-buffer (current-buffer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 )))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (when (not safe) (push (current-buffer) errbuf))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 ;; Now loop over other buffers with same major mode, trying to
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 ;; update them as well. Stop on keypress.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (dolist (b buffers)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (semantic-throw-on-input 'parsing-mode-buffers)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (with-current-buffer b
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (when (semantic-idle-scheduler-enabled-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (and (semantic-idle-scheduler-enabled-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (unless (semantic-idle-work-for-one-buffer (current-buffer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 (push (current-buffer) errbuf)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413
104447
273e528a9f9b * emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
414 (when (and (featurep 'semantic/db) (semanticdb-minor-mode-p))
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
415 ;; Save everything.
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
416 (semanticdb-save-all-db-idle)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
418 ;; Parse up files near our active buffer
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
419 (when semantic-idle-work-parse-neighboring-files-flag
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
420 (semantic-safe "Idle Work Parse Neighboring Files: %S"
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (set-buffer cb)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (semantic-idle-scheduler-work-parse-neighboring-files))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 t)
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
424
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
425 ;; Save everything... again
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
426 (semanticdb-save-all-db-idle)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 ;; Done w/ processing
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 nil))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 ;; Done
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (if interrupted
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 "Interrupted"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (cond ((not errbuf)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 "done")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 ((not (cdr errbuf))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 (format "done with 1 error in %s" (car errbuf)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (t
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 (format "done with errors in %d buffers."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 (length errbuf)))))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (defun semantic-debug-idle-work-function ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 "Run the Semantic idle work function with debugging turned on."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (interactive)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (let ((debug-on-error t))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (semantic-idle-work-core-handler)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (defun semantic-idle-scheduler-work-function ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 "Function run when after `semantic-idle-scheduler-work-idle-time'.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 This routine handles difficult tasks that require a lot of parsing, such as
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 parsing all the header files used by our active sources, or building up complex
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 datasets."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (message "Long Work Idle Timer..."))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (let ((exit-type (save-match-data
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (semantic-idle-work-core-handler))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (message "Long Work Idle Timer...%s" exit-type)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 (defun semantic-idle-scheduler-work-parse-neighboring-files ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 "Parse all the files in similar directories to buffers being edited."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 ;; Lets check to see if EDE matters.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 (let ((ede-auto-add-method 'never))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 (dolist (a auto-mode-alist)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 (when (eq (cdr a) major-mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (dolist (file (directory-files default-directory t (car a) t))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (semantic-throw-on-input 'parsing-mode-buffers)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (semanticdb-file-table-object file)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 ))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 ;;; REPARSING
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 ;; Reparsing is installed as semantic idle service.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 ;; This part ALWAYS happens, and other services occur
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 ;; afterwards.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
483 (defvar semantic-before-idle-scheduler-reparse-hook nil
104514
c65d65798b34 Fix last change to use semantic-varalias-obsolete.
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
484 "Hook run before option `semantic-idle-scheduler' begins parsing.
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
485 If any hook function throws an error, this variable is reset to nil.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 This hook is not protected from lexical errors.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
488 (defvar semantic-after-idle-scheduler-reparse-hook nil
104514
c65d65798b34 Fix last change to use semantic-varalias-obsolete.
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
489 "Hook run after option `semantic-idle-scheduler' has parsed.
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
490 If any hook function throws an error, this variable is reset to nil.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 This hook is not protected from lexical errors.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492
104514
c65d65798b34 Fix last change to use semantic-varalias-obsolete.
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
493 (semantic-varalias-obsolete 'semantic-before-idle-scheduler-reparse-hooks
105760
d0906291f75b * cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
494 'semantic-before-idle-scheduler-reparse-hook "23.2")
104514
c65d65798b34 Fix last change to use semantic-varalias-obsolete.
Chong Yidong <cyd@stupidchicken.com>
parents: 104513
diff changeset
495 (semantic-varalias-obsolete 'semantic-after-idle-scheduler-reparse-hooks
105760
d0906291f75b * cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105652
diff changeset
496 'semantic-after-idle-scheduler-reparse-hook "23.2")
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
497
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 (defun semantic-idle-scheduler-refresh-tags ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 "Refreshes the current buffer's tags.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 This is called by `semantic-idle-scheduler-function' to update the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 tags in the current buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 Return non-nil if the refresh was successful.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 Return nil if there is some sort of syntax error preventing a full
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 reparse.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 Does nothing if the current buffer doesn't need reparsing."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (prog1
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 ;; These checks actually occur in `semantic-fetch-tags', but if we
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 ;; do them here, then all the bovination hooks are not run, and
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 ;; we save lots of time.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 (cond
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 ;; If the buffer was previously marked unparseable,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 ;; then don't waste our time.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 ((semantic-parse-tree-unparseable-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 ;; The parse tree is already ok.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 ((semantic-parse-tree-up-to-date-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 t)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 (t
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 ;; If the buffer might need a reparse and it is safe to do so,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 ;; give it a try.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 (let* (;(semantic-working-type nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 (inhibit-quit nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 ;; (working-use-echo-area-p
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 ;; (not semantic-idle-scheduler-working-in-modeline-flag))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 ;; (working-status-dynamic-type
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 ;; (if semantic-idle-scheduler-no-working-message
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 ;; nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 ;; working-status-dynamic-type))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 ;; (working-status-percentage-type
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 ;; (if semantic-idle-scheduler-no-working-message
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 ;; nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 ;; working-status-percentage-type))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 (lexically-safe t)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 ;; Let people hook into this, but don't let them hose
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 ;; us over!
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 (condition-case nil
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
541 (run-hooks 'semantic-before-idle-scheduler-reparse-hook)
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
542 (error (setq semantic-before-idle-scheduler-reparse-hook nil)))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 (unwind-protect
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 ;; Perform the parsing.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 (progn
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 (message "IDLE: reparse %s..." (buffer-name)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 (when (semantic-lex-catch-errors idle-scheduler
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 (save-excursion (semantic-fetch-tags))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 ;; If we are here, it is because the lexical step failed,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 ;; proably due to unterminated lists or something like that.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 ;; We do nothing, and just wait for the next idle timer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 ;; to go off. In the meantime, remember this, and make sure
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 ;; no other idle services can get executed.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 (setq lexically-safe nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 (when semantic-idle-scheduler-verbose-flag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 (message "IDLE: reparse %s...done" (buffer-name))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561 ;; Let people hook into this, but don't let them hose
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 ;; us over!
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 (condition-case nil
104513
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
564 (run-hooks 'semantic-after-idle-scheduler-reparse-hook)
a6a812dd2d88 * cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 104508
diff changeset
565 (error (setq semantic-after-idle-scheduler-reparse-hook nil))))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 ;; Return if we are lexically safe (from prog1)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 lexically-safe)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 ;; After updating the tags, handle any pending decorations for this
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 ;; buffer.
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
571 (require 'semantic/decorate/mode)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 (semantic-decorate-flush-pending-decorations (current-buffer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 ;;; IDLE SERVICES
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 ;; Idle Services are minor modes which enable or disable a services in
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 ;; the idle scheduler. Creating a new services only requires calling
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 ;; `semantic-create-idle-services' which does all the setup
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 ;; needed to create the minor mode that will enable or disable
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 ;; a services. The services must provide a single function.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583
106211
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
584 ;; FIXME doc is incomplete.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 (defmacro define-semantic-idle-service (name doc &rest forms)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586 "Create a new idle services with NAME.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 DOC will be a documentation string describing FORMS.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 FORMS will be called during idle time after the current buffer's
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 semantic tag information has been updated.
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106878
diff changeset
590 This routine creates the following functions and variables:"
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 (let ((global (intern (concat "global-" (symbol-name name) "-mode")))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 (mode (intern (concat (symbol-name name) "-mode")))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593 (hook (intern (concat (symbol-name name) "-mode-hook")))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (map (intern (concat (symbol-name name) "-mode-map")))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 (setup (intern (concat (symbol-name name) "-mode-setup")))
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
596 (func (intern (concat (symbol-name name) "-idle-function"))))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 `(eval-and-compile
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 (defun ,global (&optional arg)
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
600 ,(concat "Toggle " (symbol-name global) ".
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
601 With ARG, turn the minor mode on if ARG is positive, off otherwise.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
602
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
603 When this minor mode is enabled, `" (symbol-name mode) "' is
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
604 turned on in every Semantic-supported buffer.")
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 (interactive "P")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 (setq ,global
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 (semantic-toggle-minor-mode-globally
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 ',mode arg)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 (defcustom ,global nil
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
611 ,(concat "Non-nil if `" (symbol-name mode) "' is enabled.")
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 :group 'semantic-modes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 :type 'boolean
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 :require 'semantic/idle
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 :initialize 'custom-initialize-default
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 :set (lambda (sym val)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618 (,global (if val 1 -1))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620 (defcustom ,hook nil
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
621 ,(concat "Hook run at the end of function `" (symbol-name mode) "'.")
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 :type 'hook)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 (defvar ,map
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 (let ((km (make-sparse-keymap)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627 km)
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
628 ,(concat "Keymap for `" (symbol-name mode) "'."))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 (defvar ,mode nil
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
631 ,(concat "Non-nil if the minor mode `" (symbol-name mode) "' is enabled.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
632 Use the command `" (symbol-name mode) "' to change this variable."))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 (make-variable-buffer-local ',mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (defun ,setup ()
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
636 ,(concat "Set up `" (symbol-name mode) "'.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637 Return non-nil if the minor mode is enabled.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 (if ,mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 (if (not (and (featurep 'semantic) (semantic-active-p)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 (progn
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 ;; Disable minor mode if semantic stuff not available
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 (setq ,mode nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 (error "Buffer %s was not set up for parsing"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (buffer-name)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 ;; Enable the mode mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 (semantic-idle-scheduler-add #',func)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 ;; Disable the mode mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 (semantic-idle-scheduler-remove #',func)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 ,mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 (defun ,mode (&optional arg)
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
654 ,doc
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 (interactive
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 (list (or current-prefix-arg
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (if ,mode 0 1))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 (setq ,mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 (if arg
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
660 (>
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 (prefix-numeric-value arg)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662 0)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
663 (not ,mode)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 (,setup)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 (run-hooks ,hook)
106197
019d906c8f48 * cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents: 106165
diff changeset
666 (if (called-interactively-p 'interactive)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 (message "%s %sabled"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668 (symbol-name ',mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
669 (if ,mode "en" "dis")))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 (semantic-mode-line-update)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671 ,mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673 (semantic-add-minor-mode ',mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 "" ; idle schedulers are quiet?
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675 ,map)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 (defun ,func ()
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
678 ,(concat "Perform idle activity for the minor mode `"
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
679 (symbol-name mode) "'.")
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
680 ,@forms))))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 (put 'define-semantic-idle-service 'lisp-indent-function 1)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 ;;; SUMMARY MODE
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 ;; A mode similar to eldoc using semantic
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
687 (defcustom semantic-idle-truncate-long-summaries t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
688 "Truncate summaries that are too long to fit in the minibuffer.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
689 This can prevent minibuffer resizing in idle time."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
690 :group 'semantic
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
691 :type 'boolean)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 (defcustom semantic-idle-summary-function
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 'semantic-format-tag-summarize-with-file
106029
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
695 "Function to call when displaying tag information during idle time.
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
696 This function should take a single argument, a Semantic tag, and
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
697 return a string to display.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 Some useful functions are found in `semantic-format-tag-functions'."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
700 :type semantic-format-tag-custom-list)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
701
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 (defsubst semantic-idle-summary-find-current-symbol-tag (sym)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
703 "Search for a semantic tag with name SYM in database tables.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 Return the tag found or nil if not found.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 If semanticdb is not in use, use the current buffer only."
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
706 (car (if (and (featurep 'semantic/db)
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
707 semanticdb-current-database
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
708 (require 'semantic/db-find))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 (cdar (semanticdb-deep-find-tags-by-name sym))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 (semantic-deep-find-tags-by-name sym (current-buffer)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 (defun semantic-idle-summary-current-symbol-info-brutish ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 "Return a string message describing the current context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 Gets a symbol with `semantic-ctxt-current-thing' and then
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
715 tries to find it with a deep targeted search."
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 ;; Try the current "thing".
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 (let ((sym (car (semantic-ctxt-current-thing))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 (when sym
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 (semantic-idle-summary-find-current-symbol-tag sym))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 (defun semantic-idle-summary-current-symbol-keyword ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 "Return a string message describing the current symbol.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 Returns a value only if it is a keyword."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 ;; Try the current "thing".
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 (let ((sym (car (semantic-ctxt-current-thing))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 (if (and sym (semantic-lex-keyword-p sym))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 (semantic-lex-keyword-get sym 'summary))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 (defun semantic-idle-summary-current-symbol-info-context ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 "Return a string message describing the current context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 Use the semantic analyzer to find the symbol information."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 (let ((analysis (condition-case nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 (semantic-analyze-current-context (point))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 (error nil))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735 (when analysis
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
736 (require 'semantic/analyze)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 (semantic-analyze-interesting-tag analysis))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
738
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 (defun semantic-idle-summary-current-symbol-info-default ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740 "Return a string message describing the current context.
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
741 This function will disable loading of previously unloaded files
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 by semanticdb as a time-saving measure."
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
743 (semanticdb-without-unloaded-file-searches
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
744 (save-excursion
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
745 ;; use whichever has success first.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
746 (or
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
747 (semantic-idle-summary-current-symbol-keyword)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
748
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
749 (semantic-idle-summary-current-symbol-info-context)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
750
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
751 (semantic-idle-summary-current-symbol-info-brutish)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
752 ))))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 (defvar semantic-idle-summary-out-of-context-faces
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 '(
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 font-lock-comment-face
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 font-lock-string-face
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 font-lock-doc-string-face ; XEmacs.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 font-lock-doc-face ; Emacs 21 and later.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
760 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 "List of font-lock faces that indicate a useless summary context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
762 Those are generally faces used to highlight comments.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764 It might be useful to override this variable to add comment faces
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765 specific to a major mode. For example, in jde mode:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
766
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 \(defvar-mode-local jde-mode semantic-idle-summary-out-of-context-faces
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
768 (append (default-value 'semantic-idle-summary-out-of-context-faces)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 '(jde-java-font-lock-doc-tag-face
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 jde-java-font-lock-link-face
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
771 jde-java-font-lock-bold-face
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
772 jde-java-font-lock-underline-face
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
773 jde-java-font-lock-pre-face
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
774 jde-java-font-lock-code-face)))")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 (defun semantic-idle-summary-useful-context-p ()
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106878
diff changeset
777 "Non-nil if we should show a summary based on context."
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
778 (if (and (boundp 'font-lock-mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 font-lock-mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
780 (memq (get-text-property (point) 'face)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
781 semantic-idle-summary-out-of-context-faces))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
782 ;; The best I can think of at the moment is to disable
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
783 ;; in comments by detecting with font-lock.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
784 nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 t))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
787 (define-overloadable-function semantic-idle-summary-current-symbol-info ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788 "Return a string message describing the current context.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 (make-obsolete-overload 'semantic-eldoc-current-symbol-info
105789
6df5ff499103 * cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105760
diff changeset
791 'semantic-idle-summary-current-symbol-info
6df5ff499103 * cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105760
diff changeset
792 "23.2")
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793
106029
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
794 (defcustom semantic-idle-summary-mode-hook nil
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
795 "Hook run at the end of `semantic-idle-summary'."
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
796 :group 'semantic
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
797 :type 'hook)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
798
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
799 (defun semantic-idle-summary-idle-function ()
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
800 "Display a tag summary of the lexical token under the cursor.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 Call `semantic-idle-summary-current-symbol-info' for getting the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 current tag to display information."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 (or (eq major-mode 'emacs-lisp-mode)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
804 (not (semantic-idle-summary-useful-context-p))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
805 (let* ((found (semantic-idle-summary-current-symbol-info))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 (str (cond ((stringp found) found)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
807 ((semantic-tag-p found)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
808 (funcall semantic-idle-summary-function
106029
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
809 found nil t)))))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810 ;; Show the message with eldoc functions
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811 (unless (and str (boundp 'eldoc-echo-area-use-multiline-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
812 eldoc-echo-area-use-multiline-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
813 (let ((w (1- (window-width (minibuffer-window)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
814 (if (> (length str) w)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
815 (setq str (substring str 0 w)))))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
816 ;; I borrowed some bits from eldoc to shorten the
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
817 ;; message.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
818 (when semantic-idle-truncate-long-summaries
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
819 (let ((ea-width (1- (window-width (minibuffer-window))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
820 (strlen (length str)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
821 (when (> strlen ea-width)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
822 (setq str (substring str 0 ea-width)))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
823 ;; Display it
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
824 (eldoc-message str))))
106029
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
825
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
826 (define-minor-mode semantic-idle-summary-mode
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
827 "Toggle Semantic Idle Summary mode.
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
828 With ARG, turn Semantic Idle Summary mode on if ARG is positive,
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
829 off otherwise.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
830
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
831 When this minor mode is enabled, the echo area displays a summary
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
832 of the lexical token at point whenever Emacs is idle."
106029
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
833 :group 'semantic
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
834 :group 'semantic-modes
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
835 (semantic-idle-summary-mode-setup)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
836 (semantic-mode-line-update))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
837
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
838 (defun semantic-idle-summary-refresh-echo-area ()
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
839 (and semantic-idle-summary-mode
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
840 eldoc-last-message
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
841 (if (and (not executing-kbd-macro)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
842 (not (and (boundp 'edebug-active) edebug-active))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
843 (not cursor-in-echo-area)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
844 (not (eq (selected-window) (minibuffer-window))))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
845 (eldoc-message eldoc-last-message)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
846 (setq eldoc-last-message nil))))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
847
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
848 (defun semantic-idle-summary-mode-setup ()
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
849 "Set up `semantic-idle-summary-mode'."
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
850 (if semantic-idle-summary-mode
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
851 ;; Enable the mode
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
852 (progn
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
853 (unless (and (featurep 'semantic) (semantic-active-p))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
854 ;; Disable minor mode if semantic stuff not available
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
855 (setq semantic-idle-summary-mode nil)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
856 (error "Buffer %s was not set up for parsing"
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
857 (buffer-name)))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
858 (require 'eldoc)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
859 (semantic-idle-scheduler-add 'semantic-idle-summary-idle-function)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
860 (add-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
861 ;; Disable the mode
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
862 (semantic-idle-scheduler-remove 'semantic-idle-summary-idle-function)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
863 (remove-hook 'pre-command-hook 'semantic-idle-summary-refresh-echo-area t))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
864 semantic-idle-summary-mode)
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
865
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
866 (semantic-add-minor-mode 'semantic-idle-summary-mode "")
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
867
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
868 (define-minor-mode global-semantic-idle-summary-mode
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
869 "Toggle Global Semantic Idle Summary mode.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
870 With ARG, turn Global Semantic Idle Summary mode on if ARG is
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
871 positive, off otherwise.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
872
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
873 When this minor mode is enabled, `semantic-idle-summary-mode' is
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
874 turned on in every Semantic-supported buffer."
106029
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
875 :global t
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
876 :group 'semantic
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
877 :group 'semantic-modes
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
878 (semantic-toggle-minor-mode-globally
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
879 'semantic-idle-summary-mode
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
880 (if global-semantic-idle-summary-mode 1 -1)))
d749d487704e * cedet/semantic/idle.el (semantic-idle-summary-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
881
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
882
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
883 ;;; Current symbol highlight
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
884 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 ;; This mode will use context analysis to perform highlighting
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
886 ;; of all uses of the symbol that is under the cursor.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
887 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
888 ;; This is to mimic the Eclipse tool of a similar nature.
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
889 (defvar semantic-idle-symbol-highlight-face 'region
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
890 "Face used for highlighting local symbols.")
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
891
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
892 (defun semantic-idle-symbol-maybe-highlight (tag)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
893 "Perhaps add highlighting to the symbol represented by TAG.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
894 TAG was found as the symbol under point. If it happens to be
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
895 visible, then highlight it."
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
896 (require 'pulse)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 (let* ((region (when (and (semantic-tag-p tag)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
898 (semantic-tag-with-position-p tag))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 (semantic-tag-overlay tag)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
900 (file (when (and (semantic-tag-p tag)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
901 (semantic-tag-with-position-p tag))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
902 (semantic-tag-file-name tag)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
903 (buffer (when file (get-file-buffer file)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
904 ;; We use pulse, but we don't want the flashy version,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
905 ;; just the stable version.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
906 (pulse-flag nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
907 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 (cond ((semantic-overlay-p region)
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105789
diff changeset
909 (with-current-buffer (semantic-overlay-buffer region)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
910 (goto-char (semantic-overlay-start region))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
911 (when (pos-visible-in-window-p
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
912 (point) (get-buffer-window (current-buffer) 'visible))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
913 (if (< (semantic-overlay-end region) (point-at-eol))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
914 (pulse-momentary-highlight-overlay
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
915 region semantic-idle-symbol-highlight-face)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
916 ;; Not the same
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
917 (pulse-momentary-highlight-region
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
918 (semantic-overlay-start region)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
919 (point-at-eol)
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
920 semantic-idle-symbol-highlight-face)))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
921 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
922 ((vectorp region)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
923 (let ((start (aref region 0))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
924 (end (aref region 1)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
925 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
926 (when buffer (set-buffer buffer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927 ;; As a vector, we have no filename. Perhaps it is a
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
928 ;; local variable?
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
929 (when (and (<= end (point-max))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
930 (pos-visible-in-window-p
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
931 start (get-buffer-window (current-buffer) 'visible)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
932 (goto-char start)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
933 (when (re-search-forward
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
934 (regexp-quote (semantic-tag-name tag))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
935 end t)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
936 ;; This is likely it, give it a try.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
937 (pulse-momentary-highlight-region
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
938 start (if (<= end (point-at-eol)) end
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
939 (point-at-eol))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
940 semantic-idle-symbol-highlight-face)))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
941 ))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
942 nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
943
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
944 (define-semantic-idle-service semantic-idle-local-symbol-highlight
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
945 "Highlight the tag and symbol references of the symbol under point.
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
946 Call `semantic-analyze-current-context' to find the reference tag.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
947 Call `semantic-symref-hits-in-region' to identify local references."
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
948 (require 'pulse)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
949 (when (semantic-idle-summary-useful-context-p)
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
950 (let* ((ctxt
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
951 (semanticdb-without-unloaded-file-searches
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
952 (semantic-analyze-current-context)))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953 (Hbounds (when ctxt (oref ctxt bounds)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
954 (target (when ctxt (car (reverse (oref ctxt prefix)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
955 (tag (semantic-current-tag))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
956 ;; We use pulse, but we don't want the flashy version,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
957 ;; just the stable version.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 (pulse-flag nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959 (when ctxt
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
960 ;; Highlight the original tag? Protect against problems.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
961 (condition-case nil
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
962 (semantic-idle-symbol-maybe-highlight target)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
963 (error nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
964 ;; Identify all hits in this current tag.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
965 (when (semantic-tag-p target)
104454
e4842bf0f303 lisp/cedet/semantic/symref/filter.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
966 (require 'semantic/symref/filter)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
967 (semantic-symref-hits-in-region
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
968 target (lambda (start end prefix)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
969 (when (/= start (car Hbounds))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
970 (pulse-momentary-highlight-region
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
971 start end semantic-idle-symbol-highlight-face))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
972 (semantic-throw-on-input 'symref-highlight)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
973 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
974 (semantic-tag-start tag)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
975 (semantic-tag-end tag)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
976 ))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
977
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
978
106211
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
979 ;;;###autoload
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
980 (defun global-semantic-idle-scheduler-mode (&optional arg)
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
981 "Toggle global use of option `semantic-idle-scheduler-mode'.
106895
181539c8b6a4 Fix typos in docstrings, error messages, etc.
Juanma Barranquero <lekktu@gmail.com>
parents: 106878
diff changeset
982 The idle scheduler will automatically reparse buffers in idle time,
106211
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
983 and then schedule other jobs setup with `semantic-idle-scheduler-add'.
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
984 If ARG is positive, enable, if it is negative, disable.
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
985 If ARG is nil, then toggle."
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
986 (interactive "P")
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
987 ;; When turning off, disable other idle modes.
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
988 (when (or (and (numberp arg) (< arg 0))
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
989 (and (null arg) global-semantic-idle-scheduler-mode))
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
990 (global-semantic-idle-summary-mode -1)
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
991 (global-semantic-idle-local-symbol-highlight-mode -1)
106211
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
992 (global-semantic-idle-completions-mode -1))
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
993 (setq global-semantic-idle-scheduler-mode
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
994 (semantic-toggle-minor-mode-globally
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
995 'semantic-idle-scheduler-mode arg)))
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
996
a26517472883 (global-semantic-idle-scheduler-mode): Move after definition of
Glenn Morris <rgm@gnu.org>
parents: 106197
diff changeset
997
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
998 ;;; Completion Popup Mode
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
999 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1000 ;; This mode uses tooltips to display a (hopefully) short list of possible
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1001 ;; completions available for the text under point. It provides
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1002 ;; NO provision for actually filling in the values from those completions.
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1003 (defun semantic-idle-completions-end-of-symbol-p ()
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1004 "Return non-nil if the cursor is at the END of a symbol.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1005 If the cursor is in the middle of a symbol, then we shouldn't be
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1006 doing fancy completions."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1007 (not (looking-at "\\w\\|\\s_")))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1008
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1009 (defun semantic-idle-completion-list-default ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1010 "Calculate and display a list of completions."
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1011 (when (and (semantic-idle-summary-useful-context-p)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1012 (semantic-idle-completions-end-of-symbol-p))
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1013 ;; This mode can be fragile. Ignore problems.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1014 ;; If something doesn't do what you expect, run
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1015 ;; the below command by hand instead.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1016 (condition-case nil
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1017 (semanticdb-without-unloaded-file-searches
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1018 ;; Use idle version.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1019 (semantic-complete-analyze-inline-idle)
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1020 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1021 (error nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1022 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1023
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1024 (define-semantic-idle-service semantic-idle-completions
106165
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1025 "Toggle Semantic Idle Completions mode.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1026 With ARG, turn Semantic Idle Completions mode on if ARG is
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1027 positive, off otherwise.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1028
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1029 This minor mode only takes effect if Semantic is active and
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1030 `semantic-idle-scheduler-mode' is enabled.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1031
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1032 When enabled, Emacs displays a list of possible completions at
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1033 idle time. The method for displaying completions is given by
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1034 `semantic-complete-inline-analyzer-idle-displayor-class'; the
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1035 default is to show completions inline.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1036
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1037 While a completion is displayed, RET accepts the completion; M-n
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1038 and M-p cycle through completion alternatives; TAB attempts to
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1039 complete as far as possible, and cycles if no additional
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1040 completion is possible; and any other command cancels the
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1041 completion.
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1042
0a1b5bffcd05 * cedet/semantic/complete.el (semantic-complete-inline-map): Doc
Chong Yidong <cyd@stupidchicken.com>
parents: 106150
diff changeset
1043 \\{semantic-complete-inline-map}"
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1044 ;; Add the ability to override sometime.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1045 (semantic-idle-completion-list-default))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1046
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1047
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1048 ;;; Breadcrumbs for tag under point
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1049 ;;
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1050 ;; Service that displays a breadcrumbs indication of the tag under
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1051 ;; point and its parents in the header or mode line.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1052 ;;
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1053
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1054 (defcustom semantic-idle-breadcrumbs-display-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1055 #'semantic-idle-breadcrumbs--display-in-header-line
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1056 "Function to display the tag under point in idle time.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1057 This function should take a list of Semantic tags as its only
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1058 argument. The tags are sorted according to their nesting order,
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1059 starting with the outermost tag. The function should call
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1060 `semantic-idle-breadcrumbs-format-tag-list-function' to convert
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1061 the tag list into a string."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1062 :group 'semantic
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1063 :type '(choice
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1064 (const :tag "Display in header line"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1065 semantic-idle-breadcrumbs--display-in-header-line)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1066 (const :tag "Display in mode line"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1067 semantic-idle-breadcrumbs--display-in-mode-line)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1068 (function :tag "Other function")))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1069
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1070 (defcustom semantic-idle-breadcrumbs-format-tag-list-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1071 #'semantic-idle-breadcrumbs--format-linear
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1072 "Function to format the list of tags containing point.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1073 This function should take a list of Semantic tags and an optional
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1074 maximum length of the produced string as its arguments. The
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1075 maximum length is a hint and can be ignored. When the maximum
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1076 length is omitted, an unconstrained string should be
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1077 produced. The tags are sorted according to their nesting order,
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1078 starting with the outermost tag. Single tags should be formatted
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1079 using `semantic-idle-breadcrumbs-format-tag-function' unless
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1080 special formatting is required."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1081 :group 'semantic
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1082 :type '(choice
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1083 (const :tag "Format tags as list, innermost last"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1084 semantic-idle-breadcrumbs--format-linear)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1085 (const :tag "Innermost tag with details, followed by remaining tags"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1086 semantic-idle-breadcrumbs--format-innermost-first)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1087 (function :tag "Other function")))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1088
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1089 (defcustom semantic-idle-breadcrumbs-format-tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1090 #'semantic-format-tag-abbreviate
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1091 "Function to call to format information about tags.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1092 This function should take a single argument, a Semantic tag, and
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1093 return a string to display.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1094 Some useful functions are found in `semantic-format-tag-functions'."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1095 :group 'semantic
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1096 :type semantic-format-tag-custom-list)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1097
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1098 (defcustom semantic-idle-breadcrumbs-separator 'mode-specific
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1099 "Specify how to separate tags in the breadcrumbs string.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1100 An arbitrary string or a mode-specific scope nesting
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1101 string (like, for example, \"::\" in C++, or \".\" in Java) can
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1102 be used."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1103 :group 'semantic
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1104 :type '(choice
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1105 (const :tag "Use mode specific separator"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1106 mode-specific)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1107 (string :tag "Specify separator string")))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1108
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1109 (defcustom semantic-idle-breadcrumbs-header-line-prefix
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1110 semantic-stickyfunc-indent-string ;; TODO not optimal
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1111 "String used to indent the breadcrumbs string.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1112 Customize this string to match the space used by scrollbars and
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1113 fringe."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1114 :group 'semantic
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1115 :type 'string)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1116
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1117 (defvar semantic-idle-breadcrumbs-popup-menu nil
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1118 "Menu used when a tag displayed by `semantic-idle-breadcrumbs-mode' is clicked.")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1119
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1120 (defun semantic-idle-breadcrumbs--popup-menu (event)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1121 "Popup a menu that displays things to do to the clicked tag.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1122 Argument EVENT describes the event that caused this function to
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1123 be called."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1124 (interactive "e")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1125 (let ((old-window (selected-window))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1126 (window (semantic-event-window event)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1127 (select-window window t)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1128 (semantic-popup-menu semantic-idle-breadcrumbs-popup-menu)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1129 (select-window old-window)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1130
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1131 (defmacro semantic-idle-breadcrumbs--tag-function (function)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1132 "Return lambda expression calling FUNCTION when called from a popup."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1133 `(lambda (event)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1134 (interactive "e")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1135 (let* ((old-window (selected-window))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1136 (window (semantic-event-window event))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1137 (column (car (nth 6 (nth 1 event)))) ;; TODO semantic-event-column?
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1138 (tag (progn
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1139 (select-window window t)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1140 (plist-get
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1141 (text-properties-at column header-line-format)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1142 'tag))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1143 (,function tag)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1144 (select-window old-window)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1145 )
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1146
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1147 ;; TODO does this work for mode-line case?
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1148 (defvar semantic-idle-breadcrumbs-popup-map
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1149 (let ((map (make-sparse-keymap)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1150 ;; mouse-1 goes to clicked tag
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1151 (define-key map
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1152 [ header-line mouse-1 ]
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1153 (semantic-idle-breadcrumbs--tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1154 semantic-go-to-tag))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1155 ;; mouse-3 pops up a context menu
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1156 (define-key map
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1157 [ header-line mouse-3 ]
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1158 'semantic-idle-breadcrumbs--popup-menu)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1159 map)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1160 "Keymap for semantic idle breadcrumbs minor mode.")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1161
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1162 (easy-menu-define
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1163 semantic-idle-breadcrumbs-popup-menu
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1164 semantic-idle-breadcrumbs-popup-map
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1165 "Semantic Breadcrumbs Mode Menu"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1166 (list
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1167 "Breadcrumb Tag"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1168 (semantic-menu-item
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1169 (vector
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1170 "Go to Tag"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1171 (semantic-idle-breadcrumbs--tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1172 semantic-go-to-tag)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1173 :active t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1174 :help "Jump to this tag"))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1175 ;; TODO these entries need minor changes (optional tag argument) in
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1176 ;; senator-copy-tag etc
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1177 ;; (semantic-menu-item
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1178 ;; (vector
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1179 ;; "Copy Tag"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1180 ;; (semantic-idle-breadcrumbs--tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1181 ;; senator-copy-tag)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1182 ;; :active t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1183 ;; :help "Copy this tag"))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1184 ;; (semantic-menu-item
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1185 ;; (vector
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1186 ;; "Kill Tag"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1187 ;; (semantic-idle-breadcrumbs--tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1188 ;; senator-kill-tag)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1189 ;; :active t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1190 ;; :help "Kill tag text to the kill ring, and copy the tag to
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1191 ;; the tag ring"))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1192 ;; (semantic-menu-item
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1193 ;; (vector
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1194 ;; "Copy Tag to Register"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1195 ;; (semantic-idle-breadcrumbs--tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1196 ;; senator-copy-tag-to-register)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1197 ;; :active t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1198 ;; :help "Copy this tag"))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1199 ;; (semantic-menu-item
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1200 ;; (vector
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1201 ;; "Narrow to Tag"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1202 ;; (semantic-idle-breadcrumbs--tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1203 ;; senator-narrow-to-defun)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1204 ;; :active t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1205 ;; :help "Narrow to the bounds of the current tag"))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1206 ;; (semantic-menu-item
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1207 ;; (vector
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1208 ;; "Fold Tag"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1209 ;; (semantic-idle-breadcrumbs--tag-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1210 ;; senator-fold-tag-toggle)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1211 ;; :active t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1212 ;; :style 'toggle
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1213 ;; :selected '(let ((tag (semantic-current-tag)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1214 ;; (and tag (semantic-tag-folded-p tag)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1215 ;; :help "Fold the current tag to one line"))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1216 "---"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1217 (semantic-menu-item
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1218 (vector
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1219 "About this Header Line"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1220 (lambda ()
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1221 (interactive)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1222 (describe-function 'semantic-idle-breadcrumbs-mode))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1223 :active t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1224 :help "Display help about this header line."))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1225 )
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1226 )
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1227
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1228 (define-semantic-idle-service semantic-idle-breadcrumbs
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1229 "Display breadcrumbs for the tag under point and its parents."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1230 (let* ((scope (semantic-calculate-scope))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1231 (tag-list (if scope
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1232 ;; If there is a scope, extract the tag and its
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1233 ;; parents.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1234 (append (oref scope parents)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1235 (when (oref scope tag)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1236 (list (oref scope tag))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1237 ;; Fall back to tags by overlay
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1238 (semantic-find-tag-by-overlay))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1239 ;; Display the tags.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1240 (funcall semantic-idle-breadcrumbs-display-function tag-list)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1241
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1242 (defun semantic-idle-breadcrumbs--display-in-header-line (tag-list)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1243 "Display the tags in TAG-LIST in the header line of their buffer."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1244 (let ((width (- (nth 2 (window-edges))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1245 (nth 0 (window-edges)))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1246 ;; Format TAG-LIST and put the formatted string into the header
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1247 ;; line.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1248 (setq header-line-format
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1249 (concat
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1250 semantic-idle-breadcrumbs-header-line-prefix
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1251 (if tag-list
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1252 (semantic-idle-breadcrumbs--format-tag-list
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1253 tag-list
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1254 (- width
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1255 (length semantic-idle-breadcrumbs-header-line-prefix)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1256 (propertize
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1257 "<not on tags>"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1258 'face
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1259 'font-lock-comment-face)))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1260
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1261 ;; Update the header line.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1262 (force-mode-line-update))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1263
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1264 (defun semantic-idle-breadcrumbs--display-in-mode-line (tag-list)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1265 "Display the tags in TAG-LIST in the mode line of their buffer.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1266 TODO THIS FUNCTION DOES NOT WORK YET."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1267
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1268 (error "This function does not work yet")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1269
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1270 (let ((width (- (nth 2 (window-edges))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1271 (nth 0 (window-edges)))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1272 (setq mode-line-format
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1273 (semantic-idle-breadcrumbs--format-tag-list tag-list width)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1274
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1275 (force-mode-line-update))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1276
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1277 (defun semantic-idle-breadcrumbs--format-tag-list (tag-list max-length)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1278 "Format TAG-LIST using configured functions respecting MAX-LENGTH.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1279 If the initial formatting result is longer than MAX-LENGTH, it is
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1280 shortened at the beginning."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1281 ;; Format TAG-LIST using the configured formatting function.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1282 (let* ((complete-format (funcall
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1283 semantic-idle-breadcrumbs-format-tag-list-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1284 tag-list max-length))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1285 ;; Determine length of complete format.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1286 (complete-length (length complete-format)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1287 ;; Shorten string if necessary.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1288 (if (<= complete-length max-length)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1289 complete-format
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1290 (concat "... "
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1291 (substring
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1292 complete-format
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1293 (- complete-length (- max-length 4))))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1294 )
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1295
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1296 (defun semantic-idle-breadcrumbs--format-linear
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1297 (tag-list &optional max-length)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1298 "Format TAG-LIST as a linear list, starting with the outermost tag.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1299 MAX-LENGTH is not used."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1300 (require 'semantic/analyze/fcn)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1301 (let* ((format-pieces (mapcar
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1302 #'semantic-idle-breadcrumbs--format-tag
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1303 tag-list))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1304 ;; Format tag list, putting configured separators between the
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1305 ;; tags.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1306 (complete-format (cond
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1307 ;; Mode specific separator.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1308 ((eq semantic-idle-breadcrumbs-separator
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1309 'mode-specific)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1310 (semantic-analyze-unsplit-name format-pieces))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1311
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1312 ;; Custom separator.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1313 ((stringp semantic-idle-breadcrumbs-separator)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1314 (mapconcat
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1315 #'identity
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1316 format-pieces
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1317 semantic-idle-breadcrumbs-separator)))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1318 complete-format)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1319 )
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1320
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1321 (defun semantic-idle-breadcrumbs--format-innermost-first
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1322 (tag-list &optional max-length)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1323 "Format TAG-LIST placing the innermost tag first, separated from its parents.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1324 If MAX-LENGTH is non-nil, the innermost tag is shortened."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1325 (let* (;; Separate and format remaining tags. Calculate length of
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1326 ;; resulting string.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1327 (rest-tags (butlast tag-list))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1328 (rest-format (if rest-tags
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1329 (concat
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1330 " | "
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1331 (semantic-idle-breadcrumbs--format-linear
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1332 rest-tags))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1333 ""))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1334 (rest-length (length rest-format))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1335 ;; Format innermost tag and calculate length of resulting
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1336 ;; string.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1337 (inner-format (semantic-idle-breadcrumbs--format-tag
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1338 (car (last tag-list))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1339 #'semantic-format-tag-prototype))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1340 (inner-length (length inner-format))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1341 ;; Calculate complete length and shorten string for innermost
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1342 ;; tag if MAX-LENGTH is non-nil and the complete string is
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1343 ;; too long.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1344 (complete-length (+ inner-length rest-length))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1345 (inner-short (if (and max-length
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1346 (<= complete-length max-length))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1347 inner-format
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1348 (concat (substring
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1349 inner-format
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1350 0
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1351 (- inner-length
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1352 (- complete-length max-length)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1353 4))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1354 " ..."))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1355 ;; Concat both parts.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1356 (concat inner-short rest-format))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1357 )
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1358
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1359 (defun semantic-idle-breadcrumbs--format-tag (tag &optional format-function)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1360 "Format TAG using the configured function or FORMAT-FUNCTION.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1361 This function also adds text properties for help-echo, mouse
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1362 highlighting and a keymap."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1363 (let ((formatted (funcall
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1364 (or format-function
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1365 semantic-idle-breadcrumbs-format-tag-function)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1366 tag nil t)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1367 (add-text-properties
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1368 0 (length formatted)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1369 (list
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1370 'tag
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1371 tag
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1372 'help-echo
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1373 (format
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1374 "Tag %s
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1375 Type: %s
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1376 mouse-1: jump to tag
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1377 mouse-3: popup context menu"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1378 (semantic-tag-name tag)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1379 (semantic-tag-class tag))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1380 'mouse-face
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1381 'highlight
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1382 'keymap
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1383 semantic-idle-breadcrumbs-popup-map)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1384 formatted)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1385 formatted))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1386
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106895
diff changeset
1387
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1388 (provide 'semantic/idle)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1389
104463
e4788b39543d lisp/cedet/semantic/idle.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104454
diff changeset
1390 ;; Local variables:
e4788b39543d lisp/cedet/semantic/idle.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104454
diff changeset
1391 ;; generated-autoload-file: "loaddefs.el"
e4788b39543d lisp/cedet/semantic/idle.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104454
diff changeset
1392 ;; generated-autoload-load-name: "semantic/idle"
e4788b39543d lisp/cedet/semantic/idle.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104454
diff changeset
1393 ;; End:
e4788b39543d lisp/cedet/semantic/idle.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104454
diff changeset
1394
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105340
diff changeset
1395 ;; arch-tag: 4bfd54da-5023-4cc1-91ae-e1fefc1a8d1b
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1396 ;;; semantic-idle.el ends here