emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] feature/new-tutorial 2367af9 06/10: First org-mode tutoria


From: Phillip Lord
Subject: [Emacs-diffs] feature/new-tutorial 2367af9 06/10: First org-mode tutorial
Date: Thu, 18 May 2017 05:18:53 -0400 (EDT)

branch: feature/new-tutorial
commit 2367af9cae9b5a30a8cf41d8ab720a5d0e457870
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>

    First org-mode tutorial
---
 lisp/tutorial-org.el | 34 +++++++++++++++++++++++++++++++++-
 lisp/tutorial.el     |  2 +-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/lisp/tutorial-org.el b/lisp/tutorial-org.el
index f71cd65..e74e7f5 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 9a0c246..780c1ef 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]