Merge pull request #2618 from codebrainz/os-info-improvements
[geany-mirror.git] / HACKING
blob4801b2b49005c57df2323c6efa20a05e3577f7b8
1 =============
2 Hacking Geany
3 =============
4 .. contents::
6 General
7 =======
9 About this file
10 ---------------
11 This file contains information for anyone wanting to work on the Geany
12 codebase. You should be aware of the open source licenses used - see
13 the README file or the documentation. It is reStructuredText; the
14 source file is HACKING.
16 You can generate this file by:
18 * Passing the *--enable-html-docs* option to ``configure``.
19 * Running ``make`` from the doc/ subdirectory.
21 Writing plugins
22 ---------------
23 * src/plugindata.h contains the plugin API data types.
24 * See plugins/demoplugin.c for a very basic example plugin.
25 * src/plugins.c loads and unloads plugins (you shouldn't need to read
26   this really).
27 * The API documentation contains a few basic guidelines and hints to
28   write plugins.
30 You should generate and read the plugin API documentation, see below.
32 Plugin API documentation
33 ^^^^^^^^^^^^^^^^^^^^^^^^
34 You can generate documentation for the plugin API using the doxygen
35 tool:
37 * Pass the *--enable-api-docs* option to ``configure``.
38 * Run ``make`` from the doc/ subdirectory.
40 The documentation will be output to doc/reference/index.html.
41 Alternatively you can view the API documentation online at
42 https://www.geany.org/manual/reference/.
44 Pull requests
45 -------------
46 Making pull requests on Github is the preferred way of contributing for geany.
48 .. note:: For helping you to get started: https://help.github.com/articles/fork-a-repo
50 See `Rules to contribute`_ for more information.
52 Patches
53 -------
54 We are happy to receive patches, but the preferred way is to make a pull
55 request on our Github repository. If you don't want to make a pull request,
56 you can send your patches on the devel mailing list, but the rules are the same:
57 see `Rules to contribute`_ for more information.
59 In general it's best to provide git-formatted patches made from the
60 current Git (see `Committing`_)::
62     $ git commit -a
63     $ git format-patch HEAD^
65 We also accept patches against other releases, but it's more work for us.
67 If you're not using Git, although you're strongly suggested to use it,
68 you can use the diff command::
70     $ diff -u originalpath modifiedpath > new-feature.patch
72 However, such a patch won't contain the authoring information nor the
73 patch's description.
75 .. note::
76     Please make sure patches follow the style of existing code - In
77     particular, use tabs for indentation. See `Coding`_.
79 Rules to contribute
80 -------------------
82 Keep in mind this is best to check with us by email on mailing list
83 whether a new feature is appropriate and whether someone is already
84 working on similar code.
86 Please, make sure contributions you make follow these rules:
88 * changes should be made in a dedicated branch for pull requests.
89 * only one feature should be in each pull request (or patch).
90 * pull requests (or patches) should not contain changes unrelated to the feature,
91   and commits should be sensible units of change.
92 * the submitter should squash together corrections that are part of
93   the development process, especially correcting your own mistakes.
94 * Please make sure your modifications follow the style of existing code:
95   see `Coding`_ for more information.
97 See `Committing`_ for more information.
99 Windows tools
100 -------------
101 * Git: http://git-scm.com/ and http://msysgit.github.io/
102 * diff, grep, etc: http://mingw.org/ or http://unxutils.sourceforge.net/
104 See also the 'Building on Windows' document on the website.
106 File organization
107 -----------------
108 callbacks.c is just for Glade callbacks.
109 Avoid adding code to geany.h if it will fit better elsewhere.
110 See the top of each ``src/*.c`` file for a brief description of what
111 it's for.
113 Plugin API code
114 ---------------
115 Please be aware that anything with a doc-comment (a comment with an
116 extra asterix: ``/**``) is something in the plugin API. Things like
117 enums and structs can usually still be appended to, ensuring that all
118 the existing elements stay in place - this will keep the ABI stable.
120 .. warning::
122     Some structs like GeanyCallback cannot be appended to without
123     breaking the ABI because they are used to declare structs by
124     plugins, not just for accessing struct members through a pointer.
125     Normally structs should never be allocated by plugins.
127 Keeping the plugin ABI stable
128 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129 Before the 1.0 release series, the ABI can change when necessary, and
130 even the API can change. An ABI change just means that all plugins will
131 not load and they must be rebuilt. An API change means that some plugins
132 might not build correctly.
134 If you're reordering or changing existing elements of structs that are
135 used as part of the plugin API, you must increment GEANY_ABI_VERSION
136 in plugindata.h. This is usually not needed if you're just appending
137 fields to structs. The GEANY_API_VERSION value should be incremented
138 for any changes to the plugin API, including appending elements.
140 If you're in any doubt when making changes to plugin API code, just ask us.
142 Plugin API/ABI design
143 ^^^^^^^^^^^^^^^^^^^^^
144 You should not make plugins rely on the size of a struct. This means:
146 * Don't let plugins allocate any structs (stack or heap).
147 * Don't let plugins index any arrays of structs.
148 * Don't add any array fields to structs in case we want to change the
149   array size later.
151 Doc-comments
152 ^^^^^^^^^^^^
153 * The @file tag can go in the source .c file, but use the .h header name so
154   it appears normally in the generated documentation. See ui_utils.c for an
155   example.
156 * Function doc-comments should always go in the source file, not the
157   header, so they can be updated if/when the implementation changes.
159 Glade
160 -----
161 Add user-interface widgets to the Glade 3 file ``data/geany.glade``.
162 Callbacks for the user-interface should go in ``src/callbacks.c``.
164 Use Glade 3.8.5. The 3.8 series still supports GTK+ 2, and earlier
165 point releases did not preserve the order of XML elements, leading to
166 unmanageable diffs.
168 GTK versions & API documentation
169 --------------------------------
170 Geany requires GTK >= 2.24 or GTK 3 (with the --enable-gtk3 configure option)
171 and GLib >= 2.32. API symbols from newer GTK/GLib versions should be 
172 avoided or made optional to keep the source code building on older systems.
174 It is recommended to use the 2.24 API documentation of the GTK
175 libs (including GLib, GDK and Pango) has the advantages
176 that you don't get confused by any newer API additions and you
177 don't have to take care about whether you can use them or not.
179 You might want to pass the ``-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32`` C
180 preprocessor flag to get warnings about newer symbols from the GLib.
182 On the contrary, you might also want to get deprecation warnings for symbols
183 deprecated in newer versions, typically when preparing a dependency bump or
184 trying to improve forward compatibility.
185 To do so, use the ``-UGLIB_VERSION_MIN_REQUIRED`` flag for GLib deprecations,
186 and ``-UGDK_DISABLE_DEPRECATION_WARNINGS`` for GTK and GDK ones.
187 To change the lower deprecation bound for GLib (and then get warnings about
188 symbols deprecated more recently) instead of simply removing it entirely, use
189 ``-UGLIB_VERSION_MIN_REQUIRED -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_X_YY``.
191 See `Compiler options & warnings`_ for how to set such flags.
193 Coding
194 ------
195 * Don't write long functions with a lot of variables and/or scopes - break
196   them down into smaller static functions where possible. This makes code
197   much easier to read and maintain.
198 * Use GLib types and functions - gint not int, g_free() not free().
199 * Your code should build against GLib 2.32 and GTK 2.24. At least for the
200   moment, we want to keep the minimum requirement for GTK at 2.24 (of
201   course, you can use the GTK_CHECK_VERSION macro to protect code using
202   later versions).
203 * Variables should be declared (and initialized) as close as practical
204   to their first use. This reduces the chances of intervening code being
205   inserted between declaration and use, where the variable may be
206   uninitialized.
207 * Variables should be defined within the smallest scope that is practical,
208   for example inside a conditional branch which uses them or in the
209   initialization part of a for loop.
210 * Local variables that will not be modified should be marked as ``const``
211   to indicate intention. This allows the compiler to give a warning if
212   part of the code accidentally tries to change the value.
213 * Pointer parameters should be marked ``const`` if the value they point
214   to will not be mutated within the function.
215 * Don't let variable names shadow outer variables - use gcc's -Wshadow
216   option.
217 * Use the strictest possible data type where practical.
218   Avoid using untyped pointers (e.g. gpointer) where practical.
219   For an enumeration, use the actual enum type rather than just a
220   ``gint``, use a ``gchar`` for individual (ASCII/UTF-8) string
221   characters rather than ``gint``, and use a ``guint`` for integers
222   which cannot be negative rather than ``gint``.
223 * Prefer loops to calling ``some_type_foreach()`` with a ``user_data``
224   argument. (Note: Some containers don't support external iteration,
225   e.g. for tree structures, so ``*_foreach`` is fine for those).
226 * Do not use G_LIKELY or G_UNLIKELY (except in critical loops). These
227   add noise to the code with little real benefit.
229 Compiler options & warnings
230 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
231 Use ``CFLAGS='-Wfoo' ./configure`` or ``CFLAGS='-Wfoo' ./autogen.sh``
232 to set warning options (as well as anything else e.g. -g -O2).
234 * Enable warnings - for gcc use '-Wall -Wextra' (and optionally
235   -Wno-unused-parameter to avoid unused parameter warnings in Glade
236   callbacks). Alternatively you can use the Glib macro G_GNUC_UNUSED
237   to suppress warnings on single parameters, e.g.
238   ``void examplefunction(G_GNUC_UNUSED gchar *foo)``. Also see
239   https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html.
240 * You should try to write ISO C99 code for portability, so always
241   use C ``/* */`` comments and function_name(void) instead of
242   function_name(). This is for compatibility with various Unix-like
243   compilers. You should use -std=c99 to help check this.
245 .. tip::
246     Remember for gcc you need to enable optimization to get certain
247     warnings like uninitialized variables, but for debugging it's
248     better to have no optimization on.
250 Style
251 ^^^^^
252 * We use a tab width of 4 and indent completely with tabs not spaces.
253   Note the documentation files use (4) spaces instead, so you may want
254   to use the 'Detect from file' indent pref.
255 * Do not add whitespace at the end of lines, this adds to commit noise.
256   When editing with Geany set preference files->Strip trailing spaces
257   and tabs.
258 * Use the multiline comment ``/* */`` to comment small blocks of code,
259   functions descriptions or longer explanations of code, etc. The more
260   comments are in your code the better. (See also
261   ``scripts/fix-cxx-comments.pl`` in Git).
262 * Lines should not be longer than about 100 characters and after 100
263   characters the lines should be wrapped and indented once more to
264   show that the line is continued.
265 * We don't put spaces between function names and the opening brace for
266   argument lists.
267 * Variable declarations come first after an opening brace, then one
268   newline to separate declarations and code.
269 * 2-operand operators should have a space each side.
270 * Function bodies should have 2 blank newlines after them.
271 * Align braces together on separate lines.
272 * Don't put assignments in 'if/while/etc' expressions except for loops,
273   for example ``for (int i = 0; i < some_limit; i++)``.
274 * if statements without brace bodies should have the code on a separate
275   line, then a blank line afterwards.
276 * Use braces after if/while statements if the body uses another
277   if/while statement.
278 * Try to fit in with the existing code style.
280 .. note::
281     A few of the above can be done with the Git
282     ``scripts/fix-alignment.pl``, but it is quite dumb and it's much better
283     to write it correctly in the first place.
284     ``scripts/rstrip-whitespace.py`` just removes trailing whitespace.
287 .. below tabs should be used, but spaces are required for reST.
289 Example::
291     struct Bar;
293     typedef struct Foo  /* struct names normally are the same as typedef names */
294     {
295         gint    foo;    /* names are somewhat aligned visually */
296         gint    bar;    /* fields don't share the same line */
297         SomeLongTypeName baz; /* alignment is not strict */
298         gchar   *ptr;   /* pointer symbol must go next to variable name, not type */
299         Bar     public; /**< only plugin API fields have a doc-comment */
300     }
301     Foo;
304     gint some_func(void);
306     gint some_other_func(void);
309     /* optional function comment explains something important */
310     gint function_long_name(gchar arg1, <too many args to fit on this line>,
311             gchar argN)
312     {
313         /* variable declarations always go before code in each scope */
314         /* variable names should NOT be aligned at all */
315         gint foo, bar;  /* variables can go on the same line */
316         gint baz;       /* but often don't */
317         gchar *ptr;     /* pointer symbol must go next to variable name, not type */
318         gchar *another; /* pointers should normally go on separate lines */
320         /* Some long comment block
321          * taking several different
322          * lines to explain */
323         if (foo)
324         {
325             /* variables only used in one scope should normally be declared there */
326             gint dir = -1;
328             bar = foo;
329             if ((bar & (guint)dir) != 7)
330                 some_code(arg1, <too many args to fit on this line>,
331                     argN - 1, argN);
333             some_func();
334         }
335     }
338     /** Explains using doc-comments for plugin API functions.
339      * First line should be short and use the third person tense - 'explains',
340      * not 'explain'.
341      *
342      * @return Some number.
343      * @since 1.22. */
344     gint another_function(void)
345     {
346         ...
348 Header Includes
349 ---------------
351 In order to make including various headers in Geany more convenient, each
352 file should include what it uses. If there is a file named ``foo.c``, and a
353 file named ``foo.h``, it should be possible to include ``foo.h`` on its own
354 without depending on stuff in ``foo.c`` that is included for the first time
355 before ``foo.h``.
357 Private Headers
358 ^^^^^^^^^^^^^^^
360 If there is some data that needs to be shared between various parts of the
361 core code, put them in a "private header", that is, if the public header is
362 called ``foo.h``, then make a ``fooprivate.h`` header that contains the
363 non-public functions, types, globals, etc that are needed. Other core source
364 files can then just include the ``foo.h`` and/or ``fooprivate.h`` depending
365 what they need, without exposing that stuff to plugins.
367 Order of Includes
368 ^^^^^^^^^^^^^^^^^
370 Inside a source file the includes section should be ordered like this:
372 1. Always include the ``config.h`` file at the start of every source file,
373    for example::
375     #ifdef HAVE_CONFIG_H
376     # include "config.h"
377     #endif
379    This allows the Autotools and other build systems use the ``./configure``
380    time settings. If you don't do this, there's likely to be a number of
381    macros that you'll have to define in the build system or custom headers.
383    Warning: Never include ``config.h`` in headers, and especially in "public"
384    headers that plugins might include.
386 2. Then include the header that has the same name as the source file (if
387    applicable). For example, for a source file named ``foo.c``, include
388    the ``foo.h`` below the ``config.h`` include. If there is a
389    ``fooprivate.h``, ``foo.c`` will most likely want to include that too,
390    put it in with includes in #3.
392 3. At this point, it should be safe to include all the headers that declare
393    whatever is needed. If everything generally "includes what it uses" and
394    all files included contain the appropriate multiple-declaration guards
395    then the order of includes is fairly arbitrary. Prefer to use English
396    alphabetic order if possible.
398 4. By now it doesn't really matter about the order, nothing below here is
399    "our problem". Semi-arbitrarily, you should use an include order like this:
401     1. Standard C headers
402     2. Non-standard system headers (eg. ``windows.h`` or ``unistd.h``)
403     3. GLib/GTK+ or related headers
405 5. Everything else that should not influence 1-4.
407 Including in Header Files
408 ^^^^^^^^^^^^^^^^^^^^^^^^^
410 Headers should also include what they use. All of the types should defined in
411 order to allow the header to be included stand-alone. For example, if a
412 header uses a ``GtkWidget*``, it should ``#include <gtk/gtk.h>``. Or, if a
413 headers uses a ``GPtrArray*``, it should ``#include <glib.h>`` to ensure that
414 all of the types are declared, whether by pointers/opaquely or fully, as
415 required. Since all headers will use a ``G_BEGIN_DECLS`` and ``G_END_DECLS``
416 guard for C++, the bare minimum for a header is to include ``glib.h`` or
417 ``<gtk/gtk.h>`` or ``gtkcompat.h`` or some other header that makes those
418 macros available.
421 Committing
422 ----------
424 * Commit one thing at a time, do small commits.  Commits should be
425   meaningful and not too big when possible; multiple small commits are
426   good if there is no good reason to group them.
427 * Use meaningful name and email in the Author and Committer fields.
428   This helps knowing who did what and allows to contact the author if
429   there is a good reason to do so (unlikely, but can happen).
430 * When working on a new feature, create a new branch for it.  When
431   merging it, use the --no-ff option to make sure a merge commit will
432   be created to better track what happened.  However, if the feature
433   only took one commit you might merge it fast-forward since there is
434   not history to keep together.
436 Commit messages
437 ^^^^^^^^^^^^^^^
438 Follow the standard Git formatting:
440 * No line should use more than about 80 characters (around 72 is best).
441 * The first line is the commit's summary and is followed by an empty
442   line.  This summary should be one line and one line only, thus less
443   than 80 characters.  This summary should not include any punctuation
444   unless really needed.  See it as the subject of an email: keep it
445   concise and as precise as you can, but not tool long.
446 * Following lines are optional detailed commit information, with
447   paragraphs separated by blank lines.  This part should be as long as
448   needed to describe the commit in depth, should use proper
449   punctuation and should include any useful information, like the
450   motivation for the patch and/or any valuable details the diff itself
451   don't provide or don't make clear.  Make it as complete as you think
452   it makes sense, but don't include an information that is better
453   explained by the commit's diff.
455   It is OK to use ASCII formatting like bullet list using "*" or "-",
456   etc. if useful, but emphasis (bold, italic, underline) should be
457   avoided.
459 Example::
461     Ask the user if spawn fails in utils_open_browser()
463     Ask the user to configure a valid browser command if spawning it
464     fails rather than falling back to some arbitrary hardcoded defaults.
466     This avoid spawning an unexpected browser when the configured one is
467     wrong, and gives the user a chance to correctly fix the preference.
470 Testing
471 -------
472 * Run with ``-v`` to print any debug messages.
473 * You can use a second instance (``geany -i``).
474 * To check first-run behaviour, use an alternate config directory by
475   passing ``-c some_dir`` (but make sure the directory is clean first).
476 * For debugging tips, see `GDB`_.
478 Bugs to watch out for
479 ---------------------
480 * Forgetting to check *doc->is_valid* when looping through
481   *documents_array* - instead use *foreach_document()*.
482 * Inserting fields into structs in the plugin API instead of appending.
483 * Not breaking the plugin ABI when necessary.
484 * Using an idle callback that doesn't check main_status.quitting.
485 * Forgetting CRLF line endings on Windows.
486 * Not handling Tabs & Spaces indent mode.
488 Libraries
489 ---------
490 We try to use an unmodified version of Scintilla - any new lexers or
491 other changes should be passed on to the maintainers at
492 http://scintilla.org. We normally update to a new Scintilla release
493 shortly after one is made. See also scintilla/README.
495 Tagmanager was originally taken from Anjuta 1.2.2, and parts of it
496 (notably c.c) have been merged from later versions of Anjuta and
497 CTags. The independent Tagmanager library itself ceased development
498 before Geany was started. It's source code parsing is mostly taken from
499 Exuberant CTags (see http://ctags.sf.net). If appropriate it's good to
500 pass language parser changes back to the CTags project.
503 Notes
504 =====
505 Some of these notes below are brief (or maybe incomplete) - please
506 contact the geany-devel mailing list for more information.
508 Using pre-defined autotools values
509 ----------------------------------
510 When you are use macros supplied by the autotools like GEANY_PREFIX,
511 GEANY_LIBDIR, GEANY_DATADIR and GEANY_LOCALEDIR be aware that these
512 might not be static strings when Geany is configured with
513 --enable-binreloc. Then these macros will be replaced by function calls
514 (in src/prefix.h). So, don't use anything like
515 printf("Prefix: " GEANY_PREFIX); but instead use
516 printf("Prefix: %s", GEANY_PREFIX);
518 Adding a source file foo.[hc] in src/ or plugins/
519 -------------------------------------------------
520 * Add foo.c, foo.h to SRCS in path/Makefile.am.
521 * Add path/foo.c to po/POTFILES.in (for string translation).
523 Adding a filetype
524 -----------------
525 You can add a filetype without syntax highlighting or tag parsing, but
526 check to see if those features have been written in upstream projects
527 first (scintilla or ctags).
529 **Custom:**
531 If you want to reuse an existing lexer and/or tag parser, making a
532 custom filetype is probably easier - it doesn't require any
533 changes to the source code. Follow instructions in the manual:
534 http://geany.org/manual/index.html#custom-filetypes. Don't forget to
535 update the ``[Groups]`` section in ``filetype_extensions.conf``.
537 .. warning::
538   You should use the newer `[build-menu]` section for default build
539   commands - the older `[build_settings]` may not work correctly for
540   custom filetypes.
542 **Built-in:**
544 * Add GEANY_FILETYPES_FOO to filetypes.h.
545 * Initialize GEANY_FILETYPES_FOO in init_builtin_filetypes() of
546   filetypes.c.
547 * Update data/filetype_extensions.conf.
549 The remaining notes relate mostly to built-in filetypes.
551 filetypes.* configuration file
552 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
553 All languages need a data/filetypes.foo configuration file. See
554 the "Filetype definition files" section in the manual and/or
555 data/filetypes.c for an example.
557 Programming languages should have:
559 * [keywords] if the lexer supports it.
560 * [settings] mostly for comment settings.
561 * [build-menu] (or [build_settings]) for commands to run.
563 For languages with a Scintilla lexer, there should be a [styling] section,
564 to correspond to the styles used in highlighting_styles_FOO[] in
565 highlightingmappings.h - see below.
567 Don't forget to add the newly created filetype file to data/Makefile.am.
569 Syntax highlighting
570 ^^^^^^^^^^^^^^^^^^^
571 It may be possible to use an existing Scintilla lexer in the scintilla/
572 subdirectory - if not, you will need to find (or write) one,
573 LexFoo.cxx. Try the official Scintilla project first.
575 .. warning::
576     We won't accept adding a lexer that conflicts with one in
577     Scintilla. All new lexers should be submitted back to the Scintilla
578     project to save duplication of work.
580 When adding a lexer, update:
582 * scintilla/Makefile.am
583 * scintilla/src/Catalogue.cxx - add a LINK_LEXER command *manually*
585 For syntax highlighting, you will need to edit highlighting.c and
586 highlightingmappings.h and add the following things:
588 1. In highlightingmappings.h:
590    a. define ``highlighting_lexer_FOO`` to the Scintilla lexer ID for
591       this filtype, e.g. ``SCLEX_CPP``.
592    b. define the ``highlighting_styles_FOO`` array that maps Scintilla
593       style states to style names in the configuration file.
594    c. define ``highlighting_keywords_FOO`` to ``EMPTY_KEYWORDS`` if the
595       filtype has no keywords, or as an ``HLKeyword`` array mapping
596       the Scintilla keyword IDs to names in the configuration file.
597    d. define ``highlighting_properties_FOO`` to ``EMPTY_PROPERTIES``, or
598       as an array of ``HLProperty`` if the filetype requires some lexer
599       properties to be set.  However, note that properties should
600       normally be set in the ``[lexer_properties]`` section of the
601       configuration file instead.
603    You may look at other filtype's definitions for some examples
604    (Ada, CSS or Diff being good examples).
606 2. In highlighting.c:
608    a. Add ``init_styleset_case(FOO);`` in ``highlighting_init_styles()``.
609    b. Add ``styleset_case(FOO);`` in ``highlighting_set_styles()``.
611 3. Write data/filetypes.foo configuration file [styling] section. See
612    the manual and see data/filetypes.d for a named style example.
614 .. note::
615     Please try to make your styles fit in with the other filetypes'
616     default colors, and to use named styles where possible (e.g.
617     "commentline=comment"). Filetypes that share a lexer should have
618     the same colors. If not using named styles, leave the background color
619     empty to match the default color.
621 Error message parsing
622 ^^^^^^^^^^^^^^^^^^^^^
623 New-style error message parsing is done with an extended GNU-style regex
624 stored in the filetypes.foo file - see the [build_settings] information
625 in the manual for details.
627 Old-style error message parsing is done in
628 msgwin_parse_compiler_error_line() of msgwindow.c - see the ParseData
629 typedef for more information.
631 Other features
632 ^^^^^^^^^^^^^^
633 If the lexer has comment styles, you should add them in
634 highlighting_is_comment_style(). You should also update
635 highlighting_is_string_style() for string/character styles. For now,
636 this prevents calltips and autocompletion when typing in a comment
637 (but it can still be forced by the user).
639 For brace indentation, update lexer_has_braces() in editor.c;
640 indentation after ':' is done from on_new_line_added().
642 If the Scintilla lexer supports user type keyword highlighting (e.g.
643 SCLEX_CPP), update document_update_tags() in document.c.
645 Adding a TagManager parser
646 ^^^^^^^^^^^^^^^^^^^^^^^^^^
647 This assumes the filetype for Geany already exists.
649 First write or find a CTags compatible parser, foo.c. Check this fork:
650 https://github.com/universal-ctags/ctags
652 There may be some unmerged language patches for CTags at:
653 http://sf.net/projects/ctags - see the tracker.
655 (You can also try the Anjuta project's anjuta-tags codebase.)
657 .. note::
658     From Geany 1.22 GLib's GRegex engine is used instead of POSIX
659     regex, unlike CTags. It should be close enough to POSIX to work
660     OK.
661     We no longer support regex parsers with the "b" regex flag
662     option set and Geany will print debug warnings if it's used.
663     CTags supports it but doesn't currently (2011) include any
664     parsers that use it. It should be easy to convert to extended
665     regex syntax anyway.
667 Method
668 ``````
669 * Add foo.c to SRCS in Makefile.am.
670 * Add Foo to parsers.h
671 * Add TM_PARSER_FOO to src/tagmanager/tm_parser.h.  The list here must follow
672   exactly the order in parsers.h.
674 In src/tagmanager/tm_parser.c:
675 Add a map_FOO TMParserMapEntry mapping each kind's letter from foo.c's
676 FooKinds to the appropriate TMTagType, and add the corresponding
677 MAP_ENTRY(FOO) to parser_map.
678 (You may want to make the symbols.c change before doing this).
680 In src/tagmanager/tm_parser.c:
681 Update tm_parser_context_separator() and tm_parser_has_full_context() to
682 handle the new parser if applicable, by adding a TM_PARSER_FOO case entry.
684 In filetypes.c, init_builtin_filetypes():
685 Set the 2nd argument of the FT_INIT() macro for this filetype to FOO.
687 In symbols.c:
688 Unless your parser uses C-like tag type kinds, update
689 add_top_level_items() for foo, calling tag_list_add_groups(). See
690 get_tag_type_iter() for which tv_iters fields to use.
692 Tests
693 `````
694 The tag parser tests checks if the proper tags are emitted
695 for a given source. Tests for tag parsers consist of two files: the
696 source to parse, and the expected output. Tests are run using ``make
697 check``.
699 The source to parse should be in the file ``tests/ctags/mytest.ext``,
700 where ``mytest`` is the name you choose for your test, and ``ext`` is an
701 extension recognized by Geany as the language the test file is for.
702 This file should contain a snippet of the language to test for.
703 It can be either long or short, depending on what it tests.
705 The expected output should be in the file ``tests/ctags/mytest.ext.tags``
706 (which is the same name as the source, but with ``.tags`` appended), and
707 should be in the format generated by ``geany -g``. This file contains
708 the tag information expected to be generated from the corresponding
709 source file.
711 When you have these two files, you have to list your new test along the
712 other ones in the ``test_source`` variable in ``tests/ctags/Makefile.am``.
713 Please keep this list sorted alphabetically.
715 Upgrading Scintilla
716 -------------------
718 To upgrade the local Scintilla copy, use the ``scripts/update-scintilla.sh``
719 script.
721 To use it, you need to first obtain a copy of the Scintilla sources you want
722 to update to.  This will generally mean checking out a release tag from the
723 Scintilla Mercurial repository, or extracting a tarball.
725 Then, just run the script from Geany's to source directory passing the path
726 to the Scintilla source directory as first argument, and follow the
727 instructions, if any::
729     ./scripts/update-scintilla.sh /path/to/scintilla/
734 Stop on warnings
735 ^^^^^^^^^^^^^^^^
736 When a GLib or GTK warning is printed, often you want to get a
737 backtrace to find out what code caused them. You can do that with the
738 ``--g-fatal-warnings`` argument, which will abort Geany on the first
739 warning it receives.
741 But for ordinary testing, you don't always want your editor to abort
742 just because of a warning - use::
744     (gdb) b handler_log if level <= G_LOG_LEVEL_WARNING
747 Running with batch commands
748 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
749 Use::
751     $ gdb src/geany -x gdb-commands
753 Where ``gdb-commands`` is a file with the following lines::
755     set pagination off
756     b handler_log if level <= G_LOG_LEVEL_WARNING
757     r -v
760 Loading a plugin
761 ^^^^^^^^^^^^^^^^
762 This is useful so you can load plugins without installing them first.
763 Alternatively you can use a symlink in ~/.config/geany/plugins or
764 $prefix/lib/geany (where $prefix is /usr/local by default).
766 The gdb session below was run from the toplevel Geany source directory.
767 Start normally with e.g. "gdb src/geany".
768 Type 'r' to run.
769 Press Ctrl-C from the gdb window to interrupt program execution.
771 Example::
773     Program received signal SIGINT, Interrupt.
774     0x00d16402 in __kernel_vsyscall ()
775     (gdb) call plugin_new("./plugins/.libs/demoplugin.so")
776     ** INFO: Loaded:   ./plugins/.libs/demoplugin.so (Demo)
777     $1 = (Plugin *) 0x905a890
778     (gdb) c
779     Continuing.
781     Program received signal SIGINT, Interrupt.
782     0x00d16402 in __kernel_vsyscall ()
783     (gdb) call plugin_free(0x905a890)
784     ** INFO: Unloaded: ./plugins/.libs/demoplugin.so
785     (gdb) c
786     Continuing.
788 Building Plugins
789 ^^^^^^^^^^^^^^^^
791 The geany-plugins autotools script automatically detects the
792 installed system Geany and builds the plugins against that.
794 Plugins will build with either GTK2 or GTK3, whichever the detected
795 Geany was built with.
797 To use plugins with a development version of Geany built with
798 a different prefix, the plugins will need to be compiled against
799 that version if the ABI has changed.
801 To do this you need to specify both --prefix and --with-geany-libdir
802 to the plugin configure.  Normally the plugin prefix is the
803 same as the Geany prefix to keep plugins with the version of Geany
804 that they are compiled against, and with-geany-libdir is the Geany
805 prefix/lib.
807 Whilst it is possible for the plugin prefix to be different to
808 the prefix of the libdir (which is why there are two settings),
809 it is probably better to keep the version of Geany and its plugins
810 together.