##// END OF EJS Templates
pager: further simplify code, clean up comments
Matt Mackall -
r6324:ee1077b4 default
parent child Browse files
Show More
@@ -1,54 +1,35 b''
1 1 # pager.py - display output using a pager
2 2 #
3 3 # Copyright 2008 David Soria Parra <dsp@php.net>
4 4 #
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7 #
8 # To load the extension add it to your .hgrc file
8 # To load the extension, add it to your .hgrc file:
9 9 #
10 10 # [extension]
11 11 # hgext.pager =
12 12 #
13 # To set the pager that should be used, set the application variable
14 #
15 # [pager]
16 # application = less
17 #
18 # You can also set environment variables there
13 # To set the pager that should be used, set the application variable:
19 14 #
20 15 # [pager]
21 # application = LESS='FSRX' less
16 # pager = LESS='FSRX' less
22 17 #
23 # If no application is set, the pager extensions use the environment
24 # variable $PAGER. If neither pager.application, nor
25 # $PAGER is set, no pager is used.
18 # If no pager is set, the pager extensions uses the environment
19 # variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager
20 # is used.
26 21 #
27 22 # If you notice "BROKEN PIPE" error messages, you can disable them
28 # by setting
23 # by setting:
29 24 #
30 # [pager]
31 # quiet = True
32 #
25 # [pager]
26 # quiet = True
33 27
34 28 import sys, os, signal
35 29
36 def getpager(ui):
37 '''return a pager
38
39 We separate this method from the pager class as we don't want to
40 instantiate a pager if it is not used at all
41 '''
42 if sys.stdout.isatty():
43 return (ui.config("pager", "application")
44 or os.environ.get("PAGER"))
45
46 30 def uisetup(ui):
47 # disable broken pipe error messages
48 if ui.configbool('pager', 'quiet', False):
49 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
50
51 if getpager(ui):
52 pager = os.popen(getpager(ui), 'wb')
53 sys.stderr = pager
54 sys.stdout = pager
31 p = ui.config("pager", "pager", os.environ.get("PAGER"))
32 if p and sys.stdout.isatty():
33 if ui.configbool('pager', 'quiet'):
34 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
35 sys.stderr = sys.stdout = os.popen(p, "wb")
General Comments 0
You need to be logged in to leave comments. Login now