emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] scratch/hook-helpers 7f1eccf 16/19: Fixed bug in hkhlp-normalize-


From: Ian Dunn
Subject: [elpa] scratch/hook-helpers 7f1eccf 16/19: Fixed bug in hkhlp-normalize-hook-spec
Date: Sun, 23 Apr 2017 12:50:41 -0400 (EDT)

branch: scratch/hook-helpers
commit 7f1eccfe4ed4d9e350b272f95b37a2f9da3751e4
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>

    Fixed bug in hkhlp-normalize-hook-spec
    
    * hook-helpers.el (hkhlp-normalize-hook-spec): Correctly handle list 
structure
    
    * hook-helpers-tests.el (hkhlp-normalize-hook-spec-test): Test for single 
list
      form
    
    * Makefile: Add check target
---
 Makefile              | 16 ++++++++++++++++
 hook-helpers-tests.el |  4 +++-
 hook-helpers.el       |  7 ++++---
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 3ef4668..68d4062 100644
--- a/Makefile
+++ b/Makefile
@@ -39,3 +39,19 @@ hook-helpers-autoloads.el:
 
 clean:
        -rm -f *.elc
+
+check:
+       @$(EMACS) \
+       -L "." \
+       --load "ert" \
+       --load "hook-helpers-tests.el" \
+       -f ert-run-tests-batch-and-exit
+
+help:
+       $(info )
+       $(info make all       - Default)
+       $(info make compile   - Compile Emacs Lisp Files)
+       $(info make autoloads - Generate Autoloads)
+       $(info make clean     - Remove generated .elc files)
+       $(info make check     - Run Tests)
+       @echo ""
diff --git a/hook-helpers-tests.el b/hook-helpers-tests.el
index 9d732fc..c5758e6 100644
--- a/hook-helpers-tests.el
+++ b/hook-helpers-tests.el
@@ -40,7 +40,9 @@
                  '((c++-mode-hook) (org-mode-hook . t))))
   (should (equal (hkhlp-normalize-hook-spec '((c++-mode-hook . t)
                                               (org-mode-hook . t)))
-                 '((c++-mode-hook . t) (org-mode-hook . t)))))
+                 '((c++-mode-hook . t) (org-mode-hook . t))))
+  (should (equal (hkhlp-normalize-hook-spec '((c++-mode-hook . t)))
+                 '((c++-mode-hook . t)))))
 
 (ert-deftest hkhlp-create-hook-helper-test ()
   (let ((test-hook nil))
diff --git a/hook-helpers.el b/hook-helpers.el
index 336cf7c..0923ecf 100644
--- a/hook-helpers.el
+++ b/hook-helpers.el
@@ -42,7 +42,7 @@
 (cl-defstruct hook-helper
   id function hooks source-file)
 
-(defun hkhlp-normalize-hook-spec (hook-spec)
+(defun hkhlp-normalize-hook-spec (hook-spec &optional recursed)
   "Turns HOOK-SPEC into a list of cons-cells, each one (HOOK . APPEND)
 
 HOOK is the name of the full variable to use
@@ -52,12 +52,13 @@ APPEND is a Boolean"
     ;; HOOK
     (list (cons hook-spec nil)))
    ((and (consp hook-spec)
+         (symbolp (car hook-spec))
          (booleanp (cdr hook-spec)))
     ;; (HOOK . APPEND)
     (list hook-spec))
-   ((listp hook-spec)
+   ((and (listp hook-spec) (not recursed))
     ;; List of specs
-    (apply 'append (mapcar (lambda (spec) (hkhlp-normalize-hook-spec spec)) 
hook-spec)))
+    (mapcar (lambda (spec) (car (hkhlp-normalize-hook-spec spec t))) 
hook-spec))
    (t
     (warn "Unrecognized hook-spec %s" hook-spec))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]