##// END OF EJS Templates
pager: add global --pager=<auto/boolean> option
Brodie Rao -
r12694:04f6de46 default
parent child Browse files
Show More
@@ -47,10 +47,15 b' If pager.attend is present, pager.ignore'
47
47
48 To ignore global commands like :hg:`version` or :hg:`help`, you have
48 To ignore global commands like :hg:`version` or :hg:`help`, you have
49 to specify them in your user configuration file.
49 to specify them in your user configuration file.
50
51 The --pager=... option can also be used to control when the pager is
52 used. Use a boolean value like yes, no, on, off, or use auto for
53 normal behavior.
50 '''
54 '''
51
55
52 import sys, os, signal, shlex, errno
56 import sys, os, signal, shlex, errno
53 from mercurial import dispatch, util, extensions
57 from mercurial import commands, dispatch, util, extensions
58 from mercurial.i18n import _
54
59
55 def _runpager(p):
60 def _runpager(p):
56 if not hasattr(os, 'fork'):
61 if not hasattr(os, 'fork'):
@@ -85,8 +90,11 b' def uisetup(ui):'
85 p = ui.config("pager", "pager", os.environ.get("PAGER"))
90 p = ui.config("pager", "pager", os.environ.get("PAGER"))
86 if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
91 if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
87 attend = ui.configlist('pager', 'attend', attended)
92 attend = ui.configlist('pager', 'attend', attended)
88 if (cmd in attend or
93 auto = options['pager'] == 'auto'
89 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
94 always = util.parsebool(options['pager'])
95 if (always or auto and
96 (cmd in attend or
97 (cmd not in ui.configlist('pager', 'ignore') and not attend))):
90 ui.setconfig('ui', 'formatted', ui.formatted())
98 ui.setconfig('ui', 'formatted', ui.formatted())
91 ui.setconfig('ui', 'interactive', False)
99 ui.setconfig('ui', 'interactive', False)
92 _runpager(p)
100 _runpager(p)
@@ -96,4 +104,10 b' def uisetup(ui):'
96
104
97 extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
105 extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
98
106
107 def extsetup(ui):
108 commands.globalopts.append(
109 ('', 'pager', 'auto',
110 _("when to paginate (boolean, always, auto, or never)"),
111 _('TYPE')))
112
99 attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
113 attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
General Comments 0
You need to be logged in to leave comments. Login now