From d5cca9d5795824fd2a2b54e6254a0354735ce500 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 27 Aug 2019 23:34:58 -0700 Subject: [PATCH] =?UTF-8?q?Add=20snippets=20to=20=E2=80=98oni-nxml?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 11 ++++++++ GNUmakefile | 16 ++++++++++- oni-nxml/Cask | 10 +++++++ oni-nxml.el => oni-nxml/oni-nxml.el | 27 ++++++++++++++++++- oni-nxml/snippets/nxml-mode/pencil-property | 7 +++++ .../snippets/nxml-mode/pencil-property-value | 5 ++++ oni-nxml/snippets/nxml-mode/pencil-shortcut | 9 +++++++ 7 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 oni-nxml/Cask rename oni-nxml.el => oni-nxml/oni-nxml.el (59%) create mode 100644 oni-nxml/snippets/nxml-mode/pencil-property create mode 100644 oni-nxml/snippets/nxml-mode/pencil-property-value create mode 100644 oni-nxml/snippets/nxml-mode/pencil-shortcut diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 721e20a..359339f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,6 +56,16 @@ package-oni-html: paths: - oni-html/dist/ +package-oni-nxml: + stage: pre-package-multifile + before_script: + - rm -rf oni-elisp/dist + script: + - cask --path oni-nxml package + artifacts: + paths: + - oni-nxml/dist/ + test-oni-alert: stage: test script: make test-oni-alert @@ -105,6 +115,7 @@ package: - package-oni-elisp - package-oni-haml - package-oni-html + - package-oni-nxml before_script: - rm -rf bin/ - mkdir bin/ diff --git a/GNUmakefile b/GNUmakefile index 82bb3f6..e58648c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ FILES := $(wildcard *.el) PACKAGE_TARGETS := $(addprefix package-,$(FILES)) package: $(PACKAGE_TARGETS) package-oni-conf package-oni-css package-oni-elisp \ - package-oni-haml package-oni-html + package-oni-haml package-oni-html package-oni-nxml package-%: % emacs --batch \ @@ -41,6 +41,12 @@ package-oni-html: --funcall package-initialize \ --eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-html/dist/*.tar\") #'string>)))" +package-oni-nxml: + emacs --batch \ + --load oni-package.el \ + --funcall package-initialize \ + --eval "(package-upload-file (car (sort (file-expand-wildcards \"oni-nxml/dist/*.tar\") #'string>)))" + install-%: emacs --batch \ --load oni-package.el \ @@ -89,6 +95,14 @@ install-oni-html: $(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \ --eval "(package-install-file (car (sort (file-expand-wildcards \"oni-html/dist/*.tar\") #'string>)))" +install-oni-nxml: + emacs --batch \ + --load oni-package.el \ + --fluncall package-initialize \ + --eval '(package-refresh-contents)' \ + $(foreach DEP,$(DEPS),--eval "(package-install-file \"$(DEP).el\")") \ + --eval "(package-install-file (car (sort (file-expand-wildcards \"oni-nxml/dist/*.tar\") #'string>)))" + test-%: install-% emacs --batch \ --load oni-package.el \ diff --git a/oni-nxml/Cask b/oni-nxml/Cask new file mode 100644 index 0000000..f9ee661 --- /dev/null +++ b/oni-nxml/Cask @@ -0,0 +1,10 @@ +(source gnu) +(source melpa) + +(package-file "./oni-nxml.el") + +(depends-on "oni-yasnippet" :git "../" :files ("oni-yasnippet.el")) + +(files + "*.el" + ("snippets" "./snippets/*")) diff --git a/oni-nxml.el b/oni-nxml/oni-nxml.el similarity index 59% rename from oni-nxml.el rename to oni-nxml/oni-nxml.el index 5f8611f..2ca4977 100644 --- a/oni-nxml.el +++ b/oni-nxml/oni-nxml.el @@ -4,7 +4,8 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 20190306231832 +;; Version: 20190827233218 +;; Package-Requires: (oni-yasnippet) ;; 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 @@ -25,10 +26,34 @@ ;;; Code: +(require 'yasnippet) + +(defconst oni-nxml-root + (file-name-directory + (or load-file-name + (buffer-file-name))) + "The directory where ‘oni-nxml’ was loaded from.") + +(defconst oni-nxml-snippets-dir + (expand-file-name "snippets" oni-nxml-root) + "The directory where ‘oni-nxml’ stores its snippets.") + +;;;###autoload +(defun oni-nxml-snippets-initialize () + "Initialize the snippets for ‘oni-nxml’." + (when (boundp 'yas-snippet-dirs) + (add-to-list 'yas-snippet-dirs oni-nxml-snippets-dir t)) + (yas-load-directory oni-nxml-snippets-dir)) + ;;;###autoload (add-to-list 'auto-mode-alist '("\\.targets\\'" . nxml-mode)) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.proj\\'" . nxml-mode)) +;;;###autoload +(with-eval-after-load 'nxml-mode + (with-eval-after-load 'yasnippet + (oni-nxml-snippets-initialize))) + (provide 'oni-nxml) ;;; oni-nxml.el ends here diff --git a/oni-nxml/snippets/nxml-mode/pencil-property b/oni-nxml/snippets/nxml-mode/pencil-property new file mode 100644 index 0000000..7fafcb8 --- /dev/null +++ b/oni-nxml/snippets/nxml-mode/pencil-property @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: PencilProperty +# key: p +# -- +$4 \ No newline at end of file diff --git a/oni-nxml/snippets/nxml-mode/pencil-property-value b/oni-nxml/snippets/nxml-mode/pencil-property-value new file mode 100644 index 0000000..5da3d10 --- /dev/null +++ b/oni-nxml/snippets/nxml-mode/pencil-property-value @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: PropertyValue +# key: pv +# -- +$2 \ No newline at end of file diff --git a/oni-nxml/snippets/nxml-mode/pencil-shortcut b/oni-nxml/snippets/nxml-mode/pencil-shortcut new file mode 100644 index 0000000..e760d27 --- /dev/null +++ b/oni-nxml/snippets/nxml-mode/pencil-shortcut @@ -0,0 +1,9 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: Shortcut +# key: s +# -- + + $0 + \ No newline at end of file