;;QML-mode.el : an emacs mode for editing QML files ;;Copyright (C) 2002 : Steven G. Harms ;; ;;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 the Free Software Foundation; either version 2 ;;of the License, or (at your option) any later version. ;; ;;This program is distributed in the hope that it will be useful, ;;but WITHOUT ANY WARRANTY; without even the implied warranty of ;;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;GNU General Public License for more details. ;; ;;You should have received a copy of the GNU General Public License ;;along with this program; if not, write to the Free Software ;;Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;; ;; ;;This is an emacs mode for creating a very basic series of "QML" ;;entries. A QML file is likely to be read by an application which ;;parses the entries into a flash-card type application. ;; ;; ;;To have this autoload, add the following to your .emacs ;; ;;(autoload 'qml-mode "/home/sgharms/elisp/qml.el" "Hooray for Question ;;Markup Language" t) ;; ;;(set q auto-mode-alist (cons '("\\.qml$" . qml-mode) ;;auto-mode-alist)) (defvar qml-mode-hook nil "*List of functions to cass when entering [Q]uestions[M]arkup[L]anguage*") (defvar qml-mode-map nil "Kefmap for the qml major mode.") (if qml-mode-map nil (setq qml-mode-map (make-keymap)) (define-key qml-mode-map "\C-ct" 'qml-insert-full-template) (define-key qml-mode-map "\C-cf" 'qml-insert-full-question-template) (define-key qml-mode-map "\C-cc" 'qml-insert-choice) (define-key qml-mode-map "\C-ca" 'qml-insert-answer) (define-key qml-mode-map "\C-cq" 'qml-insert-question) (define-key qml-mode-map "\C-cy" 'qml-true-or-false-question) (define-key qml-mode-map "\C-ci" 'qml-insert-full-question-interactively) ) ;;In case you need the template, this is less preferable to ;;qml-insert-full-question-interactively. The latter will ;;interactively ask questions so that you needn't do so much ;;navigation (defun qml-insert-full-question-template () "Function to insert a full XML block." (interactive) (insert-string " ") (previous-line 8) (end-of-line) (backward-char 2) ) (defun qml-mode () "Major mode for creating question XML files." (interactive) (kill-all-local-variables) (setq major-mode 'qml-mode) (setq mode-name "QML") (use-local-map qml-mode-map) (run-hooks 'qml-mode-hook)) ;;The standard way of inserting a question (defun qml-insert-full-question-interactively (id question c0 c1 c2 c3 ans) "Function to insert a full XML block." (interactive "sID:\nsQuestion:\nsChoice 0:\nsChoice 1:\nsChoice 2:\nsChoice 3:\nsAnswer:") (insert-string (concat " ")) (insert-string(concat " " question "")) (insert-string (concat " " c0 " " c1 " " c2 " " c3 " " ans " \n"))) ;;Create a true or false block. (defun qml-true-or-false-question (id question ans) "Function to insert a full XML block." (interactive "sID:\nsTrueFalse:\nsAnswer:") (insert-string (concat " ")) (insert-string(concat " " question "")) (insert-string (concat " " "True" " " "False" " " " " " " ans " \n"))) ;;For when you're just getting started (defun qml-insert-full-template () "Function to insert a full XML block." (interactive) (insert-string " ")) (defun qml-insert-choice () "Function to insert a element." (interactive) (insert-string " ") ) (defun qml-insert-answer () "Function to insert a element." (interactive) (insert-string " ") ) (defun qml-insert-question () "Function to insert a element." (interactive) (insert-string " ") ) (provide 'qml)