Hi,
At Fri, 29 Sep 2006 17:19:42 +0900,
Vincent Fourmond wrote in [ruby-talk:217143]:
>> ril () {
>> ri -T -f ansi "$@" | less -r
>> }
>>
>
> Why not just set the RI and PAGER environment variables?
That's a good point, but you don't always want less to have the -r
option, don't you ?
Why doesn't ri have --pager option?
Index: lib/rdoc/ri/ri_display.rb
路路路
===================================================================
RCS file: /pub/cvs/ruby/lib/rdoc/ri/ri_display.rb,v
retrieving revision 1.6
diff -U 2 -p -r1.6 ri_display.rb
--- lib/rdoc/ri/ri_display.rb 24 Mar 2004 19:17:13 -0000 1.6
+++ lib/rdoc/ri/ri_display.rb 29 Sep 2006 10:41:04 -0000
@@ -210,9 +210,14 @@ class DefaultDisplay
def setup_pager
- unless @options.use_stdout
- for pager in [ ENV['PAGER'], "less", "more", 'pager' ].compact.uniq
+ if pager = @options.pager
+ pagers =
+ pagers << pager unless pager == true
+ pagers << pager if pager = ENV['PAGER']
+ pagers.concat(%w"less more pager")
+ pagers.uniq!
+ pagers.each do |pager|
return IO.popen(pager, "w") rescue nil
end
- @options.use_stdout = true
+ @options.pager = false
nil
end
Index: lib/rdoc/ri/ri_options.rb
RCS file: /pub/cvs/ruby/lib/rdoc/ri/ri_options.rb,v
retrieving revision 1.17
diff -U 2 -p -r1.17 ri_options.rb
--- lib/rdoc/ri/ri_options.rb 22 Sep 2006 23:39:10 -0000 1.17
+++ lib/rdoc/ri/ri_options.rb 29 Sep 2006 10:34:20 -0000
@@ -6,4 +6,5 @@ module RI
require 'rdoc/ri/ri_paths'
require 'rdoc/ri/ri_display'
+ require 'rdoc/ri/ri_paths'
VERSION_STRING = "ri v1.0.1 - 20041108"
@@ -16,7 +17,7 @@ module RI
include Singleton
- # No not use a pager. Writable, because ri sets it if it
+ # Pager to use. Writable, because ri sets it if it
# can't find a pager
- attr_accessor :use_stdout
+ attr_accessor :pager
# should we just display a class list and exit
@@ -64,5 +65,5 @@ module RI
[ "--gems", nil, nil,
"Include documentation from Rubygems:\n " +
- (RI::Paths::GEMDIRS ? "#{Gem.path}/doc/*/ri" :
+ (RI::Paths::GEMDIRS ? "#{::Gem.path}/doc/*/ri" :
"No Rubygems ri found.") ],
@@ -79,4 +80,8 @@ module RI
],
+ [ "--pager", "-P", "pager",
+ "Send output to the command to pagenate"
+ ],
+
[ "--no-pager", "-T", nil,
"Send output directly to stdout."
@@ -218,5 +223,5 @@ module RI
def initialize
- @use_stdout = !STDOUT.tty?
+ @pager = STDOUT.tty?
@width = 72
@formatter = RI::TextFormatter.for("plain")
@@ -251,5 +256,6 @@ module RI
when "--version" then show_version
when "--list-names" then @list_names = true
- when "--no-pager" then @use_stdout = true
+ when "--pager" then @pager = arg
+ when "--no-pager" then @pager = false
when "--classes" then @list_classes = true
Index: lib/rdoc/ri/ri_paths.rb
RCS file: /pub/cvs/ruby/lib/rdoc/ri/ri_paths.rb,v
retrieving revision 1.7
diff -U 2 -p -r1.7 ri_paths.rb
--- lib/rdoc/ri/ri_paths.rb 26 Jun 2006 18:10:30 -0000 1.7
+++ lib/rdoc/ri/ri_paths.rb 19 Sep 2006 06:02:58 -0000
@@ -45,6 +45,7 @@ module RI
begin
require 'rubygems'
- GEMDIRS = Dir["#{Gem.path}/doc/*/ri"]
- GEMDIRS.each { |path| RI::Paths::PATH << path }
+ if GEMDIRS = (Dir["#{::Gem.path}/doc/*/ri"] if defined?(::Gem.path))
+ PATH.concat(GEMDIRS)
+ end
rescue LoadError
GEMDIRS = nil
--
Nobu Nakada