1f14f4646Smrg      Xedit is a simple text editor for X.
2f14f4646Smrg
3f14f4646Smrg      Please check xedit(1) for  information about resources  and configurable
4f14f4646Smrg  options.
5f14f4646Smrg
6f14f4646Smrg      The authors  file should  list the  original authors  of all  files, but
7f14f4646Smrg  unfortunately most  collaborators and  people that  changed portions  of the
8f14f4646Smrg  code is not listed.
9f14f4646Smrg
10f14f4646Smrg
11f14f4646Smrg      List of default keyboard commands.
12f14f4646Smrg  Uppercase letters means both, uppercase and lowercase.
13f14f4646Smrg  Lowercase letter usually means Shift key is not pressed.
14f14f4646Smrg  C-    Means Control key.
15f14f4646Smrg  M-    Means Meta key.
16f14f4646Smrg        Usually Alt key has the same effect.
17f14f4646Smrg  S-    Means Shift key.
18f14f4646Smrg
19f14f4646Smrg  C-A   Move cursor to beginning of line.
20f14f4646Smrg  C-B or Left
21f14f4646Smrg        Move cursor backwards one character.
22f14f4646Smrg  C-C   Insert CUT_BUFFER0 selection at cursor position.
23f14f4646Smrg  C-D   Delete next character.
24f14f4646Smrg  C-E   Move cursor to end of line.
25f14f4646Smrg  C-F or Right
26f14f4646Smrg        Move cursor forwards one character.
27f14f4646Smrg  C-G   Keyboard reset.
28f14f4646Smrg        Use it to switch direction in the Undo stack, i.e. switch between
29f14f4646Smrg        Undo and Redo.
30f14f4646Smrg        It can also be used to stop the lisp interpreter if it is executing
31f14f4646Smrg        code.
32f14f4646Smrg  C-H   Deletes character before cursor.
33f14f4646Smrg  C-J   Adds a newline and indent.
34f14f4646Smrg        If the current buffer is the *scratch* buffer, it will work
35f14f4646Smrg        like C-X,C-E, but print the lisp output directly to the scratch
36f14f4646Smrg        buffer. Examples:
37f14f4646Smrg        (list 1 2 3) C-J will print (1 2 3) and move the cursor to
38f14f4646Smrg        the next line.
39f14f4646Smrg  C-K   Deletes text from cursor position to end of line.
40f14f4646Smrg  C-L   Redraw text window.
41f14f4646Smrg  C-M   Adds a newline.
42f14f4646Smrg  C-N or Down
43f14f4646Smrg        Move cursor to next line.
44f14f4646Smrg  C-O   Adds one newline at cursor position without moving cursor.
45f14f4646Smrg  C-P or Up
46f14f4646Smrg        Move cursor to previous line.
47f14f4646Smrg  C-R   Opens search dialog, searching backwards.
48f14f4646Smrg  C-S   Opens search dialog, searching forwards.
49f14f4646Smrg  C-T   Transpose characters.
50f14f4646Smrg  C-U   Starts multiply mode.
51f14f4646Smrg        Multiply mode means that most keyboard commands will be repeated
52f14f4646Smrg        by its parameter. After pressing C-U type a number, that can be
53f14f4646Smrg        negative. Examples:
54f14f4646Smrg        C-U 10 C-F  will move the cursor 10 characters forwards
55f14f4646Smrg        C-U -10 C-F will move the cursor 10 characters backwards
56f14f4646Smrg        If no number is specified, or if the number zero is specified,
57f14f4646Smrg        the default value is 4.
58f14f4646Smrg  C-V or PageDown
59f14f4646Smrg        Move cursor to next page.
60f14f4646Smrg  C-W   Kills current selection.
61f14f4646Smrg        C-W is also useful when there is no active selection, to return to
62f14f4646Smrg        the previous position the left mouse was clicked in the text window.
63f14f4646Smrg  C-Y   Inserts SECONDARY selection.
64f14f4646Smrg        This usually means text delete with commands other than by just
65f14f4646Smrg        pressing Backspace or Delete (that can be multiplied)
66f14f4646Smrg  C-Z   Scroll one line up.
67f14f4646Smrg  M-B or C-Left
68f14f4646Smrg        Move cursor backwards one word.
69f14f4646Smrg        C-Left only moves over alphabetic or numeric characters
70f14f4646Smrg  M-C   Capitalize word under cursor position, or next word.
71f14f4646Smrg  M-F or C-Right
72f14f4646Smrg        Move cursor forwards one word.
73f14f4646Smrg        C-Right only moves over alphabetic or numeric characters.
74f14f4646Smrg  M-I   Opens  a dialog prompting for a file name to be inserted at the
75f14f4646Smrg        cursor position.
76f14f4646Smrg        (This isn't very user friendly, this is a cavemen interface, you will
77f14f4646Smrg        love it, you will never use it).
78f14f4646Smrg  M-K   Kills text from cursor position to end of paragraph.
79f14f4646Smrg  M-L   Downcase word at cursor position or next word.
80f14f4646Smrg  M-Q   Format paragraph.
81f14f4646Smrg        Xedit interfaces Xaw code that allows several types of text
82f14f4646Smrg        formatting. To use it, you need to Select "Auto Fill" in the
83f14f4646Smrg        "Edit Menu" and select values for "Break Columns". After that,
84f14f4646Smrg        Select "Edit Menu"->"Justification" for the available options.
85f14f4646Smrg        Text typed will usually be automatically corrected, but if you
86f14f4646Smrg        need to change text in the middle of a previous line, use M-Q
87f14f4646Smrg        to reformat, and C-_ to undo if required.
88f14f4646Smrg        Examples of text:
89f14f4646Smrg
90f14f4646Smrg                    This text with align
91f14f4646Smrg                    left and break
92f14f4646Smrg                    columns at 20 and
93f14f4646Smrg                    40.
94f14f4646Smrg
95f14f4646Smrg                         This text with align
96f14f4646Smrg                              right and break
97f14f4646Smrg                            columns at 25 and
98f14f4646Smrg                            45. Remember that
99f14f4646Smrg                            Auto Fill must be
100f14f4646Smrg                         selected. And it may
101f14f4646Smrg                         be required to press
102f14f4646Smrg                          M-Q when going back
103f14f4646Smrg                             to edit previous
104f14f4646Smrg                                       lines.
105f14f4646Smrg
106f14f4646Smrg                                         This text with align center
107f14f4646Smrg                                         and break columns at 40 and
108f14f4646Smrg                                        70. A good tip is to make sure
109f14f4646Smrg                                         there are empty lines before
110f14f4646Smrg                                        and after the aligned text, so
111f14f4646Smrg                                        that M-Q will not format more
112f14f4646Smrg                                             text than it should.
113f14f4646Smrg
114f14f4646Smrg                 This text  with full  align,
115f14f4646Smrg               note that  it will  spread the
116f14f4646Smrg               words  to   fully   fill   the
117f14f4646Smrg               configured break  columns,  in
118f14f4646Smrg               this case 15 and 45. Also note
119f14f4646Smrg               that  it  doesn't  remove  any
120f14f4646Smrg               extra  indentation   from  the
121f14f4646Smrg               first  line.   This   may   be
122f14f4646Smrg               considered a  bug or  feature,
123f14f4646Smrg               but  it   doesn't  respect   2
124f14f4646Smrg               spaces after  an '.'  dot. And
125f14f4646Smrg               it doesn't align the last line
126f14f4646Smrg               of text.
127f14f4646Smrg
128f14f4646Smrg  This text with Auto Fill disabled. When Auto  Fill is disabled, tabs are
129f14f4646Smrgusually preserved, like this,		and			this. But it
130f14f4646Smrgwill basically format the text to not be larger than the text widget screen
131f14f4646Smrgwidth and. But it the screen is scrolled horizontally, it will not work as
132f14f4646Smrgexpected, the advantage over the above interface is that is considers font
133f14f4646Smrgcharacters width, while the other interface assumes fixed width characters.
134f14f4646Smrg
135f14f4646Smrg        Notice that "auto formatting" with Auto Fill mode is done when
136f14f4646Smrg        pressing enter, but information isn't saved per paragraph, so
137f14f4646Smrg        if values of align or break columns are changed, trying to edit
138f14f4646Smrg        a text block with different configuration will not give the expected
139f14f4646Smrg        results.
140f14f4646Smrg        Also notice that lines starting with non printable characters aren't
141f14f4646Smrg        automatically formatted. This is helpful for some editing modes
142f14f4646Smrg        where symbols can be used before lines in a paragraph. If you don't
143f14f4646Smrg        need this feature, usually pressing Space or Tab is enough to put the
144f14f4646Smrg        cursor at the proper position.
145f14f4646Smrg  M-U   Upcase word at cursor position or next word.
146f14f4646Smrg  M-V or PageUp
147f14f4646Smrg        Move cursor to previous page.
148f14f4646Smrg  M-Y   Kill ring yank feature. Basically it will circulate over all
149f14f4646Smrg        text that has been cut in the current session. Keep pressing it
150f14f4646Smrg        until happy :-)
151f14f4646Smrg  M-Z   Scrolls one line down.
152f14f4646Smrg  M-D   Kill word at cursor position or next word.
153f14f4646Smrg  S-M-D Delete word at cursor position or next word.
154f14f4646Smrg        Does not go to the kill ring.
155f14f4646Smrg  M-H or M-Delete or M-Backspace.
156f14f4646Smrg        Kill word at cursor position or previous word.
157f14f4646Smrg  S-M-H or S-M-Delete or S-M-Backspace
158f14f4646Smrg        Delete word at cursor position or previous word.
159f14f4646Smrg        Does not go to the kill ring.
160f14f4646Smrg  M-.   Find definition/declaration of symbol string of selected text, and/or
161f14f4646Smrg        finds next tag when more than one definition exists for the symbol.
162f14f4646Smrg  M-< or Home
163f14f4646Smrg        Move cursor to beginning of file.
164f14f4646Smrg  M-> or End
165f14f4646Smrg        Move cursor to end of file.
166f14f4646Smrg  M-] or C-Down
167f14f4646Smrg        Move cursor to next paragraph.
168f14f4646Smrg  M-[ or C-Up
169f14f4646Smrg        Move cursor to previous paragraph.
170f14f4646Smrg  C-_ or C-X,U
171f14f4646Smrg        Undo.
172f14f4646Smrg        If enabled in the given textwidget. Not enabled by default in the
173f14f4646Smrg        message window and filename window, or any of the other text widgets
174f14f4646Smrg        in the several available dialogs.
175f14f4646Smrg  C-\ or C-Kanji
176f14f4646Smrg        Reconnect Input Method.
177f14f4646Smrg        In international mode (probably broken interface).
178f14f4646Smrg  S-Insert
179f14f4646Smrg        Insert PRIMARY selection from CUT_BUFFER0.
180f14f4646Smrg  C-Q
181f14f4646Smrg        Followed by any character, will insert the next typed character
182f14f4646Smrg        useful to insert control characters. For example C-Q,C-L will
183f14f4646Smrg        insert ^L at the cursor position.
184f14f4646Smrg  LeftMouseButton
185f14f4646Smrg        When pressed marks the start of a PRIMARY selection at CUTBUFFER0
186f14f4646Smrg        When moved while pressed extends the selection.
187f14f4646Smrg  MiddleMouseButton
188f14f4646Smrg        When pressed, inserts the PRIMARY selection at CUTBUFFER0 at
189f14f4646Smrg        the cursor position.
190f14f4646Smrg  RightMouseButton
191f14f4646Smrg        Can be used to adjust a selection done with LeftMouseButton.
192f14f4646Smrg  C-A,Tab
193f14f4646Smrg        If the loaded file has a indentation rules file, C or Lisp, xedit
194f14f4646Smrg        will reindent the line. Also, entering a fresh character on a
195f14f4646Smrg        newline should be enough to move the cursor to the proper position.
196f14f4646Smrg        To override it, you may need to use the C-U to multiply the action,
197f14f4646Smrg        as it will only indent if only one character was added.
198f14f4646Smrg  C-X,C-C or (Pressing the Quit button)
199f14f4646Smrg        Exits xedit.
200f14f4646Smrg        If there are unsaved files, a message will be printed asking to
201f14f4646Smrg        "exit" again, or save the files.
202f14f4646Smrg  C-X,C-E
203f14f4646Smrg        Execute lisp expression before the cursor position.
204f14f4646Smrg  C-X,C-F
205f14f4646Smrg        Changes keyboard input focus to the filename text input window.
206f14f4646Smrg        In this mode, pressing Tab will try to complete the filename
207f14f4646Smrg        being typed.
208f14f4646Smrg        When more than one match exists, pressing Tab again will display
209f14f4646Smrg        the directory navigation window.
210f14f4646Smrg        The initial search path usually is the basename of the file loaded
211f14f4646Smrg        in the current textwindow, or currently directory from where
212f14f4646Smrg        xedit was started if the *scratch* is the current "buffer".
213f14f4646Smrg        The character ~ can be used as a shortcut for the home directory
214f14f4646Smrg        and ~username will be replaced by the home directory of "username"
215f14f4646Smrg        if it exists.
216f14f4646Smrg  C-X,C-S or (Pressing the Save button)
217f14f4646Smrg        Saves the file in the current text window.
218f14f4646Smrg  C-X,Tab
219f14f4646Smrg        Indents the current paragraph.
220f14f4646Smrg        Use the C-U modifier to specify the number of spaces to insert
221f14f4646Smrg        or remove if the C-U parameter is negative.
222f14f4646Smrg  C-X,0
223f14f4646Smrg        Deletes the current window.
224f14f4646Smrg        The file being edited is not unloaded.
225f14f4646Smrg  C-X,1
226f14f4646Smrg        Deletes the other window.
227f14f4646Smrg        The file being edited is not unloaded.
228f14f4646Smrg  C-X,2
229f14f4646Smrg        Splits vertically the current window.
230f14f4646Smrg  C-X,3
231f14f4646Smrg        Splits vertically the current window.
232f14f4646Smrg  C-X,b
233f14f4646Smrg        Switch the contents of the current window to the next file in
234f14f4646Smrg        the list of loaded files.
235f14f4646Smrg  C-X,d
236f14f4646Smrg        Displays the directory listing window.
237f14f4646Smrg        In this window, it is possible to navigate in the file system
238f14f4646Smrg        to choose a file to edit.
239f14f4646Smrg        Usually, this is the same as pressing C-X,C-F,Tab
240f14f4646Smrg        See C-X,C-F for more information.
241f14f4646Smrg  C-X,k
242f14f4646Smrg        Unloads the file being edited.
243f14f4646Smrg        If the file has not been saved, a message will be displayed,
244f14f4646Smrg        asking to either press C-X,k again, or save the file
245f14f4646Smrg        The *scratch* buffer cannot be killed and will always
246f14f4646Smrg        prints a warning when exiting xedit. This is the expected behavior.
247f14f4646Smrg  C-X,o
248f14f4646Smrg        Switch input focus to the other window, making it the current one
249f14f4646Smrg        If the editor doesn't have splited windows, this command is ignored.
250f14f4646Smrg  Insert
251f14f4646Smrg        Switches between insert and overwrite mode.
252f14f4646Smrg        In overwrite mode text is typed over existing file contents,
253f14f4646Smrg        only extending the file contents when typing at the end of
254f14f4646Smrg        a line (or file).
255f14f4646Smrg  Escape
256f14f4646Smrg        Enters the line edit mode.
257f14f4646Smrg        In this mode it is possible to use regex expressions to search and
258f14f4646Smrg        replace the contents of the file loaded in the current text window.
259f14f4646Smrg        Refer to the xedit(1) manpage for more information of the regex
260f14f4646Smrg        expression format.
261f14f4646Smrg        Note that the regex used by xedit isn't IEEE Std 1003.2 compliant,
262f14f4646Smrg        and not compliant with most regex implementations in that it doesn't
263f14f4646Smrg        support some complex search patterns, usually involving patterns
264f14f4646Smrg        like ((.*)+)? that may require too much restarts or have several
265f14f4646Smrg        correct interpretations for multiple matches. Also, it always does
266f14f4646Smrg        minimal matching, and it is not configurable like in pcre, example:
267f14f4646Smrg        searching "a1a1a1" with the pattern "(.*)\d" will find "a1" and
268f14f4646Smrg        not "a1a1a1" as could be expected.
269f14f4646Smrg        Please refer to lisp/re/README for more information on the supported
270f14f4646Smrg        regex expressions.
271f14f4646Smrg  C-LeftMouseButton
272f14f4646Smrg        Displays the "File Menu" from where it is possible to select a
273f14f4646Smrg        new file to be edited in the current window.
274f14f4646Smrg  C-MiddleMouseButton
275f14f4646Smrg        Displays the "Edit Menu" that usually has the following options:
276f14f4646Smrg     +------------------+-------------+
277f14f4646Smrg     | Wrapping      -> | Never       |
278f14f4646Smrg     |                  | Line        |
279f14f4646Smrg     |                  | Word        |
280f14f4646Smrg     | Auto Fill        +-------------+
281f14f4646Smrg     |                  +-------------+
282f14f4646Smrg     | Justification -> | Left        |
283f14f4646Smrg     |                  | Right       |
284f14f4646Smrg     |                  | Center      |
285f14f4646Smrg     |                  | Full        |
286f14f4646Smrg     |                  +-------------+
287f14f4646Smrg     | Break Columns... |
288f14f4646Smrg     |                  +-------------+
289f14f4646Smrg     | Scrollbars    -> | Vertical    |
290f14f4646Smrg     |                  | Horizontal  |
291f14f4646Smrg     |                  +-------------+
292f14f4646Smrg     |                  +-------------+
293f14f4646Smrg     | Edit Mode     -> | Plain/None  |
294f14f4646Smrg     |                  | C/C++       |
295f14f4646Smrg     |                  | Lisp/Scheme |
296f14f4646Smrg     |                  | X imake     |
297f14f4646Smrg     |                  | Makefile    |
298f14f4646Smrg     |                  | Unix shell  |
299f14f4646Smrg     |                  | SGML        |
300f14f4646Smrg     |                  | HTML        |
301f14f4646Smrg     |                  | Man page    |
302f14f4646Smrg     |                  | X resource  |
303f14f4646Smrg     |                  | XF86Config  |
304f14f4646Smrg     |                  | RPM spec    |
305f14f4646Smrg     |                  | XFree86 log |
306f14f4646Smrg     |                  | Patch file  |
307f14f4646Smrg     +------------------+-------------+
308f14f4646Smrg        "Wrapping" is disabled if "Auto Fill" is enabled.
309f14f4646Smrg        "Justification" and "Break Columns..." are enabled if "Auto Fill"
310f14f4646Smrg        is also enabled.
311f14f4646Smrg        "Edit Mode" lists the available syntax highlight and indentation
312f14f4646Smrg        rules defined.
313f14f4646Smrg        Note that most of these options don't work in "international" mode.
314f14f4646Smrg        Several xedit interfaces works only with 8 bits encodings, and
315f14f4646Smrg        doesn't properly handle UTF-8.
316f14f4646Smrg  C-RightMouseButton
317f14f4646Smrg        Displays the "Option Menu".
318f14f4646Smrg        Currently the only option is an Ispell frontend.
319f14f4646Smrg  FourthMouseButton (usually also moving up the mouse wheel)
320f14f4646Smrg        Scroll one line down
321f14f4646Smrg  FifthMouseButton (usually also moving down the mouse wheel)
322f14f4646Smrg        Scroll one line up
323f14f4646Smrg
324f14f4646Smrg
325f14f4646Smrg
326f14f4646Smrg      There  is   also   some   documentation   in   lisp/README,   lisp/TODO,
327f14f4646Smrg  lisp/re/README, lisp/re/tests.txt, and comments/justifications/wishlists for
328f14f4646Smrg  the cases the interpreter fail to give the proper result for a given test.
329f14f4646Smrg
330f14f4646Smrg      The  lisp  interpreter  implements  most  of   a  standard  COMMON  LISP
331f14f4646Smrg  environment, but the  compiler generates only  byte code and  not everything
332f14f4646Smrg  can be compiled, in those cases the interpreter  does the work. Examples are
333f14f4646Smrg  constructs involving  UNWIND-PROTECT or  any  kind of  jump  outside of  the
334f14f4646Smrg  current function body.
335f14f4646Smrg
336f14f4646Smrg      For more  information please  consult any  COMMON LISP  documentation or
337f14f4646Smrg  tutorial.
338f14f4646Smrg
339f14f4646Smrg
340f14f4646Smrg
341f14f4646Smrg      Simple tutorial on writing a "foolang" syntax highlight mode for xedit.
342f14f4646Smrg
343f14f4646Smrg  Create a file called foolang.lsp
344f14f4646Smrg  Add:
345f14f4646Smrg  --
346f14f4646Smrg  (require "syntax")
347f14f4646Smrg  (require "indent")
348f14f4646Smrg  (in-package "XEDIT")
349f14f4646Smrg  --
350f14f4646Smrg  to foolang.lsp
351f14f4646Smrg  Check the available files if you want a custom property, or to know about
352f14f4646Smrg  the available ones. One example is:
353f14f4646Smrg  --
354f14f4646Smrg  (defsynprop *prop-foolang*
355f14f4646Smrg    "foolang"
356f14f4646Smrg    :font       "fixed"
357f14f4646Smrg    :foreground "rgb:a/b/c"
358f14f4646Smrg    :background "rgb:1/2/3"
359f14f4646Smrg    :underline  t
360f14f4646Smrg    :overstrike t)
361f14f4646Smrg  --
362f14f4646Smrg  Check  lisp/modules/xedit.lsp  for   the  other  options,   like  subscript,
363f14f4646Smrg  superscript and/or combining XLFD properties.
364f14f4646Smrg  Create a syntax definition for foolang. Check the definition of defsyntax in
365f14f4646Smrg  lisp/modules/syntax.lsp for more details. One example for foolang is:
366f14f4646Smrg  --
367f14f4646Smrg  (defsyntax *foolang-mode* :foolang nil nil nil
368f14f4646Smrg    ;; use the sample property created for foolang whenever the string
369f14f4646Smrg    ;; foolang is found at the toplevel
370f14f4646Smrg    (syntoken "\\<foolang\\>" :property *prop-foolang*)
371f14f4646Smrg
372f14f4646Smrg    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
373f14f4646Smrg    ;; process C style comments
374f14f4646Smrg    (syntoken "/*" :nospec t :begin :comment :contained t)
375f14f4646Smrg      ;; contained is an option to not "export" this definition to child
376f14f4646Smrg      ;; tables
377f14f4646Smrg
378f14f4646Smrg    (syntable :comment *prop-comment* #'default-indent
379f14f4646Smrg      ;; #'default-indent means a very simple indent that follows indentation
380f14f4646Smrg      ;; of previous line. Use nil for no indentation
381f14f4646Smrg
382f14f4646Smrg      ;; Don't start a new table, instead flag as an error if nested
383f14f4646Smrg      (syntoken "/*" :nospec t :property *prop-error*)
384f14f4646Smrg        ;; :nospec t sets the RE_NOSPEC flag for the regex, i.e. searches
385f14f4646Smrg        ;; a literal string, and * will not be a special character
386f14f4646Smrg
387f14f4646Smrg      (syntoken "XXX|TODO|FIXME" :property *prop-annotation*)
388f14f4646Smrg        ;; just to make it easier to flag some important comment
389f14f4646Smrg
390f14f4646Smrg      (syntoken "*/" :nospec t :switch -1)
391f14f4646Smrg        ;; The :switch argument is the number of tables to "pop", in
392f14f4646Smrg        ;; this case, we are at table :comment, and :switch -1 returns
393f14f4646Smrg        ;; to table :foolang, that is the "root" table
394f14f4646Smrg    )
395f14f4646Smrg
396f14f4646Smrg    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
397f14f4646Smrg    ;; Process lisp comments that can nest
398f14f4646Smrg    (syntable :lisp-comment *prop-comment* nil
399f14f4646Smrg
400f14f4646Smrg      ;; Start a comment, possibly nested
401f14f4646Smrg      (syntoken "#|" :nospec t :begin :lisp-comment)
402f14f4646Smrg
403f14f4646Smrg      ;; Returns to previous comment in stack or to main :foolang table
404f14f4646Smrg      (syntoken "|#" :nospec t :switch -1)
405f14f4646Smrg
406f14f4646Smrg      ;; For easier flagging important comments
407f14f4646Smrg      (syntoken "XXX|FIXME|TODO" :property *prop-annotation*)
408f14f4646Smrg    )
409f14f4646Smrg
410f14f4646Smrg    ;; This is usually in the end of the list, but can be anywhere,
411f14f4646Smrg    ;; just that if it isn't at the end, conflicting rules are resolved
412f14f4646Smrg    ;; by declaration order
413f14f4646Smrg    (synaugment :lisp-comment)
414f14f4646Smrg      ;; Adds the :lisp-comment table to :foolang table
415f14f4646Smrg
416f14f4646Smrg    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
417f14f4646Smrg    ;; Lisp like strings that don't need a \ at the end of the line
418f14f4646Smrg    (syntable :lisp-string *prop-string* nil
419f14f4646Smrg      ;; ignore a escaped " in the middle of the string
420f14f4646Smrg      (syntoken "\\\\.")
421f14f4646Smrg        ;; Note that no options are used, just keep using the current
422f14f4646Smrg        ;; property. Unfortunately, backslashes must be escaped twice.
423f14f4646Smrg        ;; Once for the lisp reader and once for the regex compiler.
424f14f4646Smrg
425f14f4646Smrg      (syntoken "\"" :nospec: t :switch -1)
426f14f4646Smrg        ;; :nospec is used just to create a faster regex. switch -1
427f14f4646Smrg        ;; returns to the previous syntax table. It isn't an error to
428f14f4646Smrg        ;; try to go down the "root" table, but if that happens, it
429f14f4646Smrg        ;; probably means either wrong syntax definition of malformed input.
430f14f4646Smrg    )
431f14f4646Smrg
432f14f4646Smrg    (synaugment :lisp-string)
433f14f4646Smrg      ;; Adds the :lisp-string table to :foolang table
434f14f4646Smrg      ;; Note that since there isn't a rule to start a string in the
435f14f4646Smrg      ;; :lisp-string table, it cannot nest, maybe because the ending
436f14f4646Smrg      ;; character is the starting character ? :-))
437f14f4646Smrg
438f14f4646Smrg    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
439f14f4646Smrg    ;; C style string rules
440f14f4646Smrg    (syntable :string *prop-string* nil
441f14f4646Smrg      ;; Ignore escaped characters
442f14f4646Smrg      (syntoken "\\\\.")
443f14f4646Smrg
444f14f4646Smrg    ;; Match, most, printf arguments.
445f14f4646Smrg    (syntoken "%%|%([+-]?\\d+)?(l?[deEfgiouxX]|[cdeEfgiopsuxX])"
446f14f4646Smrg        :property *prop-format*)
447f14f4646Smrg      ;; Just for fun. This makes easier to see printf formats in strings
448f14f4646Smrg      ;; *prop-format* is *prop-string* with the :underline option
449f14f4646Smrg
450f14f4646Smrg    (syntoken "\\\\$")
451f14f4646Smrg    ;; a backslash extends the string to the next line
452f14f4646Smrg
453f14f4646Smrg    ;; A nonscaped " inside a string finishes it, since this table doesn't
454f14f4646Smrg    ;; have sub tables, and cannot nest, should return to :foolang table
455f14f4646Smrg    ;; from here
456f14f4646Smrg    (syntoken "\"" :nospec t :switch -1)
457f14f4646Smrg
458f14f4646Smrg    ;; This token rule starts a new table called :error because end of line
459f14f4646Smrg    ;; has been matched. Note that it is defined last, so that a line
460f14f4646Smrg    ;; ending with " or \ will be processed first.
461f14f4646Smrg    (syntoken ".?$" :begin :error)
462f14f4646Smrg
463f14f4646Smrg    (synaugment :string)
464f14f4646Smrg      ;; Adds the :string table to :foolang table
465f14f4646Smrg
466f14f4646Smrg    ;; This table is used by :string, but could be shared for other patterns
467f14f4646Smrg    ;; like characters constants, etc.
468f14f4646Smrg    ;; It uses :switch -2 because it is started inside the :string table,
469f14f4646Smrg    ;; but it is also a table, so, pops two tables from the table stack
470f14f4646Smrg    (syntable :error *prop-error* nil
471f14f4646Smrg	(syntoken "^.*$" :switch -2)
472f14f4646Smrg    )
473f14f4646Smrg  )
474f14f4646Smrg  --
475f14f4646Smrg
476f14f4646Smrg      Indentation rules are significantly  more complex. I suggest  looking at
477f14f4646Smrg  lisp/modules/indent.lsp   for   the   macros   and   function   definitions;
478f14f4646Smrg  and lisp/modules/progmodes/lisp.lsp and lisp/modules/progmodes/c.lsp for two
479f14f4646Smrg  sample  implementations   of   indentation   for   Lisp/Scheme   and   C/C++
480f14f4646Smrg  respectively.
481f14f4646Smrg
482f14f4646Smrg      Note also  that indentation  is parsed  backwards, what  can cause  some
483f14f4646Smrg  confusion, and make "visualization" of order or precedence of evaluation for
484f14f4646Smrg  rules harder to understand.
485f14f4646Smrg
486f14f4646Smrg      A simple indentation rules definition for foolang could be:
487f14f4646Smrg
488f14f4646Smrg  --
489f14f4646Smrg  (defindent *foolang-mode-indent* :foolang
490f14f4646Smrg    ;; This must be the first token and usually the only token matching
491f14f4646Smrg    ;; BOL (Beginning of Line)
492f14f4646Smrg    (indtoken "^\\s*"   :indent
493f14f4646Smrg      :code (or *offset* (setq *offset* (+ *ind-offset* *ind-length*))))
494f14f4646Smrg      ;; the keyword :indent is a pattern put on a list when there is
495f14f4646Smrg      ;; a match, so that later patterns can be "reduced" by some other
496f14f4646Smrg      ;; rule, i.e.:  (:indent :indent) could be reduced to (:indent)
497f14f4646Smrg
498f14f4646Smrg    (indtoken "//.*$"   nil)
499f14f4646Smrg      ;; C++ style comment. Returning nil instead of a token basically
500f14f4646Smrg      ;; ignores the token, as it should not enter the reduction pattern
501f14f4646Smrg      ;; list
502f14f4646Smrg
503f14f4646Smrg    ;; Sample C comment pattern
504f14f4646Smrg    (indtoken "*/" :ccomment :nospec t :begin :comment)
505f14f4646Smrg      ;; Note that the indaugment macro doesn't need to be used, and actually
506f14f4646Smrg      ;; would be an error. In this example, the indentation compiler checks
507f14f4646Smrg      ;; the :begin :comment and handles it internally, as it already needs
508f14f4646Smrg      ;; to check for things like typos, unreachable labels, detectable
509f14f4646Smrg      ;; non resolving rules, etc. There is runtime check also, so it should
510f14f4646Smrg      ;; never enter an infinite loop when trying to resolve reduction rules.
511f14f4646Smrg      ;; Check lisp/modules/indent.lsp:(compile-indent-table) for the
512f14f4646Smrg      ;; implementation and more comments.
513f14f4646Smrg
514f14f4646Smrg    ;; Indentation rules also have stacked tables
515f14f4646Smrg    (indtable :comment
516f14f4646Smrg      (indtoken "/*" :ocomment :nospec t :switch -1))
517f14f4646Smrg      ;; Note that the name is :ocomment (open comment), but that the
518f14f4646Smrg      ;; the table is finished when matching the open comment pattern
519f14f4646Smrg
520f14f4646Smrg    ;; A simple initialization of a variable used by the indentation rules
521f14f4646Smrg    (indinit       (parens 0))
522f14f4646Smrg      ;; This variable can be declared anywhere in the body of defindent,
523f14f4646Smrg      ;; It will be properly moved to a "variables declaration section"
524f14f4646Smrg      ;; when expanding and compiling the table.
525f14f4646Smrg
526f14f4646Smrg    (indtoken "("  :oparen  :nospec t  :code (incf parens))
527f14f4646Smrg    (indtoken ")"  :cparen  :nospec t  :code (decf parens))
528f14f4646Smrg      ;; These two tokes add the patterns :oparen and :cparen to the
529f14f4646Smrg      ;; "pattern list", and also have code to remember the balancing
530f14f4646Smrg      ;; of parenthesis.
531f14f4646Smrg
532f14f4646Smrg
533f14f4646Smrg    ;; One of the simplest reduction rules :-)
534f14f4646Smrg    (indreduce nil
535f14f4646Smrg      t
536f14f4646Smrg      ((:comment)))
537f14f4646Smrg      ;; Once the boundings of a comment are found, just ignore it, like
538f14f4646Smrg      ;; what was done with the // pattern, but in that case, the boundings
539f14f4646Smrg      ;; were readily available.
540f14f4646Smrg      ;; The t (True) parameter means that this rule is always evaluated,
541f14f4646Smrg      ;; but conditional code may be used, and implicit code may be added
542f14f4646Smrg      ;; to the end of the indreduce macro.
543f14f4646Smrg      ;; Since it is a macro, code can be compiled to optimized bytecode
544f14f4646Smrg      ;; after the macro is expanded.
545f14f4646Smrg
546f14f4646Smrg    (indinit    (indent 0))
547f14f4646Smrg      ;; Note that there is a special *indent* variable that should hold the
548f14f4646Smrg      ;; proper indentation value, but it may be required to "overwrite"
549f14f4646Smrg      ;; without forgetting that value, for things like:
550f14f4646Smrg      ;;
551f14f4646Smrg      ;;  foo(bar(baz(blah
552f14f4646Smrg      ;;      ^       ^
553f14f4646Smrg      ;;      |       |
554f14f4646Smrg      ;;      indent  |
555f14f4646Smrg      ;;              effective indentation to be used
556f14f4646Smrg      ;;
557f14f4646Smrg      ;; where it is desirable to align the code in the next line with the
558f14f4646Smrg      ;; last open parenthesis.
559f14f4646Smrg
560f14f4646Smrg
561f14f4646Smrg      Since the  interface is,  unfortunately,  complex enough  to not  expect
562f14f4646Smrg  casual users to have something like a $HOME/.xedit file,  if you want to add
563f14f4646Smrg  new modes, please check lisp/modules/xedit.lsp:*auto-modes*
564f14f4646Smrg
565f14f4646Smrg      There is some documentation about the variable. It should be possible to
566f14f4646Smrg  change/update the variable from the lisp interface  in the *scratch* buffer,
567f14f4646Smrg  but for  safety, it  is suggested  that  if you  add new  rules, you  should
568f14f4646Smrg  restart  xedit  after  it.  Also  note  that  there   is  compiled  code  in
569f14f4646Smrg  lisp/xedit.c that expects that variable to follow an specific format.
570f14f4646Smrg
571f14f4646Smrg      You may notice that several .lsp files  aren't "properly indented"; this
572f14f4646Smrg  is because the lisp indentation rules  file was made long after  most of the
573f14f4646Smrg  other files were done, and it was considered  a bad practice to gratuitously
574f14f4646Smrg  reindent all files.
575f14f4646Smrg
576f14f4646Smrg
577f14f4646Smrg
578f14f4646Smrg      At the  time  of this  writing,  the ispell  interface  should be  again
579f14f4646Smrg  functional, but it may be required to use some  old ispell program to handle
580f14f4646Smrg  non utf8 text. But it should work properly for  the english language, and in
581f14f4646Smrg  international mode, should work with any language. But there are problems in
582f14f4646Smrg  international mode not fixed.
583f14f4646Smrg
584f14f4646Smrg      I  (Paulo  Cesar)  considered  several  times   to   extend  the  normal
585f14f4646Smrg  textwidget to handle  utf8, but this  is probably  a lot of  work/time badly
586f14f4646Smrg  spent and I prefer  to work on other  personal projects, but still  xedit is
587f14f4646Smrg  the editor I use for programming. The XPRINT support unfortunately is broken
588f14f4646Smrg  due to it. Note that xedit,  like pretty much any other  Xaw application can
589f14f4646Smrg  be linked against  Xaw with  XPRINT support. In  the case  of xedit,  a flag
590f14f4646Smrg  could be used, like the "international" variable to, at runtime, disable all
591f14f4646Smrg  the related code, if required.
592f14f4646Smrg
593f14f4646Smrg      Also at the time of this writing, the tags  interface was added, as well
594f14f4646Smrg  as several other bug fixes. The tags interface is documented in the manpage,
595f14f4646Smrg  but the action  shortcut may  not be clear.  The default  shortcut is  M-. .
596f14f4646Smrg  There is no support for more  than one tags file, or changing  the tags file
597f14f4646Smrg  at runtime. But  the code  should be  easy to  adapt for  this case,  as all
598f14f4646Smrg  related functions receive pointers to the appropriate structures. One option
599f14f4646Smrg  could be to descend  from the directory of  the loaded file searching  for a
600f14f4646Smrg  tags file, and then associate the file with the tags definition, if it isn't
601f14f4646Smrg  already loaded. Shouldn't be  hard to implement. For  "inter project" files,
602f14f4646Smrg  it should be better to  have one xedit window per  "project", i.e. searching
603f14f4646Smrg  the definition of something  like a libc  symbol should probably be  done in
604f14f4646Smrg  another xedit window.
605