thierryvolpiatto / isearch-light

A simple Isearch replacement for Emacs.
13 stars 0 forks source link

Support for searching filenames only in Dirvish (do not search text hidden by overlays) #3

Closed mgraham closed 5 months ago

mgraham commented 5 months ago

Hi! I think isearch-light is a great search package - it's simple, supports highlighting, status, has sensible defaults and a good UI. And it supports iedit.

I use https://github.com/alexluigit/dirvish for my file manager, which is based on dired. Dirvish uses overlays to hide a lot of the details in each line of the dirvish window. Typicaly, only the file name, the file time and the file size are visible.

When I use isearch in a dirvish-mode buffer, it searches the filenames only.

When I try using ISL in a dirvish-mode buffer, it searches all of the the invisible text as well (including mode, user, group, etc.)

I was wondering if there was a way to get ISL to only search filenames in a dirvish-mode buffer?

I am happy to help if you have ideas of how it could be accomplished.

thierryvolpiatto commented 5 months ago

Hi Michael!

Michael Graham @.***> writes:

Hi! I think isearch-light is a great search package - it's simple, supports highlighting, status, has sensible defaults and a good UI. And it supports iedit.

Glad you like it.

I use https://github.com/alexluigit/dirvish for my file manager, which is based on dired. Dirvish uses overlays to hide a lot of the details in each line of the dirvish window. Typicaly, only the file name, the file time and the file size are visible.

When I use isearch in a dirvish-mode buffer, it searches the filenames only.

When I try using ISL in a dirvish-mode buffer, it searches all of the the invisible text as well (including mode, user, group, etc.)

I was wondering if there was a way to get ISL to only search filenames in a dirvish-mode buffer?

Unfortunately I am unable to make dirvish working properly here, so I couldn't try isl in dirvish, however I quickly tried to make isl ignoring invisible text, it works in org buffers, here the patch, change the value of isl-search-invisible as needed and let me know if it works in your dirvish buffers. If so we will decide how and when to toggle this value (depending the mode in use, user toggle it manually etc...).

diff --git a/isl.el b/isl.el index 82f948a..a78dba6 100644 --- a/isl.el +++ b/isl.el @@ -784,6 +784,8 @@ symbol or line position according to `isl-multi-search-in-line'." (not (member (replace-regexp-in-string "\s\ " " " str) isl-update-blacklist-regexps))))

+(defvar isl-search-invisible t) + (defun isl-update () "Update current-buffer' whenisl-pattern' changes." (with-selected-window (minibuffer-selected-window) @@ -799,7 +801,8 @@ symbol or line position according to `isl-multi-search-in-line'." ;; all buffer and on exit restore it and unhide only the place ;; where point is with appropriate functions belonging to ;; major-mode e.g. org => org-reveal etc...

Thanks.

-- Thierry

thierryvolpiatto commented 5 months ago

Now installed on master. 1) You can now toggle invisible search with M-i 2) You can add your modes to isl-no-invisible-search-modes to disable searching in invisible text by default in these modes.

I couldn't test on dirvish, it is not working here I have errors as soon as I M-x dirvish. So I tested in org-mode and in dired with details turned off (I guess it should be more or less like dirvish) and it is working fine.

mgraham commented 5 months ago

Wow - that was fast! This works great! Thank you so much!

Moving through matches with <up>/<down>/<home>/<end> while the search is still active is a very elegant UI and it works particularly well for directory listings.

My config:

(use-package isl
    :straight (open-github :type git :host github :repo "thierryvolpiatto/isearch-light"))

(add-to-list 'isl-no-invisible-search-in-modes 'dired-mode)

(general-define-key
 :keymaps 'isl-map
 "C-a" 'isl-goto-first
 "C-e" 'isl-goto-last
 "<prior>" 'isl-scroll-up
 "<next>" 'isl-scroll-down
)
thierryvolpiatto commented 5 months ago

Thanks to confirm it works, closing now.