summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Lord <phillip.lord@russet.org.uk>2017-05-07 23:41:29 +0100
committerPhillip Lord <phillip.lord@russet.org.uk>2017-05-07 23:41:29 +0100
commit2367af9cae9b5a30a8cf41d8ab720a5d0e457870 (patch)
tree5a1dc59b13bc0726cdd4b137c905f190508eafd9
parentd37b29909e397770d2ab8dd5a8e091fb82689961 (diff)
downloademacs-2367af9cae9b5a30a8cf41d8ab720a5d0e457870.tar.gz
First org-mode tutorial
-rw-r--r--lisp/tutorial-org.el34
-rw-r--r--lisp/tutorial.el2
2 files changed, 34 insertions, 2 deletions
diff --git a/lisp/tutorial-org.el b/lisp/tutorial-org.el
index f71cd653880..e74e7f57997 100644
--- a/lisp/tutorial-org.el
+++ b/lisp/tutorial-org.el
@@ -26,10 +26,42 @@
;; Code for running the Emacs Tutorials written in org-mode.
;;; Code:
+(require 'subr-x)
+(define-derived-mode tutorial-org-mode org-mode "Tutor"
+ "A mode for displaying tutorials."
+ (show-all)
+ (setq-local org-hide-emphasis-markers t))
+
+(defun tutorial-org--display-buffer (tutorial-buffer-name)
+ (when-let ((tutorial-buffer
+ (get-buffer-window tutorial-buffer-name t)))
+ (raise-frame
+ (window-frame
+ (select-window tutorial-window))))
+ (switch-to-buffer tutorial-buffer)
+ ;; Use whole frame for tutorial
+ (delete-other-windows))
+
+(defun tutorial-org-display (org-file)
+ "Display the org-file as a tutorial"
+ (let* ((tutorial-buffer-name
+ (file-name-nondirectory
+ (file-name-sans-extension
+ org-file)))
+ (tutorial-buffer (get-buffer-create tutorial-buffer-name)))
+ ;; Display it
+ (tutorial-org--display-buffer tutorial-buffer)
+ ;; Fill it if needed
+ (when (= 0 (buffer-size tutorial-buffer))
+ (insert-file-contents org-file)
+ (tutorial-org-mode))))
(defun tutorial-org--help-with-tutorial-org (lang)
- (error "not implemented yet"))
+ (tutorial-org-display
+ (expand-file-name
+ (get-language-info lang 'tutorial-org)
+ tutorial-org-directory)))
(provide 'tutorial-org)
diff --git a/lisp/tutorial.el b/lisp/tutorial.el
index 9a0c2468a8a..780c1ef8894 100644
--- a/lisp/tutorial.el
+++ b/lisp/tutorial.el
@@ -768,7 +768,7 @@ enabled Viper.")
(if (get-language-info lang 'tutorial-org)
'org 'orig)))
(if (get-language-info lang 'tutorial-org)
- (tutorial--help-with-tutorial-org lang)
+ (tutorial-org--help-with-tutorial-org lang)
(tutorial--help-with-tutorial-orig lang dont-ask-for-revert)))))
(defun tutorial--help-with-tutorial-orig (lang dont-ask-for-revert)