##// END OF EJS Templates
rcutil: add a method to convert environment variables to config items...
Jun Wu -
r31684:0be96ac9 default
parent child Browse files
Show More
@@ -32,6 +32,28 b' def _expandrcpath(path):'
32 return [join(p, f) for f, k in osutil.listdir(p) if f.endswith('.rc')]
32 return [join(p, f) for f, k in osutil.listdir(p) if f.endswith('.rc')]
33 return [p]
33 return [p]
34
34
35 def envrcitems(env=None):
36 '''Return [(section, name, value, source)] config items.
37
38 The config items are extracted from environment variables specified by env,
39 used to override systemrc, but not userrc.
40
41 If env is not provided, encoding.environ will be used.
42 '''
43 if env is None:
44 env = encoding.environ
45 checklist = [
46 ('EDITOR', 'ui', 'editor'),
47 ('VISUAL', 'ui', 'editor'),
48 ('PAGER', 'pager', 'pager'),
49 ]
50 result = []
51 for envname, section, configname in checklist:
52 if envname not in env:
53 continue
54 result.append((section, configname, env[envname], '$%s' % envname))
55 return result
56
35 def defaultrcpath():
57 def defaultrcpath():
36 '''return rc paths in default.d'''
58 '''return rc paths in default.d'''
37 path = []
59 path = []
General Comments 0
You need to be logged in to leave comments. Login now