mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 21:59:08 -05:00
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
3 changed files with 17 additions and 10 deletions
|
@ -105,9 +105,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))))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; 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.
|
||||
|
||||
|
@ -47,6 +47,8 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(require 'guix-utils)
|
||||
|
||||
(defgroup guix-prettify nil
|
||||
"Prettify Guix store file names."
|
||||
:prefix "guix-prettify-"
|
||||
|
@ -137,13 +139,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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue