javascript: Fix more handling of class-related unterminated statements
[geany-mirror.git] / HACKING
blob36cad32cba0688dab4984345c2307fa83a3e0ab4
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 http://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 prefered 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 used 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://code.google.com/p/msysgit/
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.16 and GLib >= 2.20. API symbols from newer
171 GTK/GLib versions should be avoided or made optional to keep the source
172 code building on older systems.
174 The official GTK 2.16 API documentation may not be available online
175 anymore, so we put it on http://www.geany.org/manual/gtk/. There
176 is also a tarball with all available files for download and use with
177 devhelp.
179 Using the 2.16 API documentation of the GTK libs (including GLib, GDK
180 and Pango) has the advantages that you don't get confused by any
181 newer API additions and you don't have to take care about whether
182 you can use them or not.
184 Coding
185 ------
186 * Don't write long functions with a lot of variables and/or scopes - break
187   them down into smaller static functions where possible. This makes code
188   much easier to read and maintain.
189 * Use GLib types and functions - gint not int, g_free() not free().
190 * Your code should build against GLib 2.20 and GTK 2.16. At least for the
191   moment, we want to keep the minimum requirement for GTK at 2.16 (of
192   course, you can use the GTK_CHECK_VERSION macro to protect code using
193   later versions).
194 * Variables should be declared before statements. You can use
195   gcc's -Wdeclaration-after-statement to warn about this.
196 * Don't let variable names shadow outer variables - use gcc's -Wshadow
197   option.
198 * Do not use G_LIKELY or G_UNLIKELY (except in critical loops). These
199   add noise to the code with little real benefit.
201 Compiler options & warnings
202 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
203 Use ``CFLAGS='-Wfoo' ./configure`` or ``CFLAGS='-Wfoo' ./autogen.sh``
204 to set warning options (as well as anything else e.g. -g -O2).
206 * Enable warnings - for gcc use '-Wall -W' (and optionally
207   -Wno-unused-parameter to avoid unused parameter warnings in Glade
208   callbacks).
209 * You should try to write ISO C99 code for portability, so always
210   use C ``/* */`` comments and function_name(void) instead of
211   function_name(). This is for compatibility with various Unix-like
212   compilers. You should use -std=c99 to help check this.
214 .. tip::
215     Remember for gcc you need to enable optimization to get certain
216     warnings like uninitialized variables, but for debugging it's
217     better to have no optimization on.
219 Style
220 ^^^^^
221 * We use a tab width of 4 and indent completely with tabs not spaces.
222   Note the documentation files use (4) spaces instead, so you may want
223   to use the 'Detect from file' indent pref.
224 * Do not add whitespace at the end of lines, this adds to commit noise.
225   When editing with Geany set preference files->Strip trailing spaces
226   and tabs.
227 * Use the multiline comment ``/* */`` to comment small blocks of code,
228   functions descriptions or longer explanations of code, etc. The more
229   comments are in your code the better. (See also
230   ``scripts/fix-cxx-comments.pl`` in Git).
231 * Lines should not be longer than about 100 characters and after 100
232   characters the lines should be wrapped and indented once more to
233   show that the line is continued.
234 * We don't put spaces between function names and the opening brace for
235   argument lists.
236 * Variable declarations come first after an opening brace, then one
237   newline to separate declarations and code.
238 * 2-operand operators should have a space each side.
239 * Function bodies should have 2 blank newlines after them.
240 * Align braces together on separate lines.
241 * Don't put assignments in 'if/while/etc' expressions except for loops,
242   for example ``for (int i = 0; i < some_limit; i++)``.
243 * if statements without brace bodies should have the code on a separate
244   line, then a blank line afterwards.
245 * Use braces after if/while statements if the body uses another
246   if/while statement.
247 * Try to fit in with the existing code style.
249 .. note::
250     A few of the above can be done with the Git
251     ``scripts/fix-alignment.pl``, but it is quite dumb and it's much better
252     to write it correctly in the first place.
253     ``scripts/rstrip-whitespace.py`` just removes trailing whitespace.
256 .. below tabs should be used, but spaces are required for reST.
258 Example::
260     struct Bar;
262     typedef struct Foo  /* struct names normally are the same as typedef names */
263     {
264         gint    foo;    /* names are somewhat aligned visually */
265         gint    bar;    /* fields don't share the same line */
266         SomeLongTypeName baz; /* alignment is not strict */
267         gchar   *ptr;   /* pointer symbol must go next to variable name, not type */
268         Bar     public; /**< only plugin API fields have a doc-comment */
269     }
270     Foo;
273     gint some_func(void);
275     gint some_other_func(void);
278     /* optional function comment explains something important */
279     gint function_long_name(gchar arg1, <too many args to fit on this line>,
280             gchar argN)
281     {
282         /* variable declarations always go before code in each scope */
283         /* variable names should NOT be aligned at all */
284         gint foo, bar;  /* variables can go on the same line */
285         gint baz;       /* but often don't */
286         gchar *ptr;     /* pointer symbol must go next to variable name, not type */
287         gchar *another; /* pointers should normally go on separate lines */
289         /* Some long comment block
290          * taking several different
291          * lines to explain */
292         if (foo)
293         {
294             /* variables only used in one scope should normally be declared there */
295             gint dir = -1;
297             bar = foo;
298             if ((bar & (guint)dir) != 7)
299                 some_code(arg1, <too many args to fit on this line>,
300                     argN - 1, argN);
302             some_func();
303         }
304     }
307     /** Explains using doc-comments for plugin API functions.
308      * First line should be short and use the third person tense - 'explains',
309      * not 'explain'.
310      *
311      * @return Some number.
312      * @since 1.22. */
313     gint another_function(void)
314     {
315         ...
317 Header Includes
318 ---------------
320 In order to make including various headers in Geany more convenient, each
321 file should include what it uses. If there is a file named ``foo.c``, and a
322 file named ``foo.h``, it should be possible to include ``foo.h`` on its own
323 without depending on stuff in ``foo.c`` that is included for the first time
324 before ``foo.h``.
326 Private Headers
327 ^^^^^^^^^^^^^^^
329 If there is some data that needs to be shared between various parts of the
330 core code, put them in a "private header", that is, if the public header is
331 called ``foo.h``, then make a ``fooprivate.h`` header that contains the
332 non-public functions, types, globals, etc that are needed. Other core source
333 files can then just include the ``foo.h`` and/or ``fooprivate.h`` depending
334 what they need, without exposing that stuff to plugins.
336 Order of Includes
337 ^^^^^^^^^^^^^^^^^
339 Inside a source file the includes section should be ordered like this:
341 1. Always include the ``config.h`` file at the start of every source file,
342    for example::
344     #ifdef HAVE_CONFIG_H
345     # include "config.h"
346     #endif
348    This allows the Autotools and other build systems use the ``./configure``
349    time settings. If you don't do this, there's likely to be a number of
350    macros that you'll have to define in the build system or custom headers.
352    Warning: Never include ``config.h`` in headers, and especially in "public"
353    headers that plugins might include.
355 2. Then include the header that has the same name as the source file (if
356    applicable). For example, for a source file named ``foo.c``, include
357    the ``foo.h`` below the ``config.h`` include. If there is a
358    ``fooprivate.h``, ``foo.c`` will most likely want to include that too,
359    put it in with includes in #3.
361 3. At this point, it should be safe to include all the headers that declare
362    whatever is needed. If everything generally "includes what it uses" and
363    all files included contain the appropriate multiple-declaration guards
364    then the order of includes is fairly arbitrary. Prefer to use English
365    alphabetic order if possible.
367 4. By now it doesn't really matter about the order, nothing below here is
368    "our problem". Semi-arbitrarily, you should use an include order like this:
370     1. Standard C headers
371     2. Non-standard system headers (eg. ``windows.h`` or ``unistd.h``)
372     3. GLib/GTK+ or related headers
374 5. Everything else that should not influence 1-4.
376 Including in Header Files
377 ^^^^^^^^^^^^^^^^^^^^^^^^^
379 Headers should also include what they use. All of the types should defined in
380 order to allow the header to be included stand-alone. For example, if a
381 header uses a ``GtkWidget*``, it should ``#include <gtk/gtk.h>``. Or, if a
382 headers uses a ``GPtrArray*``, it should ``#include <glib.h>`` to ensure that
383 all of the types are declared, whether by pointers/opaquely or fully, as
384 required. Since all headers will use a ``G_BEGIN_DECLS`` and ``G_END_DECLS``
385 guard for C++, the bare minimum for a header is to include ``glib.h`` or
386 ``<gtk/gtk.h>`` or ``gtkcompat.h`` or some other header that makes those
387 macros available.
390 Committing
391 ----------
393 * Commit one thing at a time, do small commits.  Commits should be
394   meaningful and not too big when possible; multiple small commits are
395   good if there is no good reason to group them.
396 * Use meaningful name and email in the Author and Committer fields.
397   This helps knowing who did what and allows to contact the author if
398   there is a good reason to do so (unlikely, but can happen).
399 * When working on a new feature, create a new branch for it.  When
400   merging it, use the --no-ff option to make sure a merge commit will
401   be created to better track what happened.  However, if the feature
402   only took one commit you might merge it fast-forward since there is
403   not history to keep together.
405 Commit messages
406 ^^^^^^^^^^^^^^^
407 Follow the standard Git formatting:
409 * No line should use more than about 80 characters (around 72 is best).
410 * The first line is the commit's summary and is followed by an empty
411   line.  This summary should be one line and one line only, thus less
412   than 80 characters.  This summary should not include any punctuation
413   unless really needed.  See it as the subject of an email: keep it
414   concise and as precise as you can, but not tool long.
415 * Following lines are optional detailed commit information, with
416   paragraphs separated by blank lines.  This part should be as long as
417   needed to describe the commit in depth, should use proper
418   punctuation and should include any useful information, like the
419   motivation for the patch and/or any valuable details the diff itself
420   don't provide or don't make clear.  Make it as complete as you think
421   it makes sense, but don't include an information that is better
422   explained by the commit's diff.
424   It is OK to use ASCII formatting like bullet list using "*" or "-",
425   etc. if useful, but emphasis (bold, italic, underline) should be
426   avoided.
428 Example::
430     Ask the user if spawn fails in utils_open_browser()
432     Ask the user to configure a valid browser command if spawning it
433     fails rather than falling back to some arbitrary hardcoded defaults.
435     This avoid spawning an unexpected browser when the configured one is
436     wrong, and gives the user a chance to correctly fix the preference.
439 Testing
440 -------
441 * Run with ``-v`` to print any debug messages.
442 * You can use a second instance (``geany -i``).
443 * To check first-run behaviour, use an alternate config directory by
444   passing ``-c some_dir`` (but make sure the directory is clean first).
445 * For debugging tips, see `GDB`_.
447 Bugs to watch out for
448 ---------------------
449 * Forgetting to check *doc->is_valid* when looping through
450   *documents_array* - instead use *foreach_document()*.
451 * Inserting fields into structs in the plugin API instead of appending.
452 * Not breaking the plugin ABI when necessary.
453 * Using an idle callback that doesn't check main_status.quitting.
454 * Forgetting to call vStringTerminate in CTags code.
455 * Forgetting CRLF line endings on Windows.
456 * Not handling Tabs & Spaces indent mode.
458 Libraries
459 ---------
460 We try to use an unmodified version of Scintilla - any new lexers or
461 other changes should be passed on to the maintainers at
462 http://scintilla.org. We normally update to a new Scintilla release
463 shortly after one is made. See also scintilla/README.
465 Tagmanager was originally taken from Anjuta 1.2.2, and parts of it
466 (notably c.c) have been merged from later versions of Anjuta and
467 CTags. The independent Tagmanager library itself ceased development
468 before Geany was started. It's source code parsing is mostly taken from
469 Exuberant CTags (see http://ctags.sf.net). If appropriate it's good to
470 pass language parser changes back to the CTags project.
473 Notes
474 =====
475 Some of these notes below are brief (or maybe incomplete) - please
476 contact the geany-devel mailing list for more information.
478 Using pre-defined autotools values
479 ----------------------------------
480 When you are use macros supplied by the autotools like GEANY_PREFIX,
481 GEANY_LIBDIR, GEANY_DATADIR and GEANY_LOCALEDIR be aware that these
482 might not be static strings when Geany is configured with
483 --enable-binreloc. Then these macros will be replaced by function calls
484 (in src/prefix.h). So, don't use anything like
485 printf("Prefix: " GEANY_PREFIX); but instead use
486 printf("Prefix: %s", GEANY_PREFIX);
488 Adding a source file foo.[hc] in src/ or plugins/
489 -------------------------------------------------
490 * Add foo.c, foo.h to SRCS in path/Makefile.am.
491 * Add foo.o to OBJS in path/makefile.win32.
492 * Add path/foo.c to geany_sources in wscript.
493 * Add path/foo.c to po/POTFILES.in (for string translation).
495 Adding a filetype
496 -----------------
497 You can add a filetype without syntax highlighting or tag parsing, but
498 check to see if those features have been written in upstream projects
499 first (scintilla or ctags).
501 **Custom:**
503 If you want to reuse an existing lexer and/or tag parser, making a
504 custom filetype is probably easier - it doesn't require any
505 changes to the source code. Follow instructions in the manual:
506 http://geany.org/manual/geany.html#custom-filetypes. Don't forget to
507 update the ``[Groups]`` section in ``filetype_extensions.conf``.
509 .. warning::
510   You should use the newer `[build-menu]` section for default build
511   commands - the older `[build_settings]` may not work correctly for
512   custom filetypes.
514 **Built-in:**
516 * Add GEANY_FILETYPES_FOO to filetypes.h.
517 * Initialize GEANY_FILETYPES_FOO in init_builtin_filetypes() of
518   filetypes.c.
519 * Update data/filetype_extensions.conf.
521 The remaining notes relate mostly to built-in filetypes.
523 filetypes.* configuration file
524 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
525 All languages need a data/filetypes.foo configuration file. See
526 the "Filetype definition files" section in the manual and/or
527 data/filetypes.c for an example.
529 Programming languages should have:
531 * [keywords] if the lexer supports it.
532 * [settings] mostly for comment settings.
533 * [build-menu] (or [build_settings]) for commands to run.
535 For languages with a Scintilla lexer, there should be a [styling] section,
536 to correspond to the styles used in highlighting_styles_FOO[] in
537 highlightingmappings.h - see below.
539 Don't forget to add the newly created filetype file to data/Makefile.am.
541 Syntax highlighting
542 ^^^^^^^^^^^^^^^^^^^
543 It may be possible to use an existing Scintilla lexer in the scintilla/
544 subdirectory - if not, you will need to find (or write) one,
545 LexFoo.cxx. Try the official Scintilla project first.
547 .. warning::
548     We won't accept adding a lexer that conflicts with one in
549     Scintilla. All new lexers should be submitted back to the Scintilla
550     project to save duplication of work.
552 When adding a lexer, update:
554 * scintilla/Makefile.am
555 * scintilla/makefile.win32
556 * wscript
557 * scintilla/src/Catalogue.cxx - add a LINK_LEXER command *manually*
559 For syntax highlighting, you will need to edit highlighting.c and
560 highlightingmappings.h and add the following things:
562 1. In highlightingmappings.h:
564    a. define ``highlighting_lexer_FOO`` to the Scintilla lexer ID for
565       this filtype, e.g. ``SCLEX_CPP``.
566    b. define the ``highlighting_styles_FOO`` array that maps Scintilla
567       style states to style names in the configuration file.
568    c. define ``highlighting_keywords_FOO`` to ``EMPTY_KEYWORDS`` if the
569       filtype has no keywords, or as an ``HLKeyword`` array mapping
570       the Scintilla keyword IDs to names in the configuration file.
571    d. define ``highlighting_properties_FOO`` to ``EMPTY_PROPERTIES``, or
572       as an array of ``HLProperty`` if the filetype requires some lexer
573       properties to be set.  However, note that properties should
574       normally be set in the ``[lexer_properties]`` section of the
575       configuration file instead.
577    You may look at other filtype's definitions for some examples
578    (Ada, CSS or Diff being good examples).
580 2. In highlighting.c:
582    a. Add ``init_styleset_case(FOO);`` in ``highlighting_init_styles()``.
583    b. Add ``styleset_case(FOO);`` in ``highlighting_set_styles()``.
585 3. Write data/filetypes.foo configuration file [styling] section. See
586    the manual and see data/filetypes.d for a named style example.
588 .. note::
589     Please try to make your styles fit in with the other filetypes'
590     default colors, and to use named styles where possible (e.g.
591     "commentline=comment"). Filetypes that share a lexer should have
592     the same colors. If not using named styles, leave the background color
593     empty to match the default color.
595 Error message parsing
596 ^^^^^^^^^^^^^^^^^^^^^
597 New-style error message parsing is done with an extended GNU-style regex
598 stored in the filetypes.foo file - see the [build_settings] information
599 in the manual for details.
601 Old-style error message parsing is done in
602 msgwin_parse_compiler_error_line() of msgwindow.c - see the ParseData
603 typedef for more information.
605 Other features
606 ^^^^^^^^^^^^^^
607 If the lexer has comment styles, you should add them in
608 highlighting_is_comment_style(). You should also update
609 highlighting_is_string_style() for string/character styles. For now,
610 this prevents calltips and autocompletion when typing in a comment
611 (but it can still be forced by the user).
613 For brace indentation, update lexer_has_braces() in editor.c;
614 indentation after ':' is done from on_new_line_added().
616 If the Scintilla lexer supports user type keyword highlighting (e.g.
617 SCLEX_CPP), update document_update_tags() in document.c.
619 Adding a TagManager parser
620 ^^^^^^^^^^^^^^^^^^^^^^^^^^
621 This assumes the filetype for Geany already exists.
623 First write or find a CTags compatible parser, foo.c. Check this fork:
624 https://github.com/fishman/ctags
626 There may be some unmerged language patches for CTags at:
627 http://sf.net/projects/ctags - see the tracker.
629 (You can also try the Anjuta project's anjuta-tags codebase.)
631 .. note::
632     From Geany 1.22 GLib's GRegex engine is used instead of POSIX
633     regex, unlike CTags. It should be close enough to POSIX to work
634     OK.
635     We no longer support regex parsers with the "b" regex flag
636     option set and Geany will print debug warnings if it's used.
637     CTags supports it but doesn't currently (2011) include any
638     parsers that use it. It should be easy to convert to extended
639     regex syntax anyway.
641 Method
642 ``````
643 * Add foo.c to SRCS in Makefile.am.
644 * Add foo.o to OBJS in makefile.win32.
645 * Add path/foo.c to geany_sources in wscript.
646 * Add Foo to parsers.h
647 * Add TM_PARSER_FOO to tagmanager/src/tm_parser.h.  The list here must follow
648   exactly the order in parsers.h.
650 In foo.c:
651 Edit FooKinds 3rd column to match a s_tag_type_names string in tm_tag.c.
652 (You may want to make the symbols.c change before doing this).
654 In filetypes.c, init_builtin_filetypes():
655 Set the 2nd argument of the FT_INIT() macro for this filetype to FOO.
657 In symbols.c:
658 Unless your parser uses C-like tag type kinds, update
659 add_top_level_items() for foo, calling tag_list_add_groups(). See
660 get_tag_type_iter() for which tv_iters fields to use.
662 Tests
663 `````
664 The tag parser tests checks if the proper tags are emitted
665 for a given source. Tests for tag parsers consist of two files: the
666 source to parse, and the expected output. Tests are run using ``make
667 check``.
669 The source to parse should be in the file ``tests/ctags/mytest.ext``,
670 where ``mytest`` is the name you choose for your test, and ``ext`` is an
671 extension recognized by Geany as the language the test file is for.
672 This file should contain a snippet of the language to test for.
673 It can be either long or short, depending on what it tests.
675 The expected output should be in the file ``tests/ctags/mytest.ext.tags``
676 (which is the same name as the source, but with ``.tags`` appended), and
677 should be in the format generated by ``geany -g``. This file contains
678 the tag information expected to be generated from the corresponding
679 source file.
681 When you have these two files, you have to list your new test along the
682 other ones in the ``test_source`` variable in ``tests/ctags/Makefile.am``.
683 Please keep this list sorted alphabetically.
688 Stop on warnings
689 ^^^^^^^^^^^^^^^^
690 When a GLib or GTK warning is printed, often you want to get a
691 backtrace to find out what code caused them. You can do that with the
692 ``--g-fatal-warnings`` argument, which will abort Geany on the first
693 warning it receives.
695 But for ordinary testing, you don't always want your editor to abort
696 just because of a warning - use::
698     (gdb) b handler_log if level <= G_LOG_LEVEL_WARNING
701 Running with batch commands
702 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
703 Use::
705     $ gdb src/geany -x gdb-commands
707 Where ``gdb-commands`` is a file with the following lines::
709     set pagination off
710     b handler_log if level <= G_LOG_LEVEL_WARNING
711     r -v
714 Loading a plugin
715 ^^^^^^^^^^^^^^^^
716 This is useful so you can load plugins without installing them first.
717 Alternatively you can use a symlink in ~/.config/geany/plugins or
718 $prefix/lib/geany (where $prefix is /usr/local by default).
720 The gdb session below was run from the toplevel Geany source directory.
721 Start normally with e.g. "gdb src/geany".
722 Type 'r' to run.
723 Press Ctrl-C from the gdb window to interrupt program execution.
725 Example::
727     Program received signal SIGINT, Interrupt.
728     0x00d16402 in __kernel_vsyscall ()
729     (gdb) call plugin_new("./plugins/.libs/demoplugin.so")
730     ** INFO: Loaded:   ./plugins/.libs/demoplugin.so (Demo)
731     $1 = (Plugin *) 0x905a890
732     (gdb) c
733     Continuing.
735     Program received signal SIGINT, Interrupt.
736     0x00d16402 in __kernel_vsyscall ()
737     (gdb) call plugin_free(0x905a890)
738     ** INFO: Unloaded: ./plugins/.libs/demoplugin.so
739     (gdb) c
740     Continuing.
742 Building Plugins
743 ^^^^^^^^^^^^^^^^
745 The geany-plugins autotools script automatically detects the
746 installed system Geany and builds the plugins against that.
748 To use plugins with a development version of Geany built with
749 a different prefix, the plugins will need to be compiled against
750 that version if the ABI has changed.
752 To do this you need to specify both --prefix and --with-geany-libdir
753 to the plugin configure.  Normally the plugin prefix is the
754 same as the Geany prefix to keep plugins with the version of Geany
755 that they are compiled against, and with-geany-libdir is the Geany
756 prefix/lib.
758 Whilst it is possible for the plugin prefix to be different to
759 the prefix of the libdir (which is why there are two settings),
760 it is probably better to keep the version of Geany and its plugins
761 together.