From 4217d4e6cfa5ea877b8e29e5dbb9b3f933409721 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 11 Apr 2014 15:56:50 +0200 Subject: Add setting "automatically_count_files" --- doc/ranger.1 | 8 +++++++- doc/ranger.pod | 7 +++++++ doc/rifle.1 | 2 +- ranger/config/rc.conf | 3 +++ ranger/container/directory.py | 10 ++++++++-- ranger/container/settings.py | 1 + 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 03687636..a3c92128 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.6.1" "06/21/2013" "ranger manual" +.TH RANGER 1 "ranger-1.6.1" "04/11/2014" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -559,6 +559,12 @@ The different types of settings and an example for each type: .PP You can view a list of all settings and their current values by pressing \*(L"3?\*(R" in ranger. +.IP "automatically_count_files [bool]" 4 +.IX Item "automatically_count_files [bool]" +Should ranger count and display the number of files in each directory +as soon as it's visible? This gets slow with remote file sytems. Turning it +off will still allow you to see the number of files after entering the +directory. .IP "autosave_bookmarks [bool]" 4 .IX Item "autosave_bookmarks [bool]" Save bookmarks (used with mX and `X) instantly? This helps to synchronize diff --git a/doc/ranger.pod b/doc/ranger.pod index b48cdcf7..7dc50d32 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -517,6 +517,13 @@ in ranger. =over +=item automatically_count_files [bool] + +Should ranger count and display the number of files in each directory +as soon as it's visible? This gets slow with remote file sytems. Turning it +off will still allow you to see the number of files after entering the +directory. + =item autosave_bookmarks [bool] Save bookmarks (used with mX and `X) instantly? This helps to synchronize diff --git a/doc/rifle.1 b/doc/rifle.1 index 6395a34d..df63d118 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.6.1" "06/21/2013" "rifle manual" +.TH RIFLE 1 "rifle-1.6.1" "04/11/2014" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index e5d68926..7487e8be 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -41,6 +41,9 @@ set preview_script ~/.config/ranger/scope.sh # Use the external preview script or display simple plain text or image previews? set use_preview_script true +# Automatically count files in the directory, even before entering them? +set automatically_count_files false + # Open all images in this directory when running certain image viewers # like feh or sxiv? You can still open selected files by marking them. set open_all_images true diff --git a/ranger/container/directory.py b/ranger/container/directory.py index b63907db..136cc8ac 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -395,14 +395,20 @@ class Directory(FileSystemObject, Accumulator, Loadable): @lazy_property def size(self): try: - size = len(os.listdir(self.path)) # bite me + if self.fm.settings.automatically_count_files: + size = len(os.listdir(self.path)) + else: + size = None except OSError: self.infostring = BAD_INFO self.accessible = False self.runnable = False return 0 else: - self.infostring = ' %d' % size + if size is None: + self.infostring = '' + else: + self.infostring = ' %d' % size self.accessible = True self.runnable = True return size diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 44bd60e0..90b6f7ce 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -9,6 +9,7 @@ import re import os.path ALLOWED_SETTINGS = { + 'automatically_count_files': bool, 'autosave_bookmarks': bool, 'autoupdate_cumulative_size': bool, 'cd_bookmarks': bool, -- cgit 1.4.1-2-gfad0