-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.groff_mode
227 lines (156 loc) · 9.13 KB
/
README.groff_mode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
DESCRIPTION:
groff_mode for the Jed editor is an extension editing mode that facilitates
the editing of groff/nroff/troff files. It has a color highlighting scheme,
but it also has a few other features, such as the toggling of inline markup
styles, previewing of the file in a pdf-viewer as well as being able to
convert and install OpenType or TrueType fonts in a chosen user directory
for use with groff. The mode will auto detect what options to groff that are
needed to convert the current document for a chosen output device.
DOWNLOAD:
It is easiest just to check out my repository on Gihub, it is only a few
kilobytes:
git clone https://github.com/mortenivar/Jed-modes.git
INSTALLATION and CUSTOMIZATION:
Copy groff_mode.sl to directory in your jed library path, e.g.
/usr/share/jed/lib. If you only have write access to your own home
directory, then do something like this:
cd
mkdir -p .jed/lib
cp groff_mode.sl .jed/lib
and add the following line near the top of your ˝/.jedrc:
set_jed_library_path(get_jed_library_path () + "," + dircat(getenv("HOME"), ".jed/lib"));
This would include the ".jed/lib" directory under your home directory as
part of the editor's search path for library files.
Also add the following lines to your ~/.jedrc:
autoload("groff_mode", "groff_mode");
variable groff_exts = "1 2 3 4 5 6 7 8 man mm ms me mdoc mom nroff troff groff tr trf";
array_map(Void_Type, &add_mode_for_extension, "groff", strtok(groff_exts));
This enables autoloading of the mode for a number of different file
extensions.
Another way to load the mode is <alt>-x -> groff_mode
You may also add the following block of variables to your ~/.jedrc:
variable Groff_Output_Device = pdf;
variable Groff_Pdf_Viewer = "zathura";
variable Groff_Paper_Format = "A4";
variable Groff_Encoding = "utf-8";
variable Groff_Cmd = "";
variable Groff_Use_Tabcompletion = 0;
These settings are the default settings and you may then change them there
to your liking. The variable, "Groff_Cmd", may be used to set a default
groff command line for converting the document in case you have some special
needs or the auto detection for some reason fails. It will then override the
auto detection mechanism. The variable, "Groff_Use_Tabcompletion", is
explained later.
The variables, "Groff_Output_Device", "Groff_Paper_Format", "Groff_Encoding"
and "Groff_Cmd", may also be changed on the fly from within the editor.
USAGE:
(e.g. "<ctrl>-cf" means, type <ctrl>-c, release both keys and type 'f')
- <F10> -> Mode, will show some menu items of available commands.
- <F9> renders the current buffer in a pdf-viewer, a pager program such
as less(1) or a browser such as lynx(1). You may keep the
rendered document open in the pdf-viewer and <F9> will update
the contents in the pdf-viewer with no need to save the file in
between or to restart the pdf-viewer. Updating happens
completely transparently. The status line will be dynamically
updated with the detected groff options needed to convert the
document
- <ctrl>-cf will convert and install a TrueType or OpenType font for use
with groff. It uses the environment variable, $GROFF_FONT_PATH,
as the installation target. If you have haven't set this
variable in your environment, it will be set by the mode to
$XDG_DATA_HOME/groff/site-font. $XDG_DATA_HOME usually defaults
to $HOME/.local/share. If $XDG_DATA_HOME is not set in your
environment, the mode will set $GROFF_FONT_PATH to
$HOME/.local/share/groff/site-font.
- <ctrl>-cF will batch convert and install, either all TrueType or OpenType
fonts in a directory or a subset of those that match an
expression. During installation, no user interaction is
required; the style suffixes, R, B, I, BI, are parsed from the
font file names and added automatically to the groff font
description file name.
- <ctrl>-cn will pop up a window with a list of the installed groff font
description files from which you may insert a chosen font name
into the buffer. The names may be completed with the <tab> key.
- <ctrl>-ci will apply some text attribute to the current word or a block of
marked text. The available attributes are: font face, bold,
italic, font size, color and quote. Calling the function on an
already marked up word will remove the attribute. If color is
chosen, a pop up selection window with all the defined groff
colors is shown.
- <ctrl>-cO will show a one-line menu in the message area whence you may
change the settings for output device, input encoding, paper
format and toggle between portrait and landscape paper
orientation.
- <ctrl>-cC will show the full groff command line, the mode has detected as
needed to convert the current buffer, in the message area. This
is similar to what the grog(1) program does.
- <ctrl>-ce will give you a input line in the mini buffer where you may enter
or edit the groff command to convert the document. This sets the
value of the variable, "Groff_Cmd", which will override the built-in
detection mechanism. If you want to revert to auto detection, then
just clear the line.
- <ctrl>-cg will display a one-line menu in the message area with items for
drawing various figures with pic(1).
- <ctrl>-cd will display a one-line menu in the message area with items for
drawing various figures with troff requests.
Finally, the keys for the functions, forward_paragraph() and
backward_paragraph() will jump forward or backward to regular text portions
of the document, skipping over macros, comments, etc.
Using a mode hook:
When the mode is loaded, a mode hook is run. You may exploit that by
inserting the e.g. following into your ~/.jedrc:
in your ~/.jedrc, insert:
variable Groff_Use_Tabcompletion;
variable Newl_Delim;
variable Extended_Wordchars;
define groff_mode_hook ()
{
Extended_Wordchars = "-_.\\\\[\]*";
Newl_Delim = "\t";
Groff_Use_Tabcompletion = 1;
}
Using the tabcomplete.sl extension:
If you installed the tabcomplete.sl extension from the git repository, you
may use it with this groff editing mode by setting the variable,
"Groff_Use_Tabcompletion = 1", in the groff_mode_hook as per above. The
variable, "Extended_Wordchars", is set to include the period character as
part of a word, so that macros/requests are recognized. The variable,
"Newl_Delim" must be set to "\t", the TAB character, in order to have the
help messages in the ~/.tabcomplete_* completion files for the mode
formatted correctly.
The tabcomplete extension is first and foremost an extension that enables
completion with the <tab> key by default on words that are loaded from a
file and automatic insertion of code snippets and the like, but it also has
a built-in help system. Completion files with extensive help for the "ms"
and "me" macro packages as well as for troff/nroff requests are supplied in
the file, "groff_tabcompletion_files.tar_gz" in the git repository. The
archive contains the three files, ".tabcomplete_troff", ".tabcomplete_me"
and ".tabcomplete.ms", i.e. three hidden files that must be dumped in your
home directory. If you edit e.g. a file using the "ms" macros, then the
corresponding file, ~/.tabcompletion_ms will be loaded. If you start with an
empty file, then give the file the ".ms" extension.
While it doesn't make much sense to complete on two-letter macros, the help
system may be useful: Typing <F1> on a macro will show a help entry for it
in either the message area or in a window. Typing <F2> will present you with
an "apropos" prompt where you may enter some search string and then all the
macros/requests that match the search string in their help entries are
returned. E.g., if you didn't quite remember that macro that pertained to
setting a margin, just type <F2> -> "margin", and all the macros relating to
margins are shown in a pop up window along with their help strings. Only
search results that apply to the currently used macro package in addition to
pure troff/nroff requests are returned. Matches are sorted by how many times
the search query appears in the help string.
Hint: hitting <tab> after a ".ft" request pops up the window with font name
selection. Hitting <tab> after a ".gcolor" request pops up a window with all
the defined groff color names.
Using the aspell.sl extension:
The "init_aspell();" line, as shown in the mode hook above, will enable
spell checking, including flyspelling, for your groff documents.
You must have the line
autoload("init_aspell", "aspell");
in your ~/.jedrc
See the README files for those two extensions and how to install, enable and
configure them.
Send comments, suggestions or bug reports to me:
Morten Bo Johansen
mbj at hotmail dot com