-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the nano writer mode (prototype)
- Loading branch information
Showing
2 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
;; --------------------------------------------------------------------- | ||
;; GNU Emacs / N Λ N O - Emacs made simple | ||
;; Copyright (C) 2020 - N Λ N O developers | ||
;; | ||
;; 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 3 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, see <http://www.gnu.org/licenses/>. | ||
;; --------------------------------------------------------------------- | ||
(require 'org) | ||
|
||
(defun writer-mode--num-format (numbering) | ||
"Alternative numbering format for org-num. | ||
First level: 1 | xxx | ||
Second level: 1.1 — xxx | ||
Third level: 1.1.1 - xxx | ||
etc. | ||
""" | ||
(if (= (length numbering) 1) | ||
(propertize (concat (mapconcat | ||
#'number-to-string | ||
numbering ".") " | " ) | ||
'face `(:family "Roboto Condensed" | ||
:height 250 | ||
:foreground ,nano-color-faded)) | ||
(propertize (concat (mapconcat | ||
#'number-to-string | ||
numbering ".") " — " ) | ||
'face `(:family "Roboto Condensed" | ||
:foreground ,nano-color-faded)))) | ||
|
||
;; Specific face for headline stars | ||
(font-lock-add-keywords 'writer-mode | ||
'(("^*+ " 0 `(:family "Roboto Mono" | ||
:height 140 | ||
:foreground ,nano-color-faded) prepend) | ||
) 'append) | ||
|
||
(defun writer-mode--compute-prefixes () | ||
"Compute prefix strings for regular text and headlines." | ||
|
||
(setq org-indent--heading-line-prefixes | ||
(make-vector org-indent--deepest-level nil)) | ||
(setq org-indent--inlinetask-line-prefixes | ||
(make-vector org-indent--deepest-level nil)) | ||
(setq org-indent--text-line-prefixes | ||
(make-vector org-indent--deepest-level nil)) | ||
|
||
(let* ((min-indent 5) | ||
(indent (+ 1 (seq-max | ||
(org-element-map | ||
(org-element-parse-buffer) 'headline | ||
#'(lambda (item) | ||
(org-element-property :level item)))))) | ||
(indent (max indent min-indent))) | ||
|
||
(dotimes (n org-indent--deepest-level) | ||
(aset org-indent--heading-line-prefixes n | ||
(make-string | ||
(min indent (max 0 (- indent 1 n))) ?\s)) | ||
(aset org-indent--inlinetask-line-prefixes n | ||
(make-string indent ?\s)) | ||
(aset org-indent--text-line-prefixes n | ||
(make-string indent ?\s))))) | ||
|
||
|
||
|
||
(define-derived-mode writer-mode org-mode "NΛNO writer" | ||
|
||
;; Faces | ||
(face-remap-add-relative 'org-level-1 | ||
:overline nano-color-subtle | ||
:family "Roboto" :height 180) | ||
(face-remap-add-relative 'org-level-2 | ||
:family "Roboto" :height 160) | ||
(face-remap-add-relative 'org-level-3 | ||
:family "Roboto" :height 150) | ||
|
||
;; Header line | ||
(setq header-line-format nil) | ||
|
||
;; Layout | ||
(setq fill-column 72) | ||
(setq-default line-spacing 1) | ||
|
||
;; Indentation | ||
(setq org-startup-folded nil) | ||
(org-indent-mode) | ||
(setq org-level-color-stars-only nil) | ||
(setq org-hide-leading-stars nil) | ||
(advice-add 'org-indent--compute-prefixes :override | ||
#'writer-mode--compute-prefixes) | ||
|
||
;; Numbering | ||
(setq org-num-skip-unnumbered t) | ||
(setq org-num-skip-footnotes t) | ||
(setq org-num-max-level 2) | ||
(setq org-num-face nil) | ||
(org-num-mode) | ||
(setq org-num-format-function 'writer-mode--num-format) | ||
|
||
;; Markup | ||
(make-variable-buffer-local 'org-emphasis-alist) | ||
(setq org-emphasis-alist '(("*" bold) | ||
("/" italic) | ||
("_" underline) | ||
("=" org-verbatim verbatim) | ||
("~" org-code verbatim) | ||
("+" (:family "Roboto Slab" | ||
:weight 'bold :height 200))))) | ||
|
||
(provide 'nano-writer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
|
||
+NΛNO Writer Mode+ | ||
/Nicolas P. Rougier — December 2020/ | ||
|
||
*Abstract |* NΛNO writer mode is an emacs minor mode based on org-mode | ||
whose goal is to offer a nice writing environment such that | ||
it is not necessary to transform the document to read it, | ||
GNU Emacs being the main reader. | ||
|
||
|
||
* Introduction | ||
|
||
Following up my article on the design of text editors /[1]/, this is an | ||
experiment at designing a template for scientific article that can be | ||
read and interacted with directly from within GNU Emacs based on the | ||
all-mighty org-mode. | ||
|
||
** Alternative indentation | ||
|
||
|
||
By tweaking =org-indent--compute-prefixes=, it is possible to align text | ||
on the left and have the leading stars in the margin. | ||
|
||
** Typography | ||
|
||
Body font is [[https://fonts.google.com/specimen/Roboto+Mono][Roboto Mono Light]], title font is [[https://fonts.google.com/specimen/Roboto+Slab][Roboto Slab]], headers font | ||
is [[https://fonts.google.com/specimen/Roboto][Roboto]] and theme is [[https://github.com/rougier/nano-emacs][NΛNO light theme]] /[2]/. Line spacing is 1. | ||
|
||
** Section numbering | ||
|
||
Automatic section numbering is done using org-num-mode with a special | ||
format function. | ||
|
||
|
||
* References | ||
:PROPERTIES: | ||
:UNNUMBERED: nil | ||
:END: | ||
|
||
*[1]* Rougier, N.P. 2020. *On the design of text editors*, [[https://arxiv.org/abs/2008.06030][arXiv]]. | ||
*[2]* Rougier, N.P. 2020. *GNU Emacs / N Λ N O*, [[https://github.com/rougier/nano-emacs][GitHub]]. |