line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Org::Element::Setting; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
648
|
use 5.010001; |
|
9
|
|
|
|
|
33
|
|
4
|
9
|
|
|
9
|
|
63
|
use locale; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
57
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
329
|
use Moo; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
59
|
|
7
|
|
|
|
|
|
|
extends 'Org::Element'; |
8
|
|
|
|
|
|
|
with 'Org::ElementRole'; |
9
|
|
|
|
|
|
|
with 'Org::ElementRole::Block'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
12
|
|
|
|
|
|
|
our $DATE = '2023-08-05'; # DATE |
13
|
|
|
|
|
|
|
our $DIST = 'Org-Parser'; # DIST |
14
|
|
|
|
|
|
|
our $VERSION = '0.560'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @known_settings = qw( |
17
|
|
|
|
|
|
|
ARCHIVE |
18
|
|
|
|
|
|
|
ASCII |
19
|
|
|
|
|
|
|
ATTR_ASCII |
20
|
|
|
|
|
|
|
ATTR_BEAMER |
21
|
|
|
|
|
|
|
ATTR_HTML |
22
|
|
|
|
|
|
|
ATTR_LATEX |
23
|
|
|
|
|
|
|
ATTR_ODT |
24
|
|
|
|
|
|
|
AUTHOR |
25
|
|
|
|
|
|
|
BABEL |
26
|
|
|
|
|
|
|
BEAMER |
27
|
|
|
|
|
|
|
BEAMER_COLOR_THEME |
28
|
|
|
|
|
|
|
BEAMER_FONT_THEME |
29
|
|
|
|
|
|
|
BEAMER_INNER_THEME |
30
|
|
|
|
|
|
|
BEAMER_OUTER_THEME |
31
|
|
|
|
|
|
|
BEAMER_THEME |
32
|
|
|
|
|
|
|
BEGIN |
33
|
|
|
|
|
|
|
BEGIN_ASCII |
34
|
|
|
|
|
|
|
BEGIN_BEAMER |
35
|
|
|
|
|
|
|
BEGIN_CENTER |
36
|
|
|
|
|
|
|
BEGIN_COMMENT |
37
|
|
|
|
|
|
|
BEGIN_EXAMPLE |
38
|
|
|
|
|
|
|
BEGIN_HTML |
39
|
|
|
|
|
|
|
BEGIN_LATEX |
40
|
|
|
|
|
|
|
BEGIN_QUOTE |
41
|
|
|
|
|
|
|
BEGIN_SRC |
42
|
|
|
|
|
|
|
BEGIN_SRC |
43
|
|
|
|
|
|
|
BEGIN_VERSE |
44
|
|
|
|
|
|
|
BIND |
45
|
|
|
|
|
|
|
CALL |
46
|
|
|
|
|
|
|
CAPTION |
47
|
|
|
|
|
|
|
CATEGORY |
48
|
|
|
|
|
|
|
COLUMNS |
49
|
|
|
|
|
|
|
CONSTANTS |
50
|
|
|
|
|
|
|
DATE |
51
|
|
|
|
|
|
|
DESCRIPTION |
52
|
|
|
|
|
|
|
DRAWERS |
53
|
|
|
|
|
|
|
EMAIL |
54
|
|
|
|
|
|
|
EXPORT_EXCLUDE_TAGS |
55
|
|
|
|
|
|
|
EXPORT_INCLUDE_TAGS |
56
|
|
|
|
|
|
|
FILETAGS |
57
|
|
|
|
|
|
|
HEADER |
58
|
|
|
|
|
|
|
HEADERS |
59
|
|
|
|
|
|
|
HTML |
60
|
|
|
|
|
|
|
HTML_HEAD |
61
|
|
|
|
|
|
|
HTML_HEAD_EXTRA |
62
|
|
|
|
|
|
|
HTML_INCLUDE_STYLE |
63
|
|
|
|
|
|
|
INCLUDE |
64
|
|
|
|
|
|
|
INDEX |
65
|
|
|
|
|
|
|
INFOJS_OPT |
66
|
|
|
|
|
|
|
KEYWORDS |
67
|
|
|
|
|
|
|
LABEL |
68
|
|
|
|
|
|
|
LANGUAGE |
69
|
|
|
|
|
|
|
LAST_MOBILE_CHANGE |
70
|
|
|
|
|
|
|
LATEX |
71
|
|
|
|
|
|
|
LATEX_CLASS |
72
|
|
|
|
|
|
|
LATEX_CLASS_OPTIONS |
73
|
|
|
|
|
|
|
LATEX_HEADER |
74
|
|
|
|
|
|
|
LATEX_HEADER_EXTRA |
75
|
|
|
|
|
|
|
LINK |
76
|
|
|
|
|
|
|
LINK_HOME |
77
|
|
|
|
|
|
|
LINK_UP |
78
|
|
|
|
|
|
|
MACRO |
79
|
|
|
|
|
|
|
NAME |
80
|
|
|
|
|
|
|
ODT_STYLES_FILE |
81
|
|
|
|
|
|
|
OPTIONS |
82
|
|
|
|
|
|
|
ORGLST |
83
|
|
|
|
|
|
|
ORGTBL |
84
|
|
|
|
|
|
|
PLOT |
85
|
|
|
|
|
|
|
POSTID |
86
|
|
|
|
|
|
|
PRIORITIES |
87
|
|
|
|
|
|
|
PROPERTY |
88
|
|
|
|
|
|
|
RESULTS |
89
|
|
|
|
|
|
|
SEQ_TODO |
90
|
|
|
|
|
|
|
SETUPFILE |
91
|
|
|
|
|
|
|
SRCNAME |
92
|
|
|
|
|
|
|
STARTUP |
93
|
|
|
|
|
|
|
STYLE |
94
|
|
|
|
|
|
|
TAGS |
95
|
|
|
|
|
|
|
TBLFM |
96
|
|
|
|
|
|
|
TEXT |
97
|
|
|
|
|
|
|
TITLE |
98
|
|
|
|
|
|
|
TOC |
99
|
|
|
|
|
|
|
TODO |
100
|
|
|
|
|
|
|
TYP_TODO |
101
|
|
|
|
|
|
|
XSLT |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has name => (is => 'rw'); |
105
|
|
|
|
|
|
|
has raw_arg => (is => 'ro'); |
106
|
|
|
|
|
|
|
has args => (is => 'rw'); |
107
|
|
|
|
|
|
|
has indent => (is => 'rw'); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# static method |
110
|
|
|
|
|
|
|
sub indentable_settings { |
111
|
8
|
|
|
8
|
1
|
14
|
state $data = [qw/TBLFM/]; |
112
|
8
|
|
|
|
|
19
|
$data; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub BUILD { |
116
|
54
|
|
|
54
|
0
|
17717
|
require Org::Document; |
117
|
54
|
|
|
|
|
119
|
my ($self, $build_args) = @_; |
118
|
54
|
|
|
|
|
158
|
my $doc = $self->document; |
119
|
54
|
|
50
|
|
|
147
|
my $pass = $build_args->{pass} // 1; |
120
|
|
|
|
|
|
|
|
121
|
54
|
|
|
|
|
133
|
my $name = uc $self->name; |
122
|
54
|
|
|
|
|
138
|
$self->name($name); |
123
|
|
|
|
|
|
|
|
124
|
54
|
|
|
|
|
103
|
my $args = $self->args; |
125
|
54
|
100
|
|
|
|
315
|
if ($name eq 'DRAWERS') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
126
|
2
|
100
|
|
|
|
9
|
if ($pass == 1) { |
127
|
1
|
|
|
|
|
3
|
for my $arg (@$args) { |
128
|
2
|
|
|
|
|
10
|
push @{ $doc->drawer_names }, $arg |
129
|
2
|
50
|
|
|
|
3
|
unless grep { $_ eq $arg } @{ $doc->drawer_names }; |
|
7
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
6
|
|
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} elsif ($name eq 'FILETAGS') { |
133
|
5
|
100
|
|
|
|
23
|
if ($pass == 1) { |
134
|
9
|
|
|
9
|
|
6549
|
no warnings 'once'; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
6322
|
|
135
|
3
|
100
|
|
|
|
185
|
$args->[0] =~ /^$Org::Document::tags_re$/ or |
136
|
|
|
|
|
|
|
$self->die("Invalid argument for FILETAGS: $args->[0]"); |
137
|
2
|
|
|
|
|
12
|
for my $tag (split /:/, $args->[0]) { |
138
|
7
|
100
|
|
|
|
18
|
next unless length $tag; |
139
|
5
|
|
|
|
|
33
|
push @{ $doc->tags }, $tag |
140
|
5
|
50
|
|
|
|
10
|
unless grep { $_ eq $tag } @{ $doc->tags }; |
|
4
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
15
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} elsif ($name eq 'PRIORITIES') { |
144
|
8
|
100
|
|
|
|
36
|
if ($pass == 1) { |
145
|
4
|
|
|
|
|
11
|
for (@$args) { |
146
|
17
|
|
|
|
|
27
|
push @{ $doc->priorities }, $_; |
|
17
|
|
|
|
|
59
|
|
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} elsif ($name eq 'PROPERTY') { |
150
|
4
|
100
|
|
|
|
17
|
if ($pass == 1) { |
151
|
2
|
50
|
|
|
|
4
|
@$args >= 2 or $self->die("Not enough argument for PROPERTY, minimum 2"); |
152
|
2
|
|
|
|
|
4
|
my $name = shift @$args; |
153
|
2
|
50
|
|
|
|
19
|
$doc->properties->{$name} = @$args > 1 ? [@$args] : $args->[0]; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} elsif ($name =~ /^(SEQ_TODO|TODO|TYP_TODO)$/) { |
156
|
26
|
100
|
|
|
|
124
|
if ($pass == 1) { |
157
|
13
|
|
|
|
|
19
|
my $done; |
158
|
13
|
|
|
|
|
40
|
for (my $i=0; $i<@$args; $i++) { |
159
|
50
|
|
|
|
|
85
|
my $arg = $args->[$i]; |
160
|
50
|
100
|
|
|
|
157
|
if ($arg eq '|') { $done++; next } |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
42
|
|
161
|
38
|
100
|
66
|
|
|
148
|
$done++ if !$done && @$args > 1 && $i == @$args-1; |
|
|
|
100
|
|
|
|
|
162
|
38
|
100
|
|
|
|
98
|
my $ary = $done ? $doc->done_states : $doc->todo_states; |
163
|
38
|
50
|
|
|
|
193
|
push @$ary, $arg unless grep { $_ eq $arg } @$ary; |
|
18
|
|
|
|
|
101
|
|
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} else { |
167
|
9
|
50
|
|
|
|
33
|
unless ($self->document->ignore_unknown_settings) { |
168
|
9
|
100
|
|
|
|
19
|
$self->die("Unknown setting $name") unless grep { $_ eq $name } @known_settings; |
|
765
|
|
|
|
|
1136
|
|
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub as_string { |
174
|
2
|
|
|
2
|
1
|
4
|
my ($self) = @_; |
175
|
|
|
|
|
|
|
join("", |
176
|
|
|
|
|
|
|
$self->indent // "", |
177
|
|
|
|
|
|
|
"#+".uc($self->name), ":", |
178
|
2
|
50
|
50
|
|
|
15
|
$self->args && @{$self->args} ? |
|
|
|
33
|
|
|
|
|
179
|
|
|
|
|
|
|
" ".Org::Document::__format_args($self->args) : "", |
180
|
|
|
|
|
|
|
"\n" |
181
|
|
|
|
|
|
|
); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |
185
|
|
|
|
|
|
|
# ABSTRACT: Represent Org in-buffer settings |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=pod |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=encoding UTF-8 |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 NAME |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Org::Element::Setting - Represent Org in-buffer settings |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 VERSION |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This document describes version 0.560 of Org::Element::Setting (from Perl distribution Org-Parser), released on 2023-08-05. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 DESCRIPTION |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Derived from L<Org::Element>. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=for Pod::Coverage as_string BUILD |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 name => STR |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Setting name. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 raw_arg => ARRAY |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
String, read-only (can only be set during instantiation). Setting's raw |
216
|
|
|
|
|
|
|
arguments. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head2 args => ARRAY |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Setting's arguments. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head2 indent => STR |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Indentation (whitespaces before C<#+>), or empty string if none. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 METHODS |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 Org::Element::Setting->indentable_settings -> ARRAY |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Return an arrayref containing the setting names that can be indented. In Org, |
231
|
|
|
|
|
|
|
some settings can be indented and some can't. Setting names are all in |
232
|
|
|
|
|
|
|
uppercase. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 HOMEPAGE |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Org-Parser>. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 SOURCE |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Org-Parser>. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 AUTHOR |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
To contribute, you can send patches by email/via RT, or send pull requests on |
250
|
|
|
|
|
|
|
GitHub. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Most of the time, you don't need to build the distribution yourself. You can |
253
|
|
|
|
|
|
|
simply modify the code, then test via: |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
% prove -l |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
If you want to build the distribution (e.g. to try to install it locally on your |
258
|
|
|
|
|
|
|
system), you can install L<Dist::Zilla>, |
259
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, |
260
|
|
|
|
|
|
|
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other |
261
|
|
|
|
|
|
|
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond |
262
|
|
|
|
|
|
|
that are considered a bug and can be reported to me. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar <perlancar@cpan.org>. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
269
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 BUGS |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Org-Parser> |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
276
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
277
|
|
|
|
|
|
|
feature. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=cut |