[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 4ba13e6: * shell-quasiquote.el (shqq): Make better use of
From: |
Stefan Monnier |
Subject: |
[elpa] master 4ba13e6: * shell-quasiquote.el (shqq): Make better use of pcase |
Date: |
Mon, 26 Oct 2015 03:58:27 +0000 |
branch: master
commit 4ba13e6c325c4228afd10bc8de27adbccdcd688f
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* shell-quasiquote.el (shqq): Make better use of pcase
(shqq--match-comma, shqq--match-comma2): Remove.
---
packages/shell-quasiquote/shell-quasiquote.el | 36 +++---------------------
1 files changed, 5 insertions(+), 31 deletions(-)
diff --git a/packages/shell-quasiquote/shell-quasiquote.el
b/packages/shell-quasiquote/shell-quasiquote.el
index bdea46a..a0bf7c8 100644
--- a/packages/shell-quasiquote/shell-quasiquote.el
+++ b/packages/shell-quasiquote/shell-quasiquote.el
@@ -4,6 +4,7 @@
;; Author: Taylan Ulrich Bayırlı/Kammer <address@hidden>
;; Keywords: extensions, unix
+;; Version: 0
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -67,27 +68,6 @@
(defun shqq--quote-atom (atom)
(shell-quote-argument (shqq--atom-to-string atom)))
-
-(defun shqq--match-comma (form)
- "Matches FORM against ,foo i.e. (\, foo) and returns foo.
-Returns nil if FORM didn't match. You can't disambiguate between
-FORM matching ,nil and not matching."
- (if (and (consp form)
- (eq '\, (car form))
- (consp (cdr form))
- (null (cddr form)))
- (cadr form)))
-
-(defun shqq--match-comma2 (form)
- "Matches FORM against ,,foo i.e. (\, (\, foo)) and returns foo.
-Returns nil if FORM didn't match. You can't disambiguate between
-FORM matching ,,nil and not matching."
- (if (and (consp form)
- (eq '\, (car form))
- (consp (cdr form))
- (null (cddr form)))
- (shqq--match-comma (cadr form))))
-
(defmacro shqq (parts)
"First, PARTS is turned into a list of strings. For this,
@@ -124,19 +104,13 @@ separating spaces."
;; We use the match-comma helpers because pcase can't match ,foo.
(t (pcase part
;; ,,foo i.e. (, (, foo))
- ((pred shqq--match-comma2)
- (shqq--match-comma2 part))
+ (`(,`\, (,`\, ,form)) form)
;; ,,@foo i.e. (, (,@ foo))
- ((and (pred shqq--match-comma)
- (let `,@,form (shqq--match-comma part)))
- `(mapconcat #'identity ,form " "))
+ (`(,`\, (,`\,@ ,form)) `(mapconcat #'identity ,form " "))
;; ,foo
- ;; Insert redundant 'and x' to work around debbugs#18554.
- ((and x (pred shqq--match-comma))
- `(shqq--quote-atom ,(shqq--match-comma part)))
+ (`(,`\, ,form) `(shqq--quote-atom ,form))
;; ,@foo
- (`,@,form
- `(mapconcat #'shqq--quote-atom ,form " "))
+ (`,@,form `(mapconcat #'shqq--quote-atom ,form " "))
(_
(error "Bad shqq part: %S" part))))))
parts)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master 4ba13e6: * shell-quasiquote.el (shqq): Make better use of pcase,
Stefan Monnier <=