Last active
November 11, 2019 22:48
-
-
Save equwal/d23d9296533bb693c85975d9d6556c7c to your computer and use it in GitHub Desktop.
Roswell auto-insertion for Emacs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;;; Executes $ ros init CURRENTBUFFER | |
| ;;;; and reloads it when making a new *.ros file | |
| ;;;; Roswell: https://github.com/roswell/roswell | |
| ;;;###autoload | |
| (defun boilerplate-ros-auto-insertion () | |
| (shell-command (concat "ros init " "'"(file-name-base (buffer-file-name)) "'")) | |
| (find-file (buffer-file-name))) | |
| (setq auto-insert t) | |
| ;;;###autoload | |
| (boilerplate--define-auto-insertion-mode boilerplate-ros | |
| boilerplate-ros-auto-insertion | |
| "Insert ros boilerplate on new." | |
| (lisp-mode) | |
| ("ros") | |
| (lisp-mode)) | |
| (defmacro boilerplate--define-auto-insertion-mode | |
| (name insertion-fn docstring hooked-modes file-exts &rest body) | |
| "For making lots of auto insertion modes." | |
| `(progn (defvar ,(intern (concat (symbol-name name) | |
| (symbol-name '-hook))) nil) | |
| (apply (lambda (p) (add-to-list 'auto-mode-alist p)) | |
| ',(cl-loop for fe in file-exts | |
| collect (cons (concat | |
| "\\." | |
| fe | |
| "\\'") name))) | |
| (apply (lambda (p) (add-to-list 'auto-insert-alist p)) | |
| ',(cl-loop for fe in file-exts | |
| collect (cons (concat "\\." fe) insertion-fn))) | |
| (define-minor-mode ,name ,docstring | |
| :lighter " AUTOINS" | |
| (auto-insert) | |
| ,@body) | |
| ,@(cl-loop for m in hooked-modes | |
| collect `(add-hook ',m ',name)) | |
| (provide ',name))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment