branch: master
commit 859e3cbb422e02b6b040da545153f82a655383ee
Author: Basil L. Contovounesios <[email protected]>
Commit: Basil L. Contovounesios <[email protected]>
counsel.el: Clean up compile history keeping
(counsel-compile--update-history): Use add-to-history instead of
add-to-list and file-equal-p instead of string-equal. Avoid one
level of unneeded string consing.
---
counsel.el | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/counsel.el b/counsel.el
index e91c2d9..1c2fa61 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5267,24 +5267,20 @@ The optional BLDDIR is useful for other helpers that
have found
(setq cands (nconc cands more-cands)))))
cands)))
-;; This is a workaround to ensure we tag all the relevant meta-data in
-;; our compile history. This also allows M-x compile to do fancy
-;; things like infer default-directory from cd's in the string.
+;; This is a workaround to ensure we tag all the relevant metadata in
+;; our compile history. This also allows M-x compile to do fancy
+;; things like infer `default-directory' from 'cd's in the string.
(defun counsel-compile--update-history (_proc)
"Update `counsel-compile-history' from the compilation state."
- (let ((srcdir (funcall counsel-compile-root-function))
- (blddir default-directory)
- (command (car compilation-arguments)))
- (add-to-list
- 'counsel-compile-history
- (propertize
- (concat
- (propertize command 'cmd 't)
- (when (not (string-equal blddir srcdir))
- (concat (propertize " in " 'face 'font-lock-warning-face)
- (propertize blddir 'face 'dired-directory))))
- 'srcdir srcdir
- 'blddir blddir))))
+ (let* ((srcdir (funcall counsel-compile-root-function))
+ (blddir default-directory)
+ (cmd (concat
+ (propertize (car compilation-arguments) 'cmd t)
+ (unless (file-equal-p blddir srcdir)
+ (concat (propertize " in " 'face 'font-lock-warning-face)
+ (propertize blddir 'face 'dired-directory))))))
+ (add-text-properties 0 (length cmd) `(srcdir ,srcdir blddir ,blddir) cmd)
+ (add-to-history 'counsel-compile-history cmd)))
(defun counsel-compile--action (cmd)
"Process CMD to call `compile'.