└── livecoder.el /livecoder.el: -------------------------------------------------------------------------------- 1 | ;;; livecoder.el --- tools for live coders 2 | 3 | ;; Copyright (C) 2014 Nic Ferrier 4 | 5 | ;; Author: Nic Ferrier 6 | ;; Keywords: languages 7 | ;; Version: 0.0.1 8 | 9 | ;; This program is free software; you can redistribute it and/or modify 10 | ;; it under the terms of the GNU General Public License as published by 11 | ;; the Free Software Foundation, either version 3 of the License, or 12 | ;; (at your option) any later version. 13 | 14 | ;; This program is distributed in the hope that it will be useful, 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;; GNU General Public License for more details. 18 | 19 | ;; You should have received a copy of the GNU General Public License 20 | ;; along with this program. If not, see . 21 | 22 | ;;; Commentary: 23 | 24 | ;; I do live coding quite a bit, it needs better tool support. This is 25 | ;; the start of me collecting the things I do. 26 | 27 | ;;; Code: 28 | 29 | (require 'rx) 30 | 31 | (defvar livecoder-comment-pos nil 32 | "Stores the last code position when we're editing a comment.") 33 | 34 | ;;;###autoload 35 | (defun livecoder-comment-edit () 36 | "Toggle between editing a comment and code. 37 | 38 | Edit the comment at the start of a top level form and switch back 39 | to the previous position when you're done. 40 | 41 | This is intended to make screencast recording simple. It's 42 | probably not much better than just using the keys to go to the 43 | top and then editing... but it is a little quicker." 44 | (interactive) 45 | (if (markerp livecoder-comment-pos) 46 | (progn 47 | (goto-char livecoder-comment-pos) 48 | (set-marker livecoder-comment-pos nil) 49 | (setq livecoder-comment-pos nil)) 50 | (setq livecoder-comment-pos (point-marker)) 51 | (beginning-of-defun) 52 | (forward-line -1) 53 | (beginning-of-line) 54 | (if (looking-at (rx-to-string `(and bol ,comment-start))) 55 | (goto-char (re-search-forward ";+ *" nil (line-end-position))) 56 | (insert (format "%s " comment-start))))) 57 | 58 | ;;;###autoload 59 | (defun livecoder-hookup () 60 | "Call this from a mode hook to init livecoder." 61 | ;; Not sure about the key binding 62 | (local-set-key (kbd "C-c e") 'livecoder-comment-edit)) 63 | 64 | 65 | (provide 'livecoder) 66 | 67 | ;;; livecoder.el ends here 68 | --------------------------------------------------------------------------------