emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ivy-hydra 22028d4 146/395: counsel.el (counsel--string-


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 22028d4 146/395: counsel.el (counsel--string-trim-left): Add
Date: Thu, 25 Feb 2021 08:31:50 -0500 (EST)

branch: externals/ivy-hydra
commit 22028d46476036a8277bdfcb9f506d9657e5b7a5
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    counsel.el (counsel--string-trim-left): Add
    
    Fixes #2451
    Fixes #2452
    Fixes #2448
---
 counsel.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/counsel.el b/counsel.el
index f78825f..697b68e 100644
--- a/counsel.el
+++ b/counsel.el
@@ -882,11 +882,17 @@ packages are, in order of precedence, `amx' and `smex'."
 (defvar counsel-M-x-history nil
   "History for `counsel-M-x'.")
 
-(declare-function string-trim-left "subr-x")
+(defsubst counsel--string-trim-left (string &optional regexp)
+  "Trim STRING of leading string matching REGEXP.
+
+REGEXP defaults to \"[ \\t\\n\\r]+\"."
+  (if (string-match (concat "\\`\\(?:" (or regexp "[ \t\n\r]+") "\\)") string)
+      (replace-match "" t t string)
+    string))
 
 (defun counsel-M-x-action (cmd)
   "Execute CMD."
-  (setq cmd (intern (string-trim-left cmd "\\^")))
+  (setq cmd (intern (counsel--string-trim-left cmd "\\^")))
   (cond ((bound-and-true-p amx-initialized)
          (amx-rank cmd))
         ((bound-and-true-p smex-initialized-p)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]