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.
This commit is contained in:
parent
935d079bb7
commit
c10521e976
|
@ -105,9 +105,8 @@ Return a list of strings matching REGEXP.
|
||||||
GROUP specifies a parenthesized expression used in REGEXP."
|
GROUP specifies a parenthesized expression used in REGEXP."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(apply #'guix-pcomplete-run-guix args)
|
(apply #'guix-pcomplete-run-guix args)
|
||||||
(goto-char (point-min))
|
|
||||||
(let (result)
|
(let (result)
|
||||||
(while (re-search-forward regexp nil t)
|
(guix-while-search regexp
|
||||||
(push (match-string-no-properties group) result))
|
(push (match-string-no-properties group) result))
|
||||||
(nreverse result))))
|
(nreverse result))))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;; guix-prettify.el --- Prettify Guix store file names
|
;;; guix-prettify.el --- Prettify Guix store file names
|
||||||
|
|
||||||
;; Copyright © 2014 Alex Kost <alezost@gmail.com>
|
;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
|
||||||
|
|
||||||
;; This file is part of GNU Guix.
|
;; This file is part of GNU Guix.
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'guix-utils)
|
||||||
|
|
||||||
(defgroup guix-prettify nil
|
(defgroup guix-prettify nil
|
||||||
"Prettify Guix store file names."
|
"Prettify Guix store file names."
|
||||||
:prefix "guix-prettify-"
|
:prefix "guix-prettify-"
|
||||||
|
@ -137,13 +139,11 @@ enabling/disabling `guix-prettify-mode'. If nil, do nothing.")
|
||||||
(remove-text-properties (point-min)
|
(remove-text-properties (point-min)
|
||||||
(point-max)
|
(point-max)
|
||||||
'(composition nil))
|
'(composition nil))
|
||||||
(save-excursion
|
(guix-while-search guix-prettify-regexp
|
||||||
(goto-char (point-min))
|
(remove-text-properties
|
||||||
(while (re-search-forward guix-prettify-regexp nil t)
|
(match-beginning guix-prettify-regexp-group)
|
||||||
(remove-text-properties
|
(match-end guix-prettify-regexp-group)
|
||||||
(match-beginning guix-prettify-regexp-group)
|
'(composition nil)))))))
|
||||||
(match-end guix-prettify-regexp-group)
|
|
||||||
'(composition nil))))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-minor-mode guix-prettify-mode
|
(define-minor-mode guix-prettify-mode
|
||||||
|
|
|
@ -160,6 +160,14 @@ accessed with KEYS."
|
||||||
(find-file file)
|
(find-file file)
|
||||||
(message "File '%s' does not exist." 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
|
;;; Diff
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue