UP | HOME

Meta-Notes

Table of Contents

1 Introduction

Notes about these notes.

2 Org-Mode

Regarding org-mode commands and quirks.

2.1 LaTeX Macros

I follow this general scheme when adding more LaTeX macros to my org-macros.org file: add them to a latex-macros source code environment, add the following lines to my ~/.emacs.d/init.el file:

(add-to-list 'org-src-lang-modes '("latex-macros" . latex))

(defvar org-babel-default-header-args:latex-macros
  '((:results . "raw")
    (:exports . "results")))

(defun prefix-all-lines (pre body)
  (with-temp-buffer
    (insert body)
    (string-insert-rectangle (point-min) (point-max) pre)
    (buffer-string)))

(defun org-babel-execute:latex-macros (body _params)
  (concat
   (prefix-all-lines "#+LATEX_HEADER: " body)
   "\n#+HTML_HEAD_EXTRA: <div style=\"display: none\"> \\(\n"
   (prefix-all-lines "#+HTML_HEAD_EXTRA: " body)
   "\n#+HTML_HEAD_EXTRA: \\)</div>\n"))

2.2 Exporting Source code

If I add to the header of an org file:

 #+begin_src lang tangle: my-file.lisp ...

Then by default, all source code blocks will be evaluated as if it had tangle: my-file.lisp.

2.2.1 Keeping the Noweb labels in documentation

If we want to keep the noweb labels inlined in the code blocks when exporting to HTML or whatever, then we should also add:

 #+begin_src lang :noweb no-export ...

It appears that the Noweb label can include whitespace, though it may be useful to use snake_case. When we want to define or append code to a noweb label, we write

 #+begin_src lang ... :noweb-ref [label]

It seems like it must be the last element in the "begin source" line.

2.3 Custom Environments ("Blocks")

I can add custom blocks and shortcuts to expand <xxx into blocks with the following elisp:

(require 'org-tempo)
(setq org-structure-template-alist '(("a" . "export ascii")
                                     ("c" . "center")
                                     ("C" . "comment")
                                     ("e" . "example")
                                     ("E" . "export")
                                     ("h" . "export html")
                                     ("l" . "export latex")
                                     ("q" . "quote")
                                     ("s" . "src")
                                     ("v" . "verse")
                                     ("rmk" . "remark")
                                     ("cor" . "corollary")
                                     ("thm" . "theorem")
                                     ("prop" . "proposition")
                                     ("lem" . "lemma")
                                     ("pz" . "puzzle")
                                     ("xca" . "exercise")
                                     ("ex" . "math-example")
                                     ("eg" . "math-example")
                                     ("d" . "definition")
                                     ("dan" . "danger")
                                     ("pf" . "proof")))

2.4 Publishing

I'd need to add to my ~/.emacs file

(require 'ox-publish)
(setq org-publish-project-alist '())
(add-to-list 'org-publish-project-alist
      '("org-notes"
         :base-directory "~/org-notes/"
         :base-extension "org"
         :publishing-directory "~/org-notes/html/"
         :recursive t
         :publishing-function org-html-publish-to-html
         :exclude "\\(html\\|ignore\\)/"
         ))

(add-to-list 'org-publish-project-alist
        '("org-static"
        :base-directory "~/org-notes/"
        :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
        :publishing-directory "~/org-notes/html/"
        :recursive t
        :publishing-function org-publish-attachment
        :exclude "\\(html\\|ignore\\)/"
        ))

(add-to-list 'org-publish-project-alist
             '("all" :components ("all-notes" "org-static")))

We avoid writing the postamble:

(eval-after-load "ox-html" (setq org-html-postamble nil))

And we can permit evaluating source blocks automatically:

(setq org-confirm-babel-evaluate nil) ; don't ask for confirmation before evaluating a code block
(setq org-export-babel-evaluate t)
(setq org-export-use-babel t)

2.5 Org-ids

When publishing, org-ids are generated by timestamp (at the time of publishing), so although a page may not substantively change, it republishes erroneously. I looked to fix this, and found Lee Hinman wrote a solution:

(require 'org-id)
(setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)

(defun eos/org-custom-id-get (&optional pom create prefix)
  "Get the CUSTOM_ID property of the entry at point-or-marker POM.
   If POM is nil, refer to the entry at point. If the entry does
   not have an CUSTOM_ID, the function returns nil. However, when
   CREATE is non nil, create a CUSTOM_ID if none is present
   already. PREFIX will be passed through to `org-id-new'. In any
   case, the CUSTOM_ID of the entry is returned."
  (interactive)
  (org-with-point-at pom
    (let ((id (org-entry-get nil "CUSTOM_ID")))
      (cond
       ((and id (stringp id) (string-match "\\S-" id))
        id)
       (create
        (setq id (org-id-new (concat prefix "h")))
        (org-entry-put pom "CUSTOM_ID" id)
        (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
        id)))))

(defun eos/org-add-ids-to-headlines-in-file ()
  "Add CUSTOM_ID properties to all headlines in the
   current file which do not already have one."
  (interactive)
  (org-map-entries (lambda () (eos/org-custom-id-get (point) 'create))))

;; automatically add ids to saved org-mode headlines
(add-hook 'org-mode-hook
          (lambda ()
            (add-hook 'before-save-hook
                      (lambda ()
                        (when (and (eq major-mode 'org-mode)
                                   (eq buffer-read-only nil))
                          (eos/org-add-ids-to-headlines-in-file))))))

(defun org-id-new (&optional prefix)
  "Create a new globally unique ID.

An ID consists of two parts separated by a colon:
- a prefix
- a unique part that will be created according to `org-id-method'.

PREFIX can specify the prefix, the default is given by the variable
`org-id-prefix'.  However, if PREFIX is the symbol `none', don't use any
prefix even if `org-id-prefix' specifies one.

So a typical ID could look like \"Org-4nd91V40HI\"."
  (let* ((prefix (if (eq prefix 'none)
                     ""
                   (concat (or prefix org-id-prefix) "-")))
         unique)
    (if (equal prefix "-") (setq prefix ""))
    (cond
     ((memq org-id-method '(uuidgen uuid))
      (setq unique (org-trim (shell-command-to-string org-id-uuid-program)))
      (unless (org-uuidgen-p unique)
        (setq unique (org-id-uuid))))
     ((eq org-id-method 'org)
      (let* ((etime (org-reverse-string (org-id-time-to-b36)))
             (postfix (if org-id-include-domain
                          (progn
                            (require 'message)
                            (concat "@" (message-make-fqdn))))))
        (setq unique (concat etime postfix))))
     (t (error "Invalid `org-id-method'")))
    (concat prefix unique)))

2.6 Color Choices

I've used syntax highlighting based off of Github's style. In my ~/.emacs.d/init.el file, I've got:

(org-babel-do-load-languages
 'org-babel-load-languages
 '((scheme . t)
   (emacs-lisp . t)
   (lisp . t)
   (C . t)))

(setq org-html-htmlize-output-type 'css) ; export HTML classes & css syling
(setq org-html-htmlize-font-prefix "org-")
(setq org-src-preserve-indentation t)
(setq org-src-fontify-natively t) ; export syntax highlighting

This setup permits overriding the style using a CSS file, prefixing all the element classes with org-*.

Sarah Rovner-Frydman uses the following color schema:

set recolor-darkcolor "#B0C6D7" set recolor-lightcolor "#141D26"

I am using PT serif for my main font, Sans Serif Code for the teletype font,

3 Subject Classification

I'm not sure how best to organize my notes. There are a number of classification systems for the subjects I am interested in studying. These are too coarse, not quite right, but interesting nevertheless, so I'm sticking them in my meta-notes.

3.1 Mathematical Subject Classification

  • General, foundations
  • Discrete mathematics, algebra
  • Analysis
  • Geometry and Topology
  • Applied mathematics, other

3.2 Physics and Astronomy Classification System

  • General
  • The Physics of Elementary Particles and Fields
  • Nuclear Physics
  • Atomic and Molecular Physics
  • Electromagnetism, Optics, Acoustics, Heat Transfer, Classical Mechanics, and Fluid Dynamics
  • Physics of Gases, Plasmas, and Electric Discharges
  • Condensed Matter: Structure, Mechanical and Thermal Properties
  • Condensed Matter: Electronic Structure, Electrical, Magnetic, and Optical Properties
  • Interdisciplinary Physics and Related Areas of Science and Technology
  • Geophysics, Astronomy, and Astrophysics

3.3 ACM Computing Classification System

  1. General and reference
  2. Hardware
  3. Computer System Organization
  4. Networks
  5. Software and its engineering
  6. Theory of computation
  7. Mathematics of computing
  8. Information Systems
  9. Security and Privacy
  10. Human-centered computing
  11. Computing Methodologies
  12. Applied computing
  13. Social and professional topics

Last Updated 2021-04-11 Sun 12:08.