File: vimplate_listtemplates.diff

package info (click to toggle)
vim-scripts 20210124.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,384 kB
  • sloc: perl: 420; xml: 95; makefile: 25
file content (52 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download
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
Subject: Fix warnings if no template directory exists
Forwarded: no
Author: James McCoy <jamessan@debian.org>
Bug-Debian: https://bugs.debian.org/1086943
---
diff --git i/vimplate/bin/vimplate w/vimplate/bin/vimplate
index 563972d..bffa9a3 100755
--- i/vimplate/bin/vimplate
+++ w/vimplate/bin/vimplate
@@ -206,6 +206,16 @@ if ( defined $opt{createconfig} ) {
   }
 }
 
+=item B<-dir|d=<templatedir>>
+
+Search templatefiles in <templatedir>.
+
+=cut
+
+if ( defined $opt{dir} ) {
+  $Config::opt->{dir}=$opt{dir}
+}
+
 =item B<-listtemplate>
 
 Print the avaible templates and exit.
@@ -213,7 +223,7 @@ Print the avaible templates and exit.
 =cut
 
 sub listTemplates {
-  opendir(DIR, $Config::opt->{dir});
+  return unless exists $Config::opt->{dir} and opendir(DIR, $Config::opt->{dir});
   my ($file, @files);
   FILE: foreach $file (readdir(DIR)) {
     next FILE if ($file!~/\.tt$/);
@@ -252,16 +262,6 @@ if ( defined $opt{user} ) {
   $Config::opt->{user}=$opt{user}
 }
 
-=item B<-dir|d=<templatedir>>
-
-Search templatefiles in <templatedir>.
-
-=cut
-
-if ( defined $opt{dir} ) {
-  $Config::opt->{dir}=$opt{dir}
-}
-
 =item B<-template=<templatefile>>
 
 Use the <templatefile>.