]> git.eshelyaron.com Git - emacs.git/commitdiff
First org-mode tutorial
authorPhillip Lord <phillip.lord@russet.org.uk>
Sun, 7 May 2017 22:41:29 +0000 (23:41 +0100)
committerPhillip Lord <phillip.lord@russet.org.uk>
Sun, 7 May 2017 22:41:29 +0000 (23:41 +0100)
lisp/tutorial-org.el
lisp/tutorial.el

index f71cd6538807c1ed205151054763fbcb70ab8491..e74e7f57997554e8a92f56c158cd2f62b92c4540 100644 (file)
 ;; 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)
 
index 9a0c2468a8aefef7b8b007000712b533746f0381..780c1ef8894f77f6e713ce748e176fd970d8b7a5 100644 (file)
@@ -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)