[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#4341: 23.1; M-x locate runs synchronously
From: |
Juri Linkov |
Subject: |
bug#4341: 23.1; M-x locate runs synchronously |
Date: |
Sun, 15 Nov 2020 22:20:05 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> Maybe this would be an improvement. But sorry, I can't help in testing:
>> while slow `M-x locate' used to be a problem in the past, nowadays it
>> finishes within 1 sec, so I simply won't notice the difference :-)
>
> FWIW, here it takes much longer than that. It would be very welcome if
> someone would want to work on making it asynchronous.
What I can do to help is to post my current customization:
* Highlight all matches in the =*Locate*= buffer like in the =*Occur*= buffer:
#+begin_src emacs-lisp
(add-hook 'locate-post-command-hook
(lambda ()
(save-excursion
(goto-char (point-min))
(when (or (re-search-forward "Matches for .* using filter
\\(.*\\):" nil t)
(re-search-forward "Matches for \\(.*\\):" nil t))
(highlight-regexp
(match-string-no-properties 1)
'match)))))
#+end_src
* Ignore case in locate command
#+begin_src emacs-lisp
(with-eval-after-load 'locate
;; Redefine ‘locate-default-make-command-line’.
(defun locate-make-command-line-ignore-case (search-string)
(list locate-command "-i" search-string))
(setq locate-make-command-line 'locate-make-command-line-ignore-case))
#+end_src
With this I see no problems with adding a new option to use ls with switches
as demonstrated by this code:
#+begin_src emacs-lisp
(defun locate-make-command-line-ls (search-string)
(list shell-file-name
shell-command-switch
(format "%s %s %s | xargs ls -ls" locate-command "-i" search-string) ))
(setq locate-make-command-line 'locate-make-command-line-ls)
#+end_src
Then it's possible to enable 'dired-virtual-mode' in the output buffer
in 'locate-post-command-hook'.
Or maybe locate.el should be obsoleted, and a new option to run 'locate'
should be added to find-dired.el?