File: faq-macros.xml

package info (click to toggle)
jedit 5.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,252 kB
  • ctags: 11,190
  • sloc: java: 98,480; xml: 94,070; makefile: 52; sh: 42; cpp: 6; python: 6
file content (127 lines) | stat: -rw-r--r-- 6,393 bytes parent folder | download | duplicates (4)
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
<?xml version="1.0" encoding="UTF-8"?>
<section id="macros">
    <title>Macros</title>
    <!-- jEdit buffer-local properties:                      -->
    <!-- :indentSize=2:noTabs=false:maxLineLen=90:tabSize=2: -->
    <!-- :xml.root=faq.xml:                                  -->
    <!-- jEdit FAQ                                           -->
    <para>This section deals with questions on writing and running
    macros.</para>

    <qandaset defaultlabel="qanda">
        <qandadiv id="macro-using">
            <title>Using macros</title>

            <qandaentry>
                <question id="macro-getting">
                    <para>Where can I get macros from?</para>
                </question>

                <answer>
                    <para>There is a plugin available called MacroManager that
                    will provide a similar interface to jEdit's plugin manager
                    for installing new macros. The plugin downloads the macros
                    from the jEdit Community site, so an internet connection is
                    necessary. </para>
                </answer>
            </qandaentry>

            <qandaentry>
                <question id="macro-new-store">
                    <para>I just wrote a new macro for myself. Where should I
                    save the file?</para>
                </question>

                <answer>
                    <para>There is a <filename>macros</filename> directory in
                    your user settings directory. If you store your macro there
                    it will appear in jEdit's <guimenu>Macros</guimenu> menu
                    under the name you have given to the macro's source code
                    file. The <filename>.bsh</filename> will be deleted in the
                    macro entry, and underscore characters will be converted to
                    whitespace, so that the file
                    <filename>My_New_Macro.bsh</filename> will be displayed as
                    <guimenuitem>My New Macro</guimenuitem>.</para>

                    <para>You can create additional subdirectories in the
                    <filename>macros</filename>to organize your personal macros
                    by category. Each subdirectory will correspond to a submenu
                    under the application's <guimenu>Macros</guimenu> menu. This
                    is helpful to reduce the screen space used to display the
                    macros menu at any one time.</para>
                </answer>
            </qandaentry>

            <qandaentry>
                <question id="macro-new-ext">
                    <para>Do I have to use the <filename>.bsh</filename> file
                    extension when I save one of my own macro scripts?</para>
                </question>

                <answer>
                    <para>You need the <filename>.bsh</filename> extension in
                    order for jEdit to detect and display the name of the macro
                    in its <guimenu>Macros</guimenu> menu. The macro must also
                    be in the <filename>macros</filename> directory of either
                    the jEdit installation directory or the user settings
                    directory.</para>

                    <para>You do not need the extension to run a macro, however.
                    By selecting <guimenu>Macros</guimenu>&gt;<guimenuitem>Run
                    Other Macro...</guimenuitem>, you can choose any file to be
                    run as a macro. While in a macro, you can call
                    <userinput>source("full_path")</userinput> to do the same
                    thing.</para>
                </answer>
            </qandaentry>

            <qandaentry>
                <question id="macro-temp">
                    <para>How can I store the result of a macro so that the next
                    time I run it the macro can retrieve the value?</para>
                </question>

                <answer>
                    <para>You can use either
                    <userinput>jEdit.setProperty(String, String)</userinput> or
                    <userinput>jEdit.setTemporaryProperty(String,
                    String)</userinput>. Both methods take
                    <classname>String</classname> values for the name of the
                    property and its value. If you use
                    <userinput>setProperty()</userinput>, the property will
                    remain in jEdit's property store permanently, so if you only
                    need the value during the course of a single editing
                    session, use
                    <userinput>setTemporaryProperty()</userinput>.</para>

                    <para>To ensure that your value can be stored regardless of
                    its type, use the following syntax:<programlisting>jEdit.setTemporaryProperty("myValueName", myValue.toString());</programlisting>
                    and remember to convert the <quote>myValueName</quote>
                    property back to its intended type when you retrieve
                    it.</para>
                </answer>
            </qandaentry>

            <qandaentry>
                <question id="macro-exec">
                    <para>In a macro I'd like to exec an external program (e.g.
                    jmk, javac) and capture its output to a buffer. I'd also
                    like to see this output as the external program runs or be
                    able to interact with the program. So when I exec, what
                    happens to System.in/out/err of the exec'd program?</para>
                </question>

                <answer>
                    <para>Use the <filename>runInSystemShell()</filename> or the
                    <filename>runCommandToBuffer()</filename> script methods
                    that come bundled with the Console plugin. The help
                    documentation for Console provides details on these methods.
                    Currently the Console's System shell is not interactive
                    during execution of a command, but it does receive and
                    display the standard output and error streams of the
                    external process.</para>
                </answer>
            </qandaentry>
        </qandadiv>
    </qandaset>
</section>