##// END OF EJS Templates
configitems: register the 'pager.attend' config
Boris Feld -
r34496:6d1b0970 default
parent child Browse files
Show More
@@ -1,73 +1,81 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 of the
6 6 # GNU General Public License version 2 or any later version.
7 7 #
8 8 # To load the extension, add it to your configuration file:
9 9 #
10 10 # [extension]
11 11 # pager =
12 12 #
13 13 # Run 'hg help pager' to get info on configuration.
14 14
15 15 '''browse command output with an external pager (DEPRECATED)
16 16
17 17 Forcibly enable paging for individual commands that don't typically
18 18 request pagination with the attend-<command> option. This setting
19 19 takes precedence over ignore options and defaults::
20 20
21 21 [pager]
22 22 attend-cat = false
23 23 '''
24 24 from __future__ import absolute_import
25 25
26 26 from mercurial import (
27 27 cmdutil,
28 28 commands,
29 29 dispatch,
30 30 extensions,
31 registrar,
31 32 )
32 33
33 34 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
34 35 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
35 36 # be specifying the version(s) of Mercurial they are tested with, or
36 37 # leave the attribute unspecified.
37 38 testedwith = 'ships-with-hg-core'
38 39
40 configtable = {}
41 configitem = registrar.configitem(configtable)
42
43 configitem('pager', 'attend',
44 default=lambda: attended,
45 )
46
39 47 def uisetup(ui):
40 48
41 49 def pagecmd(orig, ui, options, cmd, cmdfunc):
42 50 auto = options['pager'] == 'auto'
43 51 if auto and not ui.pageractive:
44 52 usepager = False
45 attend = ui.configlist('pager', 'attend', attended)
53 attend = ui.configlist('pager', 'attend')
46 54 ignore = ui.configlist('pager', 'ignore')
47 55 cmds, _ = cmdutil.findcmd(cmd, commands.table)
48 56
49 57 for cmd in cmds:
50 58 var = 'attend-%s' % cmd
51 59 if ui.config('pager', var):
52 60 usepager = ui.configbool('pager', var)
53 61 break
54 62 if (cmd in attend or
55 63 (cmd not in ignore and not attend)):
56 64 usepager = True
57 65 break
58 66
59 67 if usepager:
60 68 # Slight hack: the attend list is supposed to override
61 69 # the ignore list for the pager extension, but the
62 70 # core code doesn't know about attend, so we have to
63 71 # lobotomize the ignore list so that the extension's
64 72 # behavior is preserved.
65 73 ui.setconfig('pager', 'ignore', '', 'pager')
66 74 ui.pager('extension-via-attend-' + cmd)
67 75 else:
68 76 ui.disablepager()
69 77 return orig(ui, options, cmd, cmdfunc)
70 78
71 79 extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
72 80
73 81 attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
General Comments 0
You need to be logged in to leave comments. Login now