branch: externals/ivy-hydra
commit 22028d46476036a8277bdfcb9f506d9657e5b7a5
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>

    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