sem-user.texi 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  1. @c This is part of the Semantic manual.
  2. @c Copyright (C) 1999-2005, 2007, 2009-2017 Free Software Foundation,
  3. @c Inc.
  4. @c See file semantic.texi for copying conditions.
  5. You can begin using @semantic{} by enabling Semantic mode, a global
  6. minor mode: type @kbd{M-x semantic-mode}, or open the @samp{Tools}
  7. menu and click on the menu item named @samp{Source Code Parsers
  8. (Semantic)}. @xref{Semantic mode}.
  9. When Semantic mode is turned on, Emacs automatically parses each file
  10. you visit. You can then use @semantic{} user commands in those
  11. buffers (@pxref{Semantic mode user commands}). You can also choose to
  12. enable a number of ``helper'' minor modes for saving tags, displaying
  13. tag information, and so forth.
  14. To enable Semantic mode each time you start Emacs, add the line
  15. @code{(semantic-mode 1)} to your initialization file. @xref{Init
  16. File,,,emacs,Emacs manual}.
  17. @menu
  18. * Semantic mode:: Global minor mode for @semantic{}.
  19. * SemanticDB:: Caching parsed buffers between sessions.
  20. * Idle Scheduler:: @semantic{} actions that occur when idle.
  21. * Analyzer:: Semantic tools for analyzing code.
  22. * Speedbar:: Using @semantic{} with the Speedbar.
  23. * SymRef:: Interface to symbol reference tools.
  24. * MRU Bookmarks:: Managing tag "bookmarks".
  25. * Sticky Func Mode:: Showing declarations in the header line.
  26. * Highlight Func Mode:: Highlight the current function declaration.
  27. * Tag Decoration Mode:: Minor mode to decorate tags.
  28. @end menu
  29. @node Semantic mode
  30. @section Semantic mode
  31. @cindex Semantic mode
  32. Semantic mode is a global minor mode for @semantic{} as a whole. When
  33. enabled, each file you visit is automatically parsed, provided its
  34. major mode is specified in the variable
  35. @code{semantic-new-buffer-setup-functions} (the default value of this
  36. variable sets up parsing for all the parsers included with Emacs, but
  37. you may add to it if you install additional parsers).
  38. In each parser-enabled buffer, a number of @semantic{} commands are
  39. available for navigating, querying, and editing source code.
  40. @xref{Semantic mode user commands}. Enabling Semantic mode also
  41. installs a @samp{Development} menu on the menu-bar, with many of these
  42. commands.
  43. In addition, enabling Semantic mode turns on certain auxiliary global
  44. minor modes. The variable @code{semantic-default-submodes} determines
  45. which auxiliary modes are enabled; the defaults are SemanticDB mode
  46. (@pxref{SemanticDB}) and Global Semantic Idle Scheduler mode
  47. (@pxref{Idle Scheduler}). You can also toggle the auxiliary minor
  48. modes separately, using their mode functions (e.g., @kbd{M-x
  49. semanticdb-minor-mode}), or via the @samp{Development} menu. The
  50. various auxiliary minor modes are described in the following sections.
  51. @defvar semantic-new-buffer-setup-functions
  52. The value of this variable is an alist of functions to call for
  53. setting up @semantic{} parsing in the buffer. Each element has the
  54. form @code{(@var{mode} . @var{fn})}, where @var{mode} is a value of
  55. @code{major-mode} for the buffer and @var{fn} is the corresponding
  56. function for setting up the parser. @var{fn} is called, with no
  57. arguments, after the major mode is initialized (and after the mode
  58. hooks have been run).
  59. The default value enables @semantic{} for all supported major modes
  60. (i.e., C, C++, Scheme, Javascript, Java, HTML, SRecode, and Make), but
  61. you can remove modes from this list if you don't want to use
  62. @semantic{} with them.
  63. @end defvar
  64. @defvar semantic-default-submodes
  65. The value of this variable is a list of symbols, specifying the
  66. auxiliary minor modes to enable when enabling Semantic mode. The
  67. valid mode symbols are:
  68. @itemize
  69. @item @code{global-semantic-idle-scheduler-mode} (@pxref{Idle Scheduler}).
  70. @item @code{global-semanticdb-minor-mode} (@pxref{SemanticDB}).
  71. @item @code{global-semantic-idle-summary-mode} (@pxref{Idle Summary Mode}).
  72. @item @code{global-semantic-idle-completions-mode} (@pxref{Idle Completions Mode}).
  73. @item @code{global-semantic-highlight-func-mode} (@pxref{Highlight Func Mode}).
  74. @item @code{global-semantic-decoration-mode} (@pxref{Tag Decoration Mode}).
  75. @item @code{global-semantic-stickyfunc-mode} (@pxref{Sticky Func Mode}).
  76. @item @code{global-semantic-mru-bookmark-mode} (@pxref{MRU Bookmarks}).
  77. @end itemize
  78. @end defvar
  79. @menu
  80. * Semantic mode user commands::
  81. @end menu
  82. @node Semantic mode user commands
  83. @subsection Semantic mode user commands
  84. Semantic mode provides a number of commands for navigating, querying,
  85. and editing source code in a language-aware manner. These commands
  86. generally act on @dfn{tags}, which are the source-code units deemed
  87. ``important'' by the present programming language (e.g., functions in
  88. the C programming language).
  89. These commands may be used in any buffer that has been parsed by
  90. @semantic{}. Several of them prompt for a tag name using the
  91. minibuffer; here, the @kbd{TAB} key can be used to complete tag names.
  92. Others act on the @dfn{current tag}, meaning the tag at (or around)
  93. point.
  94. @table @kbd
  95. @item C-c , j
  96. Prompt for a tag defined in the current file, and move point to it
  97. (@code{semantic-complete-jump-local}).
  98. @item C-c , J
  99. Prompt for a tag defined in any file that Emacs has parsed, and move
  100. point to it (@code{semantic-complete-jump}).
  101. @item C-c , l
  102. Display a list of the possible completions of the current tag
  103. (@code{semantic-analyze-possible-completions}).
  104. @item C-c , g
  105. Prompt for a tag, and display a list of tags that call it
  106. (@code{semantic-symref-symbol}). This relies on the presence of an
  107. external symbol reference tool. @xref{SymRef}.
  108. @item C-c , G
  109. Display a list of tags that call the current tag
  110. (@code{semantic-symref}). This relies on the presence of an external
  111. symbol reference tool. @xref{SymRef}.
  112. @item C-c , p
  113. Move point to the previous tag (@code{senator-previous-tag}).
  114. @item C-c , n
  115. Move point to the next tag (@code{senator-next-tag}).
  116. @item C-c , u
  117. Move point ``up'' one reference (@code{senator-go-to-up-reference}).
  118. The meaning of ``up'' is language-dependent; in C++, for instance,
  119. this means moving to the parent of the current tag.
  120. @item C-c, @key{SPC}
  121. Display a list of possible completions for the symbol at point
  122. (@code{semantic-complete-analyze-inline}). This also activates a
  123. special set of keybindings for choosing a completion: @key{RET}
  124. accepts the current completion, @kbd{M-n} and @kbd{M-p} cycle through
  125. possible completions, @key{TAB} completes as far as possible and then
  126. cycles, and @kbd{C-g} or any other key aborts the completion.
  127. @xref{Smart Completion}.
  128. @item C-c , C-w
  129. Kill the current tag (@code{senator-kill-tag}). This removes the text
  130. for that tag, placing it in the kill ring. You can retrieve the text
  131. with @kbd{C-y}. This also places the tag in the @dfn{tag ring}, so
  132. that you can yank it with @kbd{\C-c,\C-y}, below.
  133. @item C-c , M-w
  134. Copy the current tag into the kill ring as well as the tag ring
  135. (@code{senator-copy-tag}).
  136. @item C-c , C-y
  137. Yank a tag from the tag ring (@code{senator-yank-tag}).
  138. @item C-c , r
  139. Copy the current tag into a register
  140. (@code{senator-copy-tag-to-register}). With an optional argument,
  141. kill it as well. This allows you to insert or jump to that tag with
  142. the usual register commands. @xref{Registers,,,emacs,Emacs manual}.
  143. @item C-c , @kbd{up}
  144. Transpose the current tag with the previous one
  145. (@code{senator-transpose-tags-up}).
  146. @item C-c , @kbd{down}
  147. Transpose the current tag with the next one
  148. (@code{senator-transpose-tags-down}).
  149. @end table
  150. @node SemanticDB
  151. @section Semantic Database
  152. @cindex SemanticDB
  153. The Semantic Database (SemanticDB) caches the results of parsing
  154. source code files. This data can be saved to disk when you exit
  155. Emacs, and reloaded automatically when you subsequently revisit the
  156. same source code files. This saves time by eliminating the need to
  157. re-parse unmodified files.
  158. SemanticDB also provides an @acronym{API} that programs can use to
  159. acquire information about source code tags. This information can be
  160. accessed without loading the original the source files into memory.
  161. It can also be used to create alternate ``back-ends'' for storing tag
  162. information in alternative on-disk formats.
  163. By default, SemanticDB is enabled together with Semantic mode. To
  164. disable it, remove it from @code{semantic-default-submodes}
  165. (@pxref{Semantic mode}). You can also enable or disable SemanticDB
  166. with @kbd{M-x global-semanticdb-minor-mode}.
  167. @deffn Command global-semanticdb-minor-mode
  168. Toggle SemanticDB mode. When enabled, any source code parsed by
  169. @semantic{} is cached in a database.
  170. @end deffn
  171. SemanticDB offers a large number of customizable options, which are
  172. described in the following subsections.
  173. @menu
  174. * Semanticdb Tag Storage::
  175. * Semanticdb Search Configuration::
  176. * Changing Backends::
  177. * Create System Databases::
  178. @end menu
  179. @node Semanticdb Tag Storage
  180. @subsection Semanticdb Tag Storage
  181. Each time you exit Emacs, any data cached by SemanticDB is saved in
  182. the directory @file{.emacs.d/semanticdb/}, located in your home
  183. directory. Within this directory, the cache data is written into a
  184. set of files according to a SemanticDB-specific filename convention.
  185. If the SemanticDB directory does not exist, Emacs first asks if you
  186. want to create it.
  187. You can change the name of the SemanticDB directory by customizing the
  188. variable @code{semanticdb-default-save-directory}.
  189. @deffn Option semanticdb-default-save-directory
  190. The name of the directory where SemanticDB cache files are saved. If
  191. the value is @code{nil}, SemanticDB saves its data into a single file,
  192. in the current directory, whose filename is given by
  193. @code{semanticdb-default-file-name}.
  194. @end deffn
  195. @deffn Option semanticdb-default-file-name
  196. The name of a cache file in which to save SemanticDB, when
  197. @code{semanticdb-default-save-directory} is @code{nil}.
  198. @end deffn
  199. You can force SemanticDB to save the data from only certain files, or
  200. suppress saving altogether, by customizing
  201. @code{semanticdb-persistent-path}:
  202. @deffn Option semanticdb-persistent-path
  203. List of valid paths for SemanticDB to cache. Each element should be a
  204. directory name (a string); then the parse data from any file in that
  205. directory is saved.
  206. As a special exception, the value of this variable can be a list
  207. containing a single symbol: @code{never}, @code{always}, or
  208. @code{project}. The symbol @code{never} disables saving anywhere;
  209. @code{always} enables saving everywhere; and @code{project} enables
  210. saving directory based on the variable
  211. @code{semanticdb-project-predicate-functions}.
  212. The default value is @code{(always)}.
  213. @end deffn
  214. @defvar semanticdb-project-predicate-functions
  215. The value of this variable is a list of predicates for indicating that
  216. a directory belongs to a project. This list is used when the value of
  217. @code{semanticdb-persistent-path} is @code{(project)}. If the list is
  218. empty, all paths are considered valid.
  219. Project management packages, such as EDE (@pxref{Top,,,ede,EDE
  220. manual}), may add their own predicates with @dfn{add-hook} to this
  221. variable. This allows SemanticDB to save tag caches in directories
  222. controlled by them.
  223. @end defvar
  224. @deffn Option semanticdb-save-database-functions
  225. Abnormal hook run after a database is saved. Each function is called
  226. with one argument, the object representing the database recently
  227. written.
  228. @end deffn
  229. @node Semanticdb Search Configuration
  230. @subsection Semanticdb Search Configuration
  231. When another part of @semantic{} (or another Emacs package using
  232. @semantic{}) queries the SemanticDB library for a source code tag, the
  233. search need not be limited to tags defined within the current file.
  234. It can include tags defined elsewhere, such as @dfn{header files}
  235. referenced by the current file (e.g., via the C/C++ @code{#include}
  236. directive). While performing the search, the SemanticDB library may
  237. even automatically visit other files and parse them, if necessary.
  238. The variable @code{semanticdb-find-default-throttle} determines how
  239. aggressively SemanticDB searches for source code tags. @xref{Search
  240. Throttle}.
  241. The details of SemanticDB searches can vary from language to
  242. language. In C/C++ code, for example, SemanticDB distinguishes
  243. between @dfn{project header files} and @dfn{system header files},
  244. based on whether the @code{#include} directive uses the @code{""} or
  245. @code{<>} filename delimiter. SemanticDB looks for system header in
  246. the @dfn{system include path} (@pxref{Include paths}).
  247. @menu
  248. * Search Throttle:: Controlling how semanticdb searches occur.
  249. * Semanticdb Roots:: Specifying the root of different projects.
  250. * Include paths:: Specifying the directories to search.
  251. * Semanticdb search debugging commands::
  252. @end menu
  253. @node Search Throttle
  254. @subsubsection SemanticDB Search Throttle
  255. The SemanticDB @dfn{search throttle} determines how aggressive
  256. SemanticDB searches are. It is controlled by the variable
  257. @code{semanticdb-find-default-throttle}. The default value of this
  258. variable aims for maximum accuracy, at the expense of search time.
  259. Other parts of the @semantic{} package, particularly the different
  260. language parsers, may change the value of
  261. @code{semanticdb-find-default-throttle}. You can override its value,
  262. for a given major mode, like this:
  263. @example
  264. (setq-mode-local c-mode
  265. semanticdb-find-default-throttle
  266. '(project unloaded system recursive))
  267. @end example
  268. @defvar semanticdb-find-default-throttle
  269. The default throttle for @code{semanticdb-find} routines.
  270. The throttle controls how detailed the list of database
  271. tables is for a symbol lookup. The value is a list with
  272. the following keys:
  273. @table @code
  274. @item file
  275. The file the search is being performed from. This option is here for
  276. completeness only, and is assumed to always be on.
  277. @item local
  278. Tables from the same local directory are included. This includes
  279. files directly referenced by a file name which might be in a different
  280. directory.
  281. @item project
  282. Tables from the same local project are included If @code{project} is
  283. specified, then @code{local} is assumed.
  284. @item unloaded
  285. If a table is not in memory, load it. If it is not cached on disk
  286. either, get the source, parse it, and create the table.
  287. @item system
  288. Tables from system databases. These are specifically tables
  289. from system header files, or language equivalent.
  290. @item recursive
  291. For include based searches, includes tables referenced by included
  292. files.
  293. @item omniscience
  294. Included system databases which are omniscience, or somehow know
  295. everything. Omniscience databases are found in
  296. @code{semanticdb-project-system-databases}. The Emacs Lisp system
  297. @var{db} is an omniscience database.
  298. @end table
  299. @end defvar
  300. @node Semanticdb Roots
  301. @subsubsection SemanticDB project roots
  302. The @code{project} setting in the SemanticDB search throttle
  303. (@pxref{Search Throttle}) tells SemanticDB to search within the
  304. current single code project. For @semantic{}'s point of view,
  305. @dfn{projects} are determined by their top-level directories, or
  306. @dfn{project roots}; every subdirectory of a project root is
  307. considered part of the same project.
  308. If you use EDE for project management, it will set the project roots
  309. automatically. @xref{Top,,,ede,EDE manual}. You can also specify
  310. them yourself.
  311. @deffn Option semanticdb-project-roots
  312. The value of this variable is a list of directories (strings) that are
  313. project roots. All subdirectories of a project root are considered
  314. part of the same project. This variable can be overridden by
  315. @code{semanticdb-project-root-functions}.
  316. @end deffn
  317. @defvar semanticdb-project-root-functions
  318. The value of this variable is a list of functions to determine a given
  319. directory's project root. These functions are called, one at a time,
  320. with one argument (the directory name), and must return either
  321. @code{nil}, a string (the project root), or a list of strings
  322. (multiple project roots, for complex systems). The first
  323. non-@code{nil} return value, if any, is taken to be the project root,
  324. overriding @code{semanticdb-project-roots}.
  325. @end defvar
  326. @node Include paths
  327. @subsubsection Include Paths
  328. System include paths are standard locations to find source code tags,
  329. such as the @dfn{header files} in @file{/usr/include} and its
  330. subdirectories on Unix-like operating systems.
  331. You can add and remove system include paths using the following
  332. commands:
  333. @deffn Command semantic-add-system-include dir &optional mode
  334. Prompts for a directory, @var{dir}, and add it as a system include
  335. path for the current major mode. When called non-interactively, the
  336. major mode can be specified with the @var{mode} argument.
  337. @end deffn
  338. @deffn Command semantic-remove-system-include dir &optional mode
  339. Prompt for a directory, @var{dir}, and remove it from the system
  340. include path for the current major mode (or @var{mode}).
  341. @end deffn
  342. @deffn Command semantic-customize-system-include-path &optional mode
  343. Customize the system include path for the current major mode (or
  344. @var{mode}).
  345. @end deffn
  346. @defvar semanticdb-implied-include-tags
  347. Include tags implied for all files of a given mode. You can set this
  348. variable with @code{defvar-mode-local} for a particular mode so that
  349. any symbols that exist for all files for that mode are included.
  350. @end defvar
  351. @c @xref{Search Optimization}, for more information on include paths.
  352. @node Semanticdb search debugging commands
  353. @subsubsection Semanticdb search debugging commands
  354. You can use @kbd{M-x semanticdb-dump-all-table-summary} to see the
  355. list of databases that will be searched from a given buffer. You can
  356. follow up with @kbd{M-x semanticdb-find-test-translate-path} to then
  357. make sure specific tables from the path are discovered correctly.
  358. Alternately, you can get a list of include files @semantic{}
  359. encountered, but could not find on disk using @kbd{M-x
  360. semanticdb-find-adebug-lost-includes}.
  361. @deffn Command semanticdb-dump-all-table-summary
  362. Dump a list of all databases in Emacs memory.
  363. @end deffn
  364. @deffn Command semanticdb-find-test-translate-path &optional arg
  365. Call and output results of @dfn{semanticdb-find-translate-path}. In
  366. the displayed buffer, you can type @key{SPC} to expand items. With
  367. @var{arg} non-@code{nil}, specify a @var{brutish} translation.
  368. @end deffn
  369. @deffn Command semanticdb-find-adebug-lost-includes
  370. Translate the current path, then display the lost includes.
  371. Examines the variable @code{semanticdb-find-lost-includes}.
  372. @end deffn
  373. Lastly, you can test an explicit search term using this command:
  374. @deffn Command semantic-adebug-searchdb regex
  375. Search the semanticdb for @var{regex} for the current buffer.
  376. Display the results as a debug list.
  377. @end deffn
  378. @node Changing Backends
  379. @subsection Changing Backends
  380. If you want to use some other form of backend, you can use this
  381. variable to choose which back end class to use for your general tag
  382. storage.
  383. The default is to save databases in flat files. Alternatively, you
  384. could write a new database backend that stores tags into a database,
  385. or other storage system.
  386. @defvar semanticdb-new-database-class
  387. The default type of database created for new files. This can be
  388. changed on a per file basis, so that some directories are saved using
  389. one mechanism, and some directories via a different mechanism.
  390. @end defvar
  391. @node Create System Databases
  392. @subsection Create System Databases
  393. If your supported language stores the system libraries in readily
  394. available parsable source code, you can pre-generate database files
  395. for them once, which will be used over and over for tools such as
  396. summary-mode, or the analyzer.
  397. @deffn Command semanticdb-create-ebrowse-database dir
  398. Create an Ebrowse database for directory @var{dir}. The database file
  399. is stored in ~/.semanticdb, or whichever directory is specified by
  400. @code{semanticdb-default-system-save-directory}.
  401. @end deffn
  402. @node Idle Scheduler
  403. @section Idle Scheduler
  404. @cindex Idle Scheduler
  405. The @dfn{Semantic Idle Scheduler} is a part of @semantic{} that
  406. performs various operations while Emacs is waiting for user input
  407. (idle time). Its primary job is to perform buffer parsing during idle
  408. time. You can also use the Idle Scheduler to display function
  409. prototypes (@pxref{Idle Summary Mode}) or symbol completions
  410. (@pxref{Idle Completions Mode}).
  411. @deffn Command global-semantic-idle-scheduler-mode &optional arg
  412. This command toggles Semantic Idle Scheduler mode in every
  413. @semantic{}-enabled buffer. This minor mode ensures that the buffer
  414. is automatically reparsed whenever Emacs is idle. If there is
  415. additional idle time, it runs jobs scheduled by other parts of
  416. @semantic{}, such as Semantic Idle Summary mode (@pxref{Idle Summary
  417. Mode}) and Semantic Idle Completions mode (@pxref{Idle Completions
  418. Mode}).
  419. @end deffn
  420. @deffn Option semantic-idle-scheduler-idle-time
  421. The value of this variable is the amount of idle time, in seconds,
  422. before the Semantic idle scheduler activates. The default is 1.
  423. @end deffn
  424. @deffn Option semantic-idle-scheduler-verbose-flag
  425. If this variable is non-@code{nil}, the idle scheduler prints verbose
  426. messages while running, which are useful for debugging.
  427. @end deffn
  428. @menu
  429. * Reparsing Options:: Reparsing the current buffer in idle time.
  430. * Idle Working Options:: Options for extra work done at idle time.
  431. * Debugging Idle Time Issues:: How to produce good bug reports.
  432. * Idle Summary Mode:: Display prototype of symbol under cursor.
  433. * Idle Completions Mode:: Smart completion pop-up help.
  434. @end menu
  435. @node Reparsing Options
  436. @subsection Reparsing Options
  437. When activated during idle time, the Semantic idle scheduler
  438. automatically reparses all buffers that need it. Any arriving user
  439. input cancels this, returning Emacs to its normal editing behavior.
  440. @deffn Option semantic-idle-scheduler-max-buffer-size
  441. Maximum size in bytes of buffers automatically reparsed. If this
  442. value is less than or equal to @var{0}, buffers are automatically
  443. reparsed regardless of their size.
  444. @end deffn
  445. @deffn Option semantic-idle-scheduler-no-working-message
  446. If non-@code{nil}, disable display of working messages while reparsing.
  447. @end deffn
  448. @deffn Option semantic-idle-scheduler-working-in-modeline-flag
  449. If non-@code{nil}, show working messages in the mode line. Normally,
  450. re-parsing shows messages in the minibuffer; this moves the parse
  451. message to the modeline instead.
  452. @end deffn
  453. @defvar semantic-before-idle-scheduler-reparse-hook
  454. This normal hook is run just before the idle scheduler begins
  455. reparsing. If any hook function throws an error, the value of this
  456. variable is reset to @code{nil}. This hook is not protected from
  457. lexical errors.
  458. @end defvar
  459. @defvar semantic-after-idle-scheduler-reparse-hook
  460. This normal hook is run after the idle scheduler finishes reparsing.
  461. If any hook throws an error, this variable is reset to @code{nil}.
  462. This hook is not protected from lexical errors.
  463. @end defvar
  464. @node Idle Working Options
  465. @subsection Idle Working Options
  466. In addition to reparsing buffers, the Semantic idle scheduler performs
  467. additional operations, including the following:
  468. @itemize
  469. @item
  470. Creating the include path caches required for symbol lookup.
  471. @item
  472. Create data type caches.
  473. @item
  474. Saving SemanticDB caches to disk.
  475. @item
  476. Speculatively parsing the files in the same directory as the current
  477. buffer.
  478. @end itemize
  479. Because this extra work is quite time-consuming, it is only carried
  480. out after a longer idle delay. The following features control how the
  481. idle work is performed.
  482. @deffn Option semantic-idle-scheduler-work-idle-time
  483. The value of this variable is the amount of idle time, in seconds,
  484. before commencing idle work. The default is 60.
  485. @end deffn
  486. @deffn Option semantic-idle-work-parse-neighboring-files-flag
  487. If the value of this variable is non-@code{nil}, the Semantic idle
  488. scheduler uses idle work time to parse files in the same directory as
  489. the current buffer. This improves the accuracy of tag searches and
  490. saves time when visiting those files later, at the cost of doing a lot
  491. of parsing. The default is @code{t}.
  492. @end deffn
  493. @node Debugging Idle Time Issues
  494. @subsection Debugging Idle Time Issues
  495. If you see an error signaled during idle time, it could be an
  496. indication of a more serious issue elsewhere. It is not enough to
  497. enable @code{debug-on-error}, because the idle scheduler inhibits the
  498. debugger. Instead, use the following commands to debug the error:
  499. @deffn Command semantic-debug-idle-function
  500. Run the Semantic idle function with debugging turned on.
  501. @end deffn
  502. @deffn Command semantic-debug-idle-work-function
  503. Run the Semantic idle work function with debugging turned on.
  504. @end deffn
  505. @node Idle Summary Mode
  506. @subsection Idle Summary Mode
  507. Semantic Idle Summary mode is a minor mode that displays a short
  508. summary of the symbol at point, such as its function prototype, in the
  509. echo area. Its functionality is similar to what ElDoc mode provides
  510. for Emacs Lisp (@pxref{Lisp Doc,,,emacs,Emacs manual}).
  511. @deffn global-semantic-idle-summary-mode &optional arg
  512. This command toggles Semantic Idle Summary mode in all
  513. @semantic{}-enabled buffers. You can also toggle it via the
  514. @samp{Show Tag Summaries} menu item in the @samp{Development} menu.
  515. @end deffn
  516. When Semantic Idle Summary mode is active, a summary of the tag at
  517. point is displayed in the echo area. This display takes place during
  518. the idle time, as given by @code{semantic-idle-scheduler-idle-time}
  519. (@pxref{Idle Scheduler}).
  520. You can override the method for getting the current tag to display by
  521. setting @code{idle-summary-current-symbol-info}.
  522. @deffn Option semantic-idle-summary-function
  523. The value of this variable should be a function to call to display tag
  524. information during idle time. See the variable
  525. @code{semantic-format-tag-functions} for a list of useful functions.
  526. @end deffn
  527. @defvar semantic-idle-summary-out-of-context-faces
  528. The value of this variable is a list of font-lock faces indicating
  529. useless summary contexts. These are generally faces used to highlight
  530. comments or strings. Semantic Idle Summary mode does not display its
  531. usual summary if the text at point has one of these faces.
  532. @end defvar
  533. @node Idle Completions Mode
  534. @subsection Idle Completions Mode
  535. Semantic Idle Completions mode is a minor mode for performing
  536. @dfn{code completions} during idle time. The completions are
  537. displayed inline, with keybindings that allow you to cycle through
  538. different alternatives.
  539. Semantic Idle Completions mode performs completion based on the
  540. Semantic Analyzer (@pxref{Analyzer}).
  541. @deffn global-semantic-idle-completions-mode &optional arg
  542. This command toggles Semantic Idle Completions mode in every
  543. @semantic{}-enabled buffer. You can also toggle it via the @samp{Show
  544. Tag Completions} menu item in the @samp{Development} menu.
  545. @end deffn
  546. If the tag at point has at least one completion, Semantic Idle
  547. Completions mode displays that completion inline---i.e., as part of
  548. the buffer text (you can change the display method by customizing
  549. @code{semantic-complete-inline-analyzer-idle-displayor-class}, as
  550. described below). The completed part is highlighted, to indicate that
  551. it is not yet properly inserted into the buffer. The echo area shows
  552. the completion, and whether there are other possible completions, like
  553. this:
  554. @example
  555. besselj [1 of 6 matches]
  556. @end example
  557. @noindent
  558. While the completion is being displayed, the following keybindings
  559. take effect:
  560. @table @kbd
  561. @item @key{RET}
  562. @itemx C-m
  563. Accept the current completion (@code{semantic-complete-inline-done}),
  564. placing it in the buffer and moving point to the end of the completed
  565. tag.
  566. @item M-n
  567. Select the next possible completion
  568. (@code{semantic-complete-inline-down}). The new completion is shown
  569. inline, replacing the old completion.
  570. @item M-p
  571. Select the previous possible completion
  572. (@code{semantic-complete-inline-up}).
  573. @item @key{TAB}
  574. @item C-i
  575. Accept as much of the completion as possible. If no additional
  576. completion can be accepted without ambiguity, select the next possible
  577. completion (@code{semantic-complete-inline-TAB}).
  578. @item C-g
  579. Quit without completing (@code{semantic-complete-inline-quit}).
  580. @end table
  581. @noindent
  582. You can also exit inline completion by issuing any other Emacs
  583. command. The completion text then disappears from the buffer.
  584. @deffn Command semantic-complete-analyze-inline-idle
  585. This is the command for performing inline code completion. It is
  586. called by Semantic Idle Completions mode during idle time, but you can
  587. also call it yourself. It returns immediately, leaving the buffer in
  588. a state for inline completion.
  589. @end deffn
  590. @deffn Option semantic-complete-inline-analyzer-idle-displayor-class
  591. The value of this variable determines how
  592. @code{semantic-complete-analyze-inline-idle} shows its completions.
  593. Possible values include:
  594. @table @code
  595. @item semantic-displayor-ghost
  596. Display completions ``inline'' with the buffer text, as described
  597. above. This is the default value.
  598. @item semantic-displayor-tooltip
  599. Display completions in a tooltip.
  600. @item semantic-displayor-traditional
  601. Display completions in a separate window.
  602. @end table
  603. @end deffn
  604. @node Analyzer
  605. @section Analyzer
  606. @cindex Analyzer
  607. The Semantic Analyzer is a library for performing context analysis on
  608. source code. It provides user commands for displaying, completing,
  609. and navigating through source code.
  610. @menu
  611. * Smart Completion:: Performing code completion.
  612. * Smart Summary:: Displaying help on a symbol.
  613. * Smart Jump:: Jumping to the definition of a tag.
  614. * Analyzer Debug:: Debugging problems with the analyzer.
  615. @end menu
  616. @node Smart Completion
  617. @subsection Smart Completion
  618. The Semantic Analyzer can be used to perform code completion in a
  619. manner that takes the local context into account. (In addition to the
  620. user commands in this section, Semantic Idle Completions mode also
  621. uses the Semantic Analyzer. @xref{Idle Completions Mode}.)
  622. @deffn Command semantic-analyze-possible-completions context
  623. This is the most basic command for Semantic Analyzer-based completion.
  624. Called interactively, it displays a list of the possible completions
  625. for the symbol at point.
  626. When called from a Lisp program,
  627. @code{semantic-analyze-possible-completions} does not display a
  628. completions list. The argument @var{context} should be either a
  629. buffer position, or a context object. The return value is a list of
  630. @semantic{} tag objects that complete the symbol for @var{context},
  631. based on the following criteria:
  632. @itemize
  633. @item Elements currently in scope.
  634. @item Constants currently in scope.
  635. @item Elements matching the context's @code{:prefix}.
  636. @item Type of the completion matching the type of the context.
  637. @end itemize
  638. Most of the other commands documented in this section call
  639. @code{semantic-analyze-possible-completions} internally.
  640. @end deffn
  641. @deffn Command semantic-complete-analyze-inline
  642. This command is bound to @kbd{C-c , @key{SPC}} when Semantic mode is
  643. enabled (@pxref{Semantic mode user commands}). It displays a list of
  644. possible completions for the symbol at point, and activates a special
  645. set of keybindings for choosing a completion.
  646. You can type @key{RET} to accept the current completion, @kbd{M-n} and
  647. @kbd{M-p} to cycle through the possible completions, @key{TAB} to
  648. complete as far as possible and then cycle through completions, and
  649. either @kbd{C-g} or any other key to abort the completion.
  650. This command is similar to the completion performed by Semantic Idle
  651. Completions mode. The main difference is that it is called
  652. explicitly, whereas Semantic Idle Completions mode completes during
  653. idle time (@pxref{Idle Completions Mode}).
  654. @end deffn
  655. @deffn Option semantic-complete-inline-analyzer-idle-displayor-class
  656. The value of this variable determines how
  657. @code{semantic-complete-analyze-inline} shows its completions.
  658. Possible values include:
  659. @table @code
  660. @item semantic-displayor-traditional
  661. Display completions in a separate window. This is the default value.
  662. @item semantic-displayor-ghost
  663. Display completions ``inline'' with the buffer text, similar to the
  664. default behavior of Semantic Idle Completions mode (@pxref{Idle
  665. Completions Mode}).
  666. @item semantic-displayor-tooltip
  667. Display completions in a tooltip.
  668. @end table
  669. @end deffn
  670. In addition to @code{semantic-complete-analyze-inline}, you can use
  671. the simpler command @code{semantic-ia-complete-symbol point}. This
  672. behaves like the usual @kbd{M-@key{TAB}} (@code{complete-symbol})
  673. command (@pxref{Symbol Completion,,,emacs,Emacs manual}), except it
  674. uses the Semantic Analyzer.
  675. @deffn Command semantic-ia-complete-symbol point
  676. Complete the current symbol at @var{point}.
  677. @end deffn
  678. @node Smart Summary
  679. @subsection Smart Summary
  680. You can use the following commands to obtain information about the
  681. code at point:
  682. @deffn Command semantic-ia-show-summary pos
  683. Display a summary for the symbol at @var{pos}. Called interactively,
  684. @var{pos} defaults to point.
  685. @end deffn
  686. @deffn Command semantic-ia-show-doc pos
  687. Display the code-level documentation for the symbol at @var{pos}.
  688. Called interactively, @var{pos} defaults to point.
  689. @end deffn
  690. @deffn Command semantic-ia-describe-class typename
  691. Prompt for the name of a data type, @var{typename}, and display its
  692. components. For instance, if the type in question is a class, this
  693. displays the methods and member variables.
  694. @end deffn
  695. You can also use Semantic Idle Summary mode to show information about
  696. the current symbol in the echo area during idle time. @xref{Idle
  697. Summary Mode}.
  698. @node Smart Jump
  699. @subsection Smart Jump
  700. The Semantic Analyzer can be used to jump directly to the definition
  701. for a code symbol.
  702. @deffn Command semantic-ia-fast-jump pos
  703. Jump to the definition for the symbol at @var{pos}. Called
  704. interactively, @var{pos} defaults to point.
  705. @end deffn
  706. @defun semantic-ia-fast-mouse-jump event
  707. Jump to the definition for the symbol at the position of the mouse
  708. event @var{event}. This command is meant to be bound to a mouse
  709. command, like this:
  710. @example
  711. (global-set-key '[(S-mouse-1)] semantic-ia-fast-mouse-jump)
  712. @end example
  713. @end defun
  714. These commands are often more accurate than the @code{xref-find-definitions}
  715. command (@pxref{Looking Up Identifiers,,,emacs,Emacs manual}), because
  716. the Semantic Analyzer is context-sensitive.
  717. You can also use @kbd{C-c , j} (@code{semantic-complete-jump-local})
  718. and @kbd{C-c , J} (@code{semantic-complete-jump}) to navigate tags.
  719. @xref{Semantic mode user commands}. Those commands do not make use of
  720. the Semantic Analyzer.
  721. @node Analyzer Debug
  722. @subsection Debugging the Semantic Analyzer
  723. If the Semantic Analyzer does not analyze your code properly, you can
  724. take steps to identify and solve the problem. This section was
  725. written with C/C++ in mind, but should be relevant for any typed
  726. language.
  727. @subsubsection Step 1: Check the context
  728. To check the current context, type @kbd{M-x
  729. semantic-analyze-current-context}.
  730. @deffn Command semantic-analyze-current-context pos
  731. Analyze the context at @var{pos}. This function is used by most of
  732. the other Semantic Analyzer commands to obtain the context of the code
  733. at a given buffer position. The return value is an EIEIO object
  734. describing the context at @var{pos} (@pxref{Top,,,eieio,EIEIO
  735. manual}).
  736. When called interactively, this displays a @file{*Semantic Context
  737. Analysis*} buffer containing a summary of the context at point.
  738. @end deffn
  739. @noindent
  740. The Prefix section of the @file{*Semantic Context Analysis*} buffer
  741. lists the tags based on the text at point. If it shows only a simple
  742. string, the Semantic was unable to identify what the data type was.
  743. The first item in the list of the prefix is the first lookup failure
  744. in the chain, and that is the item to focus debugging effort on. For
  745. example:
  746. @example
  747. Context Type: #<semantic-analyze-context context>
  748. Bounds: (182 . 185)
  749. Prefix: Foo* bar
  750. int bbb (const char* y)
  751. Prefix Types: class Foo @{@}
  752. --------
  753. -> Local Vars: int argc
  754. char** argv
  755. @end example
  756. In this example you can see that the prefix has two fully found tags.
  757. In the following example, the symbol ``bbb'' is incomplete, and could
  758. not be found:
  759. @example
  760. Context Type: #<semantic-analyze-context context>
  761. Bounds: (182 . 184)
  762. Prefix: Foo* bar
  763. "bb"
  764. Prefix Classes: 'function
  765. 'variable
  766. Prefix Types: class Foo @{@}
  767. --------
  768. -> Local Vars: int argc
  769. char** argv
  770. @end example
  771. @subsubsection Step 2 : Check your include path
  772. Once you know the missing symbol, check your include path. The header
  773. or include file containing the needed definition may not be in the
  774. list of headers @semantic{} is searching through. To get a basic
  775. list, you can use @kbd{M-x semanticdb-find-test-translate-path}.
  776. @xref{Semanticdb search debugging commands}.
  777. If items should be loaded but aren't, or if you see some tables that
  778. have no tags in them, then you you may have an incorrectly-set search
  779. throttle (@pxref{Search Throttle}). For example,
  780. @example
  781. *#<semanticdb-table main.cpp (4 tags DIRTY)>
  782. *#<semanticdb-table foo.hh (0 tags DIRTY)>
  783. @end example
  784. Here, @semantic{} found @file{foo.hh}, but there are 0 tags. This may
  785. be because you had set the throttle to avoid reading and parsing files
  786. that Emacs has not visited. To fix this, visit the file and let
  787. @semantic{} parse it.
  788. For C++, check also that the @samp{#include} statements for your
  789. project-level files use quotes, not angle brackets; angle brackets are
  790. for system files.
  791. @subsubsection Step 3: Check the local scope
  792. If your data type is somehow abbreviated based on scope, such as from
  793. a @code{using} statement, you should make sure that the symbol you
  794. want is in the local scope. Examine the scope with @kbd{M-x
  795. semantic-calculate-scope}. The scope structure is displayed in ADEBUG
  796. mode, so use @kbd{SPC} to expand different elements and looking for
  797. your symbol.
  798. If your symbol should be in the scope, but you cannot find it, then
  799. you may have found a language support bug in the local-variable
  800. parser, or using statement parser.
  801. Calling @kbd{M-x bovinate} should force a reset on the scope in case
  802. there is merely some bad state.
  803. @example
  804. ] Name: Cache
  805. ] Class: #'semantic-scope-cache
  806. ] :table #<semanticdb-table testsubclass.cpp (13 tags DIRTY)>
  807. ] tag createMoose : class moose
  808. ] scopetypes 'nil
  809. ] parents #<TAG LIST: 1 entries>
  810. ] scope #<TAG LIST: 22 entries>
  811. ] fullscope #<TAG LIST: 23 entries>
  812. ] localvar #<TAG LIST: 6 entries>
  813. @end example
  814. In the above sample output, the @code{tag} slot specifies where within
  815. you source this scope is relevant. @code{Parents} should contain any
  816. in scope parents, such as the class a method belongs to.
  817. @code{Localvar} should contain your local variables. @code{Scope}
  818. should contain datatypes in scope due to a @code{using} statement or
  819. the like.
  820. @subsubsection Step 4: Check the typecache
  821. For complex typed languages like C++, @semantic{} creates a typecache,
  822. or an optimized search table with all the various data types in it.
  823. Elements in the typecache do not obey local scope. It only contains
  824. fully qualified names. You can examine the typecache with
  825. @kbd{M-x semanticdb-typecache-dump}.
  826. If your data types are not in the typecache, there may be some parsing
  827. error or other bug. Calling @kbd{M-x bovinate} should force a reset on
  828. the typecache in case there is merely some bad state.
  829. @example
  830. ]#<semanticdb-typecache /home/zappo/cedet/semantic/tests/testsubclass.cpp>
  831. ] Name: /home/zappo/cedet/semantic/tests/testsubclass.cpp
  832. ] Class: #'semanticdb-typecache
  833. ] filestream 'nil
  834. ] includestream #<TAG LIST: 84 entries>
  835. ] stream 'nil
  836. ] dependants 'nil
  837. @end example
  838. In the above example, the output of @kbd{M-x semanticdb-typecache-dump}
  839. was expanded one level. The @code{filestream} slot should contain
  840. datatypes in the current file. The @code{includestream} should
  841. contain all the datatypes in all included header files.
  842. The @code{dependants} slot will specify other files that depend on
  843. this one.
  844. @subsubsection Step 5: Check the parser
  845. Go to the location where your unfound tag should be. You can call
  846. @kbd{M-x bovinate}, and see a dump of the raw tag structure. To see a
  847. navigable tree, use @kbd{M-x semantic-adebug-bovinate} instead. You
  848. can then look to make sure your tag has been properly parsed.
  849. If it has not, then you may have found a parser bug. To get a feel
  850. how @semantic{} treats your file, type @kbd{M-x
  851. global-semantic-show-unmatched-syntax-mode}. This causes any syntax
  852. it cannot parse to be underlined in red.
  853. If your type is not parsable, it could be for a couple of reasons:
  854. @enumerate
  855. @item
  856. If there is a MACRO keyword used in the definition of the type, you
  857. may need to update the @code{semantic-lex-c-preprocessor-symbol-map}
  858. to account for it.
  859. @item
  860. Or perhaps the parser needs to be fixed.
  861. @end enumerate
  862. @node Speedbar
  863. @section Speedbar
  864. @cindex speedbar
  865. You can integrate @semantic{} with the Speedbar.
  866. @xref{Speedbar,,,emacs,Emacs manual}. To do this, add the following
  867. line to your init file:
  868. @example
  869. (add-hook 'speedbar-load-hook (lambda () (require 'semantic/sb)))
  870. @end example
  871. @noindent
  872. Or, alternatively:
  873. @example
  874. (require 'semantic/sb)
  875. @end example
  876. Once installed, the Speedbar will use @semantic{} to find and display
  877. tags. Tags from @semantic{} are displayed with more details than
  878. ordinary Speedbar tags, such as function arguments and return type.
  879. In addition, you can use the Speedbar to show the output of the
  880. Semantic Analyzer (@pxref{Analyzer}). To do this, go to the
  881. @samp{Display} menu item on the Speedbar menu and select
  882. @samp{Analyze}; or type @kbd{M-x semantic-speedbar-analysis}.
  883. @deffn Command semantic-speedbar-analysis
  884. Start the Speedbar in Semantic Analysis mode.
  885. @end deffn
  886. In Semantic Analysis mode, the Speedbar displays information about the
  887. local context, such as the current function, local arguments and
  888. variables, and details on the prefix (the current symbol). Each entry
  889. has an @samp{<i>} button; clicking on this shows a summary of what
  890. @semantic{} knows about that variable or type. The Speedbar also
  891. displays a list of possible completions at point.
  892. @node SymRef
  893. @section Symbol References
  894. @cindex symref
  895. @semantic{} can interface with external @dfn{symbol reference tools},
  896. such as GNU Global and GNU Idutils. These tools provide information
  897. about where different tags or symbols appear.
  898. By default, @semantic{} tries to look for the best external symbol
  899. reference tool that can be used. The supported tools are GNU Global,
  900. GNU Idutils, CScope, and Grep (the fallback method). For best
  901. results, use GNU Global. However, @semantic{} does not manage your
  902. GNU Global tables for you; you must manage them yourself.
  903. @defvar semantic-symref-tool
  904. The value of this variable is a symbol that determines the external
  905. symbol reference tool to use. The default value, @code{detect}, says
  906. to look for the best available tool. Other possible values are
  907. @code{global}, @code{idutils}, @code{cscope}, and @code{grep}. Note
  908. that @code{grep} is much slower than the others.
  909. @end defvar
  910. The commands to display symbol references are @kbd{C-c , g}
  911. (@code{semantic-symref-symbol} and @kbd{C-c , G}
  912. (@code{semantic-symref}). These keybindings are available whenever
  913. Semantic mode is enabled (@pxref{Semantic mode user commands}).
  914. @deffn Command semantic-symref-symbol sym
  915. This command (normally bound to @kbd{C-c , g}) prompts for a symbol
  916. name, and uses an external reference tool to find references to that
  917. tag.
  918. @end deffn
  919. @deffn Command semantic-symref
  920. This command (normally bound to @kbd{C-c , G}) uses an external
  921. reference tool to find references to the current tag.
  922. @end deffn
  923. Both @code{semantic-symref-symbol} and @code{semantic-symref} display
  924. a list of symbol references in a separate buffer. The entries are
  925. organized by file, and by function name. Typing @key{RET} on the
  926. @samp{[+]} next to each function name ``expands'' that entry, listing
  927. all references to the target symbol occurring within that function.
  928. Typing @kbd{RET} on a reference line jumps to that reference.
  929. @node MRU Bookmarks
  930. @section MRU Bookmarks mode
  931. @cindex semantic-mru-bookmark-mode
  932. Semantic MRU Bookmarks mode is a minor mode that keeps track of the
  933. tags you have edited, allowing you to quickly return to them later
  934. (MRU stands for ``Most Recently Used'').
  935. @deffn Command global-semantic-mru-bookmark-mode &optional arg
  936. Toggle Semantic MRU Bookmarks mode globally. The minor mode can be
  937. turned on only if the current buffer was set up for parsing. With
  938. argument @var{arg}, turn the minor mode if @var{arg} is positive, and
  939. off otherwise.
  940. @end deffn
  941. Semantic MRU Bookmarks mode takes note of each tag you edit.
  942. Afterwards, you can type @kbd{C-x B}
  943. (@code{semantic-mrub-switch-tags}) to return to a tag. This command
  944. prompts for a tag name, completing with the names of edited tags; at
  945. the prompt, you can use @kbd{M-p} and @kbd{M-n} to cycle through tags
  946. in order of last modification time.
  947. @node Sticky Func Mode
  948. @section Sticky Function mode
  949. Semantic Sticky Function minor mode displays a header line that shows
  950. the declaration line of the function or tag on the topmost line in the
  951. text area. This allows you to keep that declaration line in view at
  952. all times, even if it is scrolls off the ``top'' of the screen.
  953. In addition, clicking @kbd{mouse-1} on the header line opens a context
  954. menu that contains menu items for copying, killing, or narrowing to
  955. that tag.
  956. @deffn Command global-semantic-stickyfunc-mode &optional arg
  957. Toggle Semantic Sticky Function mode in all Semantic-enabled buffers.
  958. With an optional argument @var{arg}, enable if @var{arg} is positive,
  959. and disable otherwise.
  960. @end deffn
  961. @defvar semantic-stickyfunc-sticky-classes
  962. The value of this variable is a list of tag classes that Semantic
  963. Sticky Function mode makes ``sticky''. The default is
  964. @code{'(function type)}, meaning function declarations and type
  965. declarations. Other possible tag classes are @code{variable},
  966. @code{include}, and @code{package}.
  967. @end defvar
  968. @node Highlight Func Mode
  969. @section Highlight Func Mode
  970. @cindex semantic-highlight-func-mode
  971. Semantic Highlight Function minor mode highlights the declaration line
  972. of the current function or tag (that is to say, the first line that
  973. describes the rest of the construct).
  974. In addition, clicking @kbd{mouse-3} on the highlighted declaration
  975. line opens a context menu that contains menu items for copying,
  976. killing, or narrowing to that tag.
  977. The tag classes highlighted by Semantic Highlight Function mode are
  978. the same ones given by @code{semantic-stickyfunc-sticky-classes}.
  979. @xref{Sticky Func Mode}.
  980. @defun global-semantic-highlight-func-mode &optional arg
  981. Toggle Semantic Highlight Function mode in all Semantic-enabled
  982. buffers. With an optional argument @var{arg}, enable if @var{arg} is
  983. positive, and disable otherwise.
  984. @end defun
  985. @deffn Face semantic-highlight-func-current-tag-face
  986. This face is used to highlight declaration lines in Semantic Highlight
  987. Func mode.
  988. @end deffn
  989. @node Tag Decoration Mode
  990. @section Tag Decoration Mode
  991. @cindex semantic-decoration-mode
  992. Semantic Tag Decoration mode ``decorates'' each tag based on certain
  993. arbitrary features of that tag. Decorations are specified using the
  994. variable @code{semantic-decoration-styles}.
  995. @deffn Command global-semantic-decoration-mode &optional arg
  996. Toggle Semantic Tag Decoration mode in all Semantic-enabled buffers.
  997. With an optional argument @var{arg}, enable if @var{arg} is positive,
  998. and disable otherwise.
  999. @end deffn
  1000. @defvar semantic-decoration-styles
  1001. The value of this variable is a list of decoration styles for Semantic
  1002. Tag Decoration mode. Each element in this list should have the form
  1003. @code{(@var{name} . @var{flag})}, where @var{name} is a style name (a
  1004. symbol) and @var{flag} is non-@code{nil} if the style is enabled.
  1005. The following styles are available:
  1006. @table @code
  1007. @item semantic-tag-boundary
  1008. Place an overline in front of each long tag (excluding prototypes).
  1009. @item semantic-decoration-on-private-members
  1010. Highlight class members that are designated as private.
  1011. @item semantic-decoration-on-protected-members
  1012. Highlight class members that are designated as protected.
  1013. @item semantic-decoration-on-includes
  1014. Highlight class members that are includes. Clicking on the
  1015. highlighted include statements opens a context menu for configuring
  1016. @semantic{} includes.
  1017. @end table
  1018. @end defvar
  1019. To enable or disable specific decorations, use this function:
  1020. @deffn Command semantic-toggle-decoration-style name &optional arg
  1021. Prompt for a decoration style, @var{name}, and turn it on or off.
  1022. With prefix argument @var{arg}, turn on if positive, otherwise off.
  1023. Return non-@code{nil} if the decoration style is enabled.
  1024. @end deffn
  1025. @deffn Face semantic-tag-boundary-face
  1026. Face for long tags in the @code{semantic-tag-boundary} decoration
  1027. style.
  1028. @end deffn
  1029. @deffn Face semantic-decoration-on-private-members-face
  1030. Face for privately-scoped tags in the
  1031. @code{semantic-decoration-on-private-members} decoration style.
  1032. @end deffn
  1033. @deffn Face semantic-decoration-on-protected-members-face
  1034. Face for protected tags in the
  1035. @code{semantic-decoration-on-protected-members} decoration style.
  1036. @end deffn
  1037. @deffn Face semantic-decoration-on-includes
  1038. Face for includes that are not in some other state, in the
  1039. @code{semantic-decoration-on-includes} decoration style.
  1040. @end deffn
  1041. @deffn Face semantic-decoration-on-unknown-includes
  1042. Face for includes that cannot be found, in the
  1043. @code{semantic-decoration-on-includes} decoration style.
  1044. @end deffn
  1045. @deffn Face semantic-decoration-on-unparsed-includes
  1046. Face for includes that have not yet been parsed, in the
  1047. @code{semantic-decoration-on-includes} decoration style.
  1048. @end deffn
  1049. @subsection Creating New Decoration Modes
  1050. You can create new types of decorations using the following function:
  1051. @defun define-semantic-decoration-style name doc &rest flags
  1052. Define a new decoration style with @var{name}.
  1053. @var{doc} is a documentation string describing the decoration style @var{name}.
  1054. It is appended to auto-generated doc strings.
  1055. An optional list of @var{flags} can also be specified. Flags are:
  1056. @code{:enabled} <value> - specify the default enabled value for @var{name}.
  1057. This defines two new overload functions respectively called @code{NAME-p}
  1058. and @code{NAME-highlight}, for which you must provide a default
  1059. implementation in respectively the functions @code{NAME-p-default} and
  1060. @code{NAME-highlight-default}. Those functions are passed a tag. @code{NAME-p}
  1061. must return non-@code{nil} to indicate that the tag should be decorated by
  1062. @code{NAME-highlight}.
  1063. To put primary decorations on a tag @code{NAME-highlight}, use
  1064. functions like @dfn{semantic-set-tag-face},
  1065. @dfn{semantic-set-tag-intangible}, etc., found in the
  1066. semantic-decorate library.
  1067. To add other kind of decorations on a tag, @code{NAME-highlight} must use
  1068. @dfn{semantic-decorate-tag}, and other functions of the semantic
  1069. decoration @var{api} found in this library.
  1070. @end defun