[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 69d47fbb9a 075/472: Merge branch 'pacman-utils-ut-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 69d47fbb9a 075/472: Merge branch 'pacman-utils-ut-54'. Close #54 |
Date: |
Thu, 6 Jan 2022 21:59:14 -0500 (EST) |
branch: elpa/pacmacs
commit 69d47fbb9a3ff5eca0b1283a848e97911d42b9c0
Merge: 07e18ca1e6 7f706e2159
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Merge branch 'pacman-utils-ut-54'. Close #54
---
pacman-anim.el | 31 +++++++++++++++----------------
pacman-utils.el | 43 +++++++++++++++++++++++++++++++++++++++++++
test/pacman-utils-test.el | 7 +++++++
test/test-helper.el | 1 +
4 files changed, 66 insertions(+), 16 deletions(-)
diff --git a/pacman-anim.el b/pacman-anim.el
index 2664380ccc..de2f09a726 100644
--- a/pacman-anim.el
+++ b/pacman-anim.el
@@ -35,6 +35,7 @@
(require 'json)
(require 'pacman-image)
+(require 'pacman-utils)
(defun pacman-make-anim (frames sprite-sheet)
(list :frames frames
@@ -64,29 +65,27 @@
(< order1 order2)))
(defun pacman-convert-aseprite-frame (aseprite-frame)
- (let* ((frame (cdr (assoc 'frame (cdr aseprite-frame))))
- (x (cdr (assoc 'x frame)))
- (y (cdr (assoc 'y frame)))
- (w (cdr (assoc 'w frame)))
- (h (cdr (assoc 'h frame))))
- (list x y w h)))
+ (let* ((frame (cdr (assoc 'frame (cdr aseprite-frame)))))
+ (mapcar (lambda (n)
+ (cdr (assoc n frame)))
+ '(x y w h))))
(defun pacman-anim-get-frame (anim)
- (let ((frames (plist-get anim :frames))
- (current-frame (plist-get anim :current-frame)))
+ (plist-bind ((frames :frames)
+ (current-frame :current-frame))
+ anim
(nth current-frame frames)))
(defun pacman-anim-next-frame (anim)
- (let* ((frames (plist-get anim :frames))
- (current-frame (plist-get anim :current-frame))
- (new-current-frame (mod (+ current-frame 1)
- (length frames))))
- (plist-put anim :current-frame new-current-frame)))
+ (plist-bind ((frames :frames)
+ (current-frame :current-frame))
+ anim
+ (let ((new-current-frame (mod (+ current-frame 1)
+ (length frames))))
+ (plist-put anim :current-frame new-current-frame))))
(defun pacman-anim-object-next-frame (anim-object)
- (let ((anim (plist-get anim-object :animation)))
- (plist-put anim-object :animation
- (pacman-anim-next-frame anim))))
+ (plist-map anim-object :animation #'pacman-anim-next-frame))
(provide 'pacman-anim)
diff --git a/pacman-utils.el b/pacman-utils.el
index 46ff4901d2..3ff2903462 100644
--- a/pacman-utils.el
+++ b/pacman-utils.el
@@ -1,3 +1,36 @@
+;;; pacman-utils.el --- Pacman for Emacs
+
+;; Copyright (C) 2015 Codingteam
+
+;; Author: Codingteam <codingteam@conference.jabber.ru>
+;; Maintainer: Alexey Kutepov <reximkut@gmail.com>
+;; URL: http://github.com/rexim/pacman.el
+
+;; Permission is hereby granted, free of charge, to any person
+;; obtaining a copy of this software and associated documentation
+;; files (the "Software"), to deal in the Software without
+;; restriction, including without limitation the rights to use, copy,
+;; modify, merge, publish, distribute, sublicense, and/or sell copies
+;; of the Software, and to permit persons to whom the Software is
+;; furnished to do so, subject to the following conditions:
+
+;; The above copyright notice and this permission notice shall be
+;; included in all copies or substantial portions of the Software.
+
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+;; SOFTWARE.
+
+;;; Commentary:
+
+;; Some common utils
+
+;;; Code:
(defmacro plist-bind (keys expr &rest body)
(declare (indent 2) (debug t))
@@ -9,4 +42,14 @@
keys))
,@body)))
+(defun plist-map (plist property transformer)
+ "Transform the value of PROPERTY in PLIST with TRANSFORMER.
+This function modifies plist with plist-put. So it does the same
+side-effects."
+ (plist-bind ((value property)) plist
+ (plist-put plist property
+ (funcall transformer value))))
+
(provide 'pacman-utils)
+
+;;; pacman.el ends here
diff --git a/test/pacman-utils-test.el b/test/pacman-utils-test.el
new file mode 100644
index 0000000000..378045dce3
--- /dev/null
+++ b/test/pacman-utils-test.el
@@ -0,0 +1,7 @@
+(ert-deftest plist-map-test ()
+ (let ((plist (list :foo 1
+ :bar 2)))
+ (plist-map plist :bar #'1+)
+ (should (equal (list :foo 1
+ :bar 3)
+ plist))))
diff --git a/test/test-helper.el b/test/test-helper.el
index 3cf0400ea4..55373381c1 100644
--- a/test/test-helper.el
+++ b/test/test-helper.el
@@ -8,3 +8,4 @@
(add-to-list 'load-path ".")
(load "pacman-anim.el")
(load "pacman-image.el")
+(load "pacman-utils.el")
- [nongnu] elpa/pacmacs 1b2ca64cd1 157/472: Merge branch 'resource-packaging-95'. Close #95, (continued)
- [nongnu] elpa/pacmacs 1b2ca64cd1 157/472: Merge branch 'resource-packaging-95'. Close #95, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 48ecc5cee9 159/472: Don't fail if the score file doesn't exist, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 10b8a997dd 037/472: More precise instructions in README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7e04991d4e 030/472: Add UT for pacman-compare-aseprite-frames function (#22), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 327332d32d 036/472: Update README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 68f876d0ba 043/472: Merge pull request #29 from rexim/license-28, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 298b950310 062/472: Rename pacman-resources to pacman-image (#51), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs e9703e9ba2 061/472: Rename function for loading images (#51), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0a65793037 071/472: Use plist-bind for pacman-anim-object-next-frame (#54), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7f706e2159 074/472: Add UTs for plist-map (#54), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 69d47fbb9a 075/472: Merge branch 'pacman-utils-ut-54'. Close #54,
ELPA Syncer <=
- [nongnu] elpa/pacmacs 7d16738069 077/472: Implement custom map format. Close #61, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 6d1831c746 081/472: Implement ghost mechanics. Close #62, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 427b4f823e 088/472: Add edebug specs for plist-bind macro (#68), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1ed7f14e30 099/472: UTs for pacmacs--init-board-test (#75), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a802074eea 109/472: Add set/get functions for board (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs de66c1ce17 112/472: Refactor out pacmacs--step-point (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b0561eb59f 111/472: Refactor pacmacs--cell-tracked-p (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 317f9b85b7 114/472: Refactor pacmacs--track-point (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 5233bac0c5 105/472: UT for pacmacs--put-object-test (#75), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d2c449734e 124/472: Merge branch 'pacman-death-69'. Close #69, ELPA Syncer, 2022/01/06