[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-hydra c76d797 370/395: Clean up some stuff around c
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-hydra c76d797 370/395: Clean up some stuff around counsel-locate |
Date: |
Thu, 25 Feb 2021 08:32:40 -0500 (EST) |
branch: externals/ivy-hydra
commit c76d79715f8bb3dd6308e4d2538c8fde149d28d4
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Clean up some stuff around counsel-locate
* counsel.el (counsel-require-program): Simplify and correct with
string-prefix-p.
(counsel-locate-cmd): Allow custom function values.
(counsel-locate-cmd-default, counsel-locate-cmd-noregex)
(counsel-locate-cmd-mdfind): Use shell-quote-argument.
(counsel-locate-cmd-es): Localize defvar declaration.
(counsel-locate-function, counsel-locate): Clarify docstring.
(counsel-file-stale-p): Simplify.
Re: #2766.
---
counsel.el | 50 ++++++++++++++++++++++++--------------------------
1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/counsel.el b/counsel.el
index 51c283e..5094be2 100644
--- a/counsel.el
+++ b/counsel.el
@@ -126,7 +126,7 @@ complex regexes."
"Check system for program used in CMD, printing error if not found.
CMD is either a string or a list of strings.
To skip the `executable-find' check, start the string with a space."
- (unless (and (stringp cmd) (string-match-p "^ " cmd))
+ (unless (and (stringp cmd) (string-prefix-p " " cmd))
(let ((program (if (listp cmd)
(car cmd)
(car (split-string cmd)))))
@@ -2542,13 +2542,13 @@ can use `C-x r j i' to open that file."
;;** `counsel-locate'
(defcustom counsel-locate-cmd (cond ((memq system-type '(darwin berkeley-unix))
- 'counsel-locate-cmd-noregex)
+ #'counsel-locate-cmd-noregex)
((and (eq system-type 'windows-nt)
(executable-find "es.exe"))
- 'counsel-locate-cmd-es)
+ #'counsel-locate-cmd-es)
(t
- 'counsel-locate-cmd-default))
- "The function for producing a locate command string from the input.
+ #'counsel-locate-cmd-default))
+ "The function for producing a `locate' command string from the input.
The function takes a string - the current input, and returns a
string - the full shell command to run."
@@ -2556,7 +2556,8 @@ string - the full shell command to run."
(const :tag "Default" counsel-locate-cmd-default)
(const :tag "No regex" counsel-locate-cmd-noregex)
(const :tag "mdfind" counsel-locate-cmd-mdfind)
- (const :tag "everything" counsel-locate-cmd-es)))
+ (const :tag "everything" counsel-locate-cmd-es)
+ (function :tag "Custom")))
(ivy-set-actions
'counsel-locate
@@ -2591,33 +2592,33 @@ string - the full shell command to run."
(dired-jump nil x))
(defun counsel-locate-cmd-default (input)
- "Return a shell command based on INPUT."
+ "Return a `locate' shell command based on regexp INPUT."
(counsel-require-program "locate")
- (format "locate -i --regex '%s'"
- (counsel--elisp-to-pcre
- (ivy--regex input))))
+ (format "locate -i --regex %s"
+ (shell-quote-argument
+ (counsel--elisp-to-pcre
+ (ivy--regex input)))))
(defun counsel-locate-cmd-noregex (input)
- "Return a shell command based on INPUT."
+ "Return a `locate' shell command based on INPUT."
(counsel-require-program "locate")
- (format "locate -i '%s'" input))
+ (format "locate -i %s" (shell-quote-argument input)))
(defun counsel-locate-cmd-mdfind (input)
- "Return a shell command based on INPUT."
+ "Return a `mdfind' shell command based on INPUT."
(counsel-require-program "mdfind")
- (format "mdfind -name '%s'" input))
-
-(defvar w32-ansi-code-page)
+ (format "mdfind -name %s" (shell-quote-argument input)))
(defun counsel-locate-cmd-es (input)
- "Return a shell command based on INPUT."
+ "Return a `es' shell command based on INPUT."
+ (defvar w32-ansi-code-page)
(counsel-require-program "es.exe")
(let ((raw-string (format "es.exe -i -p -r %s"
(counsel--elisp-to-pcre
(ivy--regex input t)))))
- ;; W32 don't use Unicode by default, so we encode search command
- ;; to local codepage to support searching filename contains non-ASCII
- ;; characters.
+ ;; W32 doesn't use Unicode by default, so we encode search command
+ ;; to local codepage to support searching file names containing
+ ;; non-ASCII characters.
(if (and (eq system-type 'windows-nt)
(boundp 'w32-ansi-code-page))
(encode-coding-string raw-string
@@ -2625,7 +2626,7 @@ string - the full shell command to run."
raw-string)))
(defun counsel-locate-function (input)
- "Call the \"locate\" shell command with INPUT."
+ "Call a \"locate\" style shell command with INPUT."
(or
(ivy-more-chars)
(progn
@@ -2639,10 +2640,7 @@ string - the full shell command to run."
(defun counsel-file-stale-p (fname seconds)
"Return non-nil if FNAME was modified more than SECONDS ago."
- (> (time-to-seconds
- (time-subtract
- (current-time)
- (nth 5 (file-attributes fname))))
+ (> (float-time (time-subtract nil (nth 5 (file-attributes fname))))
seconds))
(defun counsel--locate-updatedb ()
@@ -2657,7 +2655,7 @@ string - the full shell command to run."
;;;###autoload
(defun counsel-locate (&optional initial-input)
- "Call the \"locate\" shell command.
+ "Call a \"locate\" style shell command.
INITIAL-INPUT can be given as the initial minibuffer input."
(interactive)
(counsel--locate-updatedb)
- [elpa] externals/ivy-hydra 63549da 354/395: Fix counsel-descbinds for Emacs 28, (continued)
- [elpa] externals/ivy-hydra 63549da 354/395: Fix counsel-descbinds for Emacs 28, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 387390b 312/395: Prefer derived-mode-p for major-mode comparisons, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 8d840b2 317/395: counsel.el (counsel-find-file-undo): Undo changing current directory, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 9bb6841 347/395: counsel.el (counsel-highlight-with-face): Fix preselect on next call, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra dd9c88f 319/395: ivy-avy.el: Fix package-lint warnings, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 544e7de 314/395: ivy.el (ivy-completing-read): Work better with find-file-at-point, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 4f98f97 332/395: targets/plain.el: Install avy automatically, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 6a22192 360/395: ivy.el (ivy--highlight-default): Use match faces consistently, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra f8b1ab8 328/395: Minor fixes for recent additions, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra dd43ab1 346/395: Add Emacs 27 executable-find compatibility shim, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra c76d797 370/395: Clean up some stuff around counsel-locate,
Basil L. Contovounesios <=
- [elpa] externals/ivy-hydra 34a203f 374/395: counsel.el: Add prompt param to counsel-mark--ivy-read, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 71c59ae 377/395: ivy.el (ivy--format-minibuffer-line): Check for annotation-function in one more place, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 80101ca 383/395: counsel.el (counsel-ag-function): User switches override -i/-s, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra e0374dc 385/395: Support empty isearch in swiper-from-isearch, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 1477144 391/395: * .gitignore: Anchor ELPA files at project root., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 63f1af0 392/395: * doc/scripts.el: Add copyright to tame the checking script, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra d47e354 393/395: Update copyright notices for 2021, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 65f5783 395/395: Select files relevant for the ivy-hydra package, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 968eea5 057/395: ivy.el (ivy-partial-or-done): Check if completion-cycle-threshold is a number, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 9619e3c 340/395: counsel.el (counsel-compile-get-make-help-invocations): new helper, Basil L. Contovounesios, 2021/02/25