My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/prototypes/novelist/novelist-mode.el

122 lines
3.8 KiB

;;; novelist-mode.el --- A major mode for writing novels, short stories, and other prose
;; Copyright (C) 2020-2021 Katharina Fey <kookie@spacekookie>
;; Author: Katharina Fey
;; URL: http://git.open-communication.net/spacekookie/novelist-mode
;; Created: 2020
;; Version: 0.1
;; Keywords: writing novels stories
;; Package-Requires: (transient "20200819.1133")
;; This file is NOT part of GNU Emacs.
;;
;;; Commentary:
;;
;; An application mode to create and manage prose writing in emacs
(provide 'novelist)
;;;###autoload
(defun novelist-project-create ()
"Interactively create a new novelist project."
(interactive))
;;;###autoload
(define-transient-command novelist-menu ()
"Display the primary interactive action menu for novelist-mode"
["Project Actions"
("c" "Create a new novelist project on disk" novelist-project-create)
("v" "Toggle the project explorer overview" novelist-path-overview)
("a" "Add some resource to the project" novelist-add)
("d" "Delete some resource from the project" novelist-delete)
]
["Selection Actions"
("n" "Show the hidden note buffer for a selected resource" novelist-path-notes)
("m" "Show the metadata editor for a selected resource" novelist-path-metadata)
])
(defun display-prefix (&optional arg)
"Display the value of the raw prefix arg."
(interactive "P")
(if (= arg nil)
(message "No prefix argument was given!")
(message "Provided prefix argument: %s" arg)))
;; (message path))
;; (when (arg) (setq path read-file-name))
;; (message "%s" arg))
(defun nv--setup-buffer ()
"Setup various display settings for novelist-mode"
(interactive)
(setq buffer-face-mode-face '(:family "Literata" :height 200))
(visual-line-mode 1)
(sublimity-mode)
(text-mode)
(sublimity-attractive-hide-fringes)
(buffer-face-mode)
(setq line-spacing 15))
(defun novelist-project-create ()
"Create a new novelist project on disk, with an optional universe"
(interactive)
(setq name (read-string "Enter project name: "))
(setq path (read-directory-name "Where to create this project: "))
(setq universe (when (y-or-n-p "Do you want to link an external .universe resource? ")
(read-file-name "Select .universe resource index")))
(nv--project-create name path universe))
(defun novelist-project-load ()
"Load an existing project index file from disk"
(interactive)
(setq index (read-file-name "Select .novel project index file")))
(defun novelist-add ()
"Add a new resource to the currently selected project"
(interactive))
(defun novelist-delete ()
"Move a resource to trash via it's path. Optionally delete immediately"
(interactive))
(defun novelist-path-overview ()
"Bring up the project explorer overview"
(interactive))
(defun novelist-path-notes ()
"Bring up the note section for a given path"
(interactive))
(defun novelist-path-metadata ()
"Bring up a special metadata section for a given path"
(interactive))
;;;; Internal functions
(defun nv--project-create (name path &optional universe)
"Create a new novelist project"
(message "Creating project '%s%s'" path name)
(setq root (concat path name))
(make-directory root t)
(make-directory (concat root "/notes"))
(make-directory (concat root "/meta"))
(make-directory (concat root "/templates"))
(make-directory (concat root "/data")))
;; (visual-line-mode 0)
;; (eldoc-mode 1)
;; (display-line-numbers-mode 1)
;; Increase the text size, change the font to Literata
## This is a heading
;; Something is a problem here! "Oh no," he screamed.
;; "This is really an inconvenience," Ira said. "What do they want from us now? Rhey shrugged. They didn't really know either. What were they going to do? It wasn't really clear at the time but it would become apparent later on.
;; "We need to keep moving," they said and stood up.