From 3dcabca1978996ea5f6cb01ac36665bbbb0b267a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=20=D0=A1=D0=B8=D0=BC=D0=B8=D1=9B?= Date: Wed, 5 Oct 2016 21:28:44 +0100 Subject: [PATCH 1/4] fix for ns snippet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the snippets for ns, they kept bombing out on: (ns [yas] elisp error: Symbol’s function definition is void: flet) (ns [yas] elisp error: Symbol’s function definition is void: first) (ns [yas] elisp error: Symbol’s function definition is void: remove-if-not) (ns [yas] elisp error: Symbol’s function definition is void: second) That's why I've added the new `cl-' prefix for them as they are part of the cl-lib. --- snippets/clojure-mode/ns | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snippets/clojure-mode/ns b/snippets/clojure-mode/ns index 1d8982e..0ed0191 100644 --- a/snippets/clojure-mode/ns +++ b/snippets/clojure-mode/ns @@ -2,15 +2,15 @@ # name: ns # key: ns # -- -(ns `(flet ((try-src-prefix +(ns `(cl-flet ((try-src-prefix (path src-pfx) (let ((parts (split-string path src-pfx))) (if (= 2 (length parts)) - (second parts) + (cl-second parts) nil)))) (let* ((p (buffer-file-name)) - (p2 (first - (remove-if-not '(lambda (x) x) + (p2 (cl-first + (cl-remove-if-not '(lambda (x) x) (mapcar '(lambda (pfx) (try-src-prefix p pfx)) @@ -19,4 +19,4 @@ (p4 (mapconcat '(lambda (x) x) (split-string p3 "/") "."))) - (replace-regexp-in-string "_" "-" p4)))`) \ No newline at end of file + (replace-regexp-in-string "_" "-" p4)))`) From 1159f9e1d07b6d77cde9fc598f1d074ab0771c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=20=D0=A1=D0=B8=D0=BC=D0=B8=D1=9B?= Date: Wed, 5 Oct 2016 21:32:08 +0100 Subject: [PATCH 2/4] Fixed the indentation After adding the `cl-' prefix, I ran `indent-region' on the body of the snippet. --- snippets/clojure-mode/ns | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/snippets/clojure-mode/ns b/snippets/clojure-mode/ns index 0ed0191..8ddec14 100644 --- a/snippets/clojure-mode/ns +++ b/snippets/clojure-mode/ns @@ -3,20 +3,20 @@ # key: ns # -- (ns `(cl-flet ((try-src-prefix - (path src-pfx) - (let ((parts (split-string path src-pfx))) - (if (= 2 (length parts)) - (cl-second parts) - nil)))) - (let* ((p (buffer-file-name)) - (p2 (cl-first - (cl-remove-if-not '(lambda (x) x) - (mapcar - '(lambda (pfx) - (try-src-prefix p pfx)) - '("/src/cljs/" "/src/clj/" "/src/"))))) - (p3 (file-name-sans-extension p2)) - (p4 (mapconcat '(lambda (x) x) - (split-string p3 "/") - "."))) - (replace-regexp-in-string "_" "-" p4)))`) + (path src-pfx) + (let ((parts (split-string path src-pfx))) + (if (= 2 (length parts)) + (cl-second parts) + nil)))) + (let* ((p (buffer-file-name)) + (p2 (cl-first + (cl-remove-if-not '(lambda (x) x) + (mapcar + '(lambda (pfx) + (try-src-prefix p pfx)) + '("/src/cljs/" "/src/clj/" "/src/"))))) + (p3 (file-name-sans-extension p2)) + (p4 (mapconcat '(lambda (x) x) + (split-string p3 "/") + "."))) + (replace-regexp-in-string "_" "-" p4)))`) From 9ced8d948e0ed575da18ef474d7dea1ad1c0bd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=20=D0=A1=D0=B8=D0=BC=D0=B8=D1=9B?= Date: Wed, 5 Oct 2016 21:40:30 +0100 Subject: [PATCH 3/4] Explicitly specify `cl-lib' requirement Even though `yasnippet' uses and specifies `cl-lib' as a requirement, this package uses it too and so it should be explicitly stated. --- clojure-snippets.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clojure-snippets.el b/clojure-snippets.el index a0144c7..0a3d7dd 100644 --- a/clojure-snippets.el +++ b/clojure-snippets.el @@ -5,7 +5,7 @@ ;; Author: Max Penet ;; Keywords: snippets ;; Version: 1.0.0 -;; Package-Requires: ((yasnippet "0.8.0")) +;; Package-Requires: ((yasnippet "0.8.0") (cl-lib "0.5")) ;; 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 From 81f2511bba5ad61b6fcd17c69317897aa79db95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=20=D0=A1=D0=B8=D0=BC=D0=B8=D1=9B?= Date: Sat, 8 Oct 2016 11:44:47 +0100 Subject: [PATCH 4/4] Make the 'ns' snippet work for test files Added the "/test/" path so that the ns snippet works for files that are created under 'test' directory and not just the files under "/src/*". --- snippets/clojure-mode/ns | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/clojure-mode/ns b/snippets/clojure-mode/ns index 8ddec14..9be7469 100644 --- a/snippets/clojure-mode/ns +++ b/snippets/clojure-mode/ns @@ -14,7 +14,7 @@ (mapcar '(lambda (pfx) (try-src-prefix p pfx)) - '("/src/cljs/" "/src/clj/" "/src/"))))) + '("/src/cljs/" "/src/clj/" "/src/" "/test/"))))) (p3 (file-name-sans-extension p2)) (p4 (mapconcat '(lambda (x) x) (split-string p3 "/")