[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/20: emacs: Add and use 'guix-while-search'.
From: |
Alex Kost |
Subject: |
04/20: emacs: Add and use 'guix-while-search'. |
Date: |
Tue, 18 Aug 2015 09:41:09 +0000 |
alezost pushed a commit to branch wip-emacs-popup-ui
in repository guix.
commit d9bc6fd7bf8497d023ad47abdc19a1a65bf5ffb9
Author: Alex Kost <address@hidden>
Date: Wed Aug 12 15:28:55 2015 +0300
emacs: Add and use 'guix-while-search'.
* emacs/guix-utils.el (guix-while-search): New macro.
* emacs/guix-pcomplete.el (guix-pcomplete-run-guix-and-search): Use it.
* emacs/guix-prettify.el (guix-prettify-decompose-buffer): Likewise.
---
emacs/guix-pcomplete.el | 3 +--
emacs/guix-prettify.el | 16 ++++++++--------
emacs/guix-utils.el | 8 ++++++++
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/emacs/guix-pcomplete.el b/emacs/guix-pcomplete.el
index cad1966..99bc29f 100644
--- a/emacs/guix-pcomplete.el
+++ b/emacs/guix-pcomplete.el
@@ -104,9 +104,8 @@ Return a list of strings matching REGEXP.
GROUP specifies a parenthesized expression used in REGEXP."
(with-temp-buffer
(apply #'guix-pcomplete-run-guix args)
- (goto-char (point-min))
(let (result)
- (while (re-search-forward regexp nil t)
+ (guix-while-search regexp
(push (match-string-no-properties group) result))
(nreverse result))))
diff --git a/emacs/guix-prettify.el b/emacs/guix-prettify.el
index b01495c..1abfd68 100644
--- a/emacs/guix-prettify.el
+++ b/emacs/guix-prettify.el
@@ -1,6 +1,6 @@
;;; guix-prettify.el --- Prettify Guix store file names
-;; Copyright © 2014 Alex Kost <address@hidden>
+;; Copyright © 2014, 2015 Alex Kost <address@hidden>
;; This file is part of GNU Guix.
@@ -47,6 +47,8 @@
;;; Code:
+(require 'guix-utils)
+
(defgroup guix-prettify nil
"Prettify Guix store file names."
:prefix "guix-prettify-"
@@ -136,13 +138,11 @@ enabling/disabling `guix-prettify-mode'. If nil, do
nothing.")
(remove-text-properties (point-min)
(point-max)
'(composition nil))
- (save-excursion
- (goto-char (point-min))
- (while (re-search-forward guix-prettify-regexp nil t)
- (remove-text-properties
- (match-beginning guix-prettify-regexp-group)
- (match-end guix-prettify-regexp-group)
- '(composition nil))))))))
+ (guix-while-search guix-prettify-regexp
+ (remove-text-properties
+ (match-beginning guix-prettify-regexp-group)
+ (match-end guix-prettify-regexp-group)
+ '(composition nil)))))))
;;;###autoload
(define-minor-mode guix-prettify-mode
diff --git a/emacs/guix-utils.el b/emacs/guix-utils.el
index dc0c58a..8a0673a 100644
--- a/emacs/guix-utils.el
+++ b/emacs/guix-utils.el
@@ -160,6 +160,14 @@ accessed with KEYS."
(find-file file)
(message "File '%s' does not exist." file)))
+(defmacro guix-while-search (regexp &rest body)
+ "Evaluate BODY after each search for REGEXP in the current buffer."
+ (declare (indent 1) (debug t))
+ `(save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward ,regexp nil t)
+ ,@body)))
+
;;; Diff
- branch wip-emacs-popup-ui created (now 2392984), Alex Kost, 2015/08/18
- 01/20: guix lint: Export checkers and <lint-checker> accessors., Alex Kost, 2015/08/18
- 03/20: emacs: Add 'guix-package-names'., Alex Kost, 2015/08/18
- 05/20: emacs: Add and use 'guix-concat-strings'., Alex Kost, 2015/08/18
- 04/20: emacs: Add and use 'guix-while-search'.,
Alex Kost <=
- 06/20: emacs: Add utils to make symbol and string for guix command., Alex Kost, 2015/08/18
- 08/20: emacs: Add 'guix-any'., Alex Kost, 2015/08/18
- 09/20: emacs: Add 'guix-memoized-defalias' macro., Alex Kost, 2015/08/18
- 13/20: ui: Add 'run-guix'., Alex Kost, 2015/08/18
- 02/20: emacs: Add 'guix-lint-checker-names'., Alex Kost, 2015/08/18
- 14/20: emacs: Add code to run guix command in REPL., Alex Kost, 2015/08/18
- 10/20: emacs: Add help variables., Alex Kost, 2015/08/18
- 07/20: emacs: Add utils to copy guix command., Alex Kost, 2015/08/18
- 15/20: emacs: Add code to run guix command in shell., Alex Kost, 2015/08/18
- 20/20: emacs: Use popup interface instead 'guix-pull' command., Alex Kost, 2015/08/18