bugranger - Bugs: bug #35628, filter command, case insensitive

 
 

bug #35628: filter command, case insensitive

Submitted by:  None
Submitted on:  Sun 26 Feb 2012 05:12:40 PM UTC  
 
Severity: 3 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 02 Mar 2012 01:03:41 AM UTC, comment #2:

Again, with correct indentation:

The :filter command is subject to change. For now, here is what you can put in your commands.py to get a case-insensitive :filter_i command:

Roman Z. <hut>
Project Administrator
Fri 02 Mar 2012 12:58:26 AM UTC, comment #1:

The :filter command is subject to change. For now, here is what you can put in your commands.py to get a case-insensitive :filter_i command:

# ~/.config/ranger/commands.py
from ranger.api.commands import *
import ranger.fsobject.directory

original_accept_file = ranger.fsobject.directory.accept_file

# this was copy&pasted from ranger/fsobject/directory.py and modified
# to make filters case insensitive
def insensitive_accept_file(fname, dirname, hidden_filter, name_filter):
if hidden_filter:
try:
if hidden_filter.search(fname):
return False
except:
if hidden_filter in fname:
return False
if name_filter and name_filter.lower() not in fname.lower():
return False
return True

class filter(Command):
def execute(self):
ranger.fsobject.directory.accept_file = original_accept_file
self.fm.set_filter(self.rest(1))
self.fm.reload_cwd()

class filter_i(Command):
def execute(self):
ranger.fsobject.directory.accept_file = insensitive_accept_file
self.fm.set_filter(self.rest(1))
self.fm.reload_cwd()

Roman Z. <hut>
Project Administrator
Sun 26 Feb 2012 05:12:40 PM UTC, original submission:

It would be nice if the filter command could do the search case-insensitive.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by hut (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 02 Mar 2012 01:03:41 AM UTChutOpen/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1