changeset 613: |
9ffe93dbe9b9 |
parent 612: |
9238c034b97e |
child 614: |
f03dbf6338ed |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Mon, 19 Aug 2024 20:24:03 -0400 |
files: |
emacs/default.el emacs/keys.el emacs/lib/publish.el |
description: |
el tweaks |
1.1--- a/emacs/default.el Mon Aug 19 20:00:04 2024 -0400
1.2+++ b/emacs/default.el Mon Aug 19 20:24:03 2024 -0400
1.3@@ -771,6 +771,40 @@
1.4 ("C" . "comment")
1.5 ("v" . "verse")))
1.6
1.7+(defun org-schedule-effort ()
1.8+(interactive)
1.9+ (save-excursion
1.10+ (org-back-to-heading t)
1.11+ (let* (
1.12+ (element (org-element-at-point))
1.13+ (effort (org-element-property :EFFORT element))
1.14+ (scheduled (org-element-property :scheduled element))
1.15+ (ts-year-start (org-element-property :year-start scheduled))
1.16+ (ts-month-start (org-element-property :month-start scheduled))
1.17+ (ts-day-start (org-element-property :day-start scheduled))
1.18+ (ts-hour-start (org-element-property :hour-start scheduled))
1.19+ (ts-minute-start (org-element-property :minute-start scheduled)) )
1.20+ (org-schedule nil (concat
1.21+ (format "%s" ts-year-start)
1.22+ "-"
1.23+ (if (< ts-month-start 10)
1.24+ (concat "0" (format "%s" ts-month-start))
1.25+ (format "%s" ts-month-start))
1.26+ "-"
1.27+ (if (< ts-day-start 10)
1.28+ (concat "0" (format "%s" ts-day-start))
1.29+ (format "%s" ts-day-start))
1.30+ " "
1.31+ (if (< ts-hour-start 10)
1.32+ (concat "0" (format "%s" ts-hour-start))
1.33+ (format "%s" ts-hour-start))
1.34+ ":"
1.35+ (if (< ts-minute-start 10)
1.36+ (concat "0" (format "%s" ts-minute-start))
1.37+ (format "%s" ts-minute-start))
1.38+ "+"
1.39+ effort)) )))
1.40+
1.41 (setopt org-preview-latex-image-directory "~/.emacs.d/.cache/ltximg"
1.42 org-latex-image-default-width "8cm"
1.43 org-refile-use-cache t
2.1--- a/emacs/keys.el Mon Aug 19 20:00:04 2024 -0400
2.2+++ b/emacs/keys.el Mon Aug 19 20:24:03 2024 -0400
2.3@@ -64,6 +64,7 @@
2.4 :doc "User-specified keymap for review functions. Usually bound to 'C-c c r'."
2.5 "s" #'flyspell-buffer
2.6 "SPC" #'whitespace-cleanup
2.7+ "C-s" #'org-schedule-effort
2.8 "u" #'untabify
2.9 "q" #'query-replace-regexp)
2.10
2.11@@ -99,7 +100,7 @@
2.12 "r" review-map
2.13 "q" server-map
2.14 "(" parens-map
2.15- "M-l" #'duplicate-dwim
2.16+ "M-l" #'duplicate-dwim
2.17 "d i" #'image-dired
2.18 "<tab>" #'outline-cycle
2.19 "<backtab>" #'outline-cycle-buffer
3.1--- a/emacs/lib/publish.el Mon Aug 19 20:00:04 2024 -0400
3.2+++ b/emacs/lib/publish.el Mon Aug 19 20:24:03 2024 -0400
3.3@@ -15,7 +15,7 @@
3.4 (defvar vc-url "https://vc.compiler.company")
3.5 (defvar packy-url "https://packy.compiler.company")
3.6 (defvar html-nav (format "<div class=\"nav\" id=\"nav\"><h2 id=\"index\">*</h2><div id=\"text-index\"> (<a href = \"%s\">~</a><br> (<a href = \"%s/blog\">blog</a> <a href = \"%s/docs\">docs</a> <a href = \"%s/plan\">plan</a> <a href = \"%s/notes\">notes</a>)<br> (<a href = \"%s\">vc</a> <a href = \"%s\">packy</a>))</div></div>"
3.7- url url url url url vc-url packy-url))
3.8+ url url url url url vc-url packy-url))
3.9
3.10 (defvar html-foot "<footer><p>updated %C</p></footer>")
3.11
3.12@@ -108,82 +108,82 @@
3.13 :html-preamble ,html-nav
3.14 :html-postamble ,html-foot)))
3.15
3.16- (defun org-export-get-reference-title (datum info)
3.17- "Like `org-export-get-reference', except uses heading titles instead of random numbers."
3.18- (let ((cache (plist-get info :internal-references)))
3.19- (or (car (rassq datum cache))
3.20- (let* ((crossrefs (plist-get info :crossrefs))
3.21- (cells (org-export-search-cells datum))
3.22- ;; Preserve any pre-existing association between
3.23- ;; a search cell and a reference, i.e., when some
3.24- ;; previously published document referenced a location
3.25- ;; within current file (see
3.26- ;; `org-publish-resolve-external-link').
3.27- ;;
3.28- ;; However, there is no guarantee that search cells are
3.29- ;; unique, e.g., there might be duplicate custom ID or
3.30- ;; two headings with the same title in the file.
3.31- ;;
3.32- ;; As a consequence, before re-using any reference to
3.33- ;; an element or object, we check that it doesn't refer
3.34- ;; to a previous element or object.
3.35- (new (or (cl-some
3.36- (lambda (cell)
3.37- (let ((stored (cdr (assoc cell crossrefs))))
3.38- (when stored
3.39- (let ((old (org-export-format-reference stored)))
3.40- (and (not (assoc old cache)) stored)))))
3.41- cells)
3.42- (when (org-element-property :raw-value datum)
3.43- ;; Heading with a title
3.44- (org-export-new-title-reference datum cache))
3.45- ;; NOTE: This probably breaks some Org Export
3.46- ;; feature, but if it does what I need, fine.
3.47- (org-export-format-reference
3.48- (org-export-new-reference cache))))
3.49- (reference-string new))
3.50- ;; Cache contains both data already associated to
3.51- ;; a reference and in-use internal references, so as to make
3.52- ;; unique references.
3.53- (dolist (cell cells) (push (cons cell new) cache))
3.54- ;; Retain a direct association between reference string and
3.55- ;; DATUM since (1) not every object or element can be given
3.56- ;; a search cell (2) it permits quick lookup.
3.57- (push (cons reference-string datum) cache)
3.58- (plist-put info :internal-references cache)
3.59- reference-string))))
3.60+;; (defun org-export-get-reference-title (datum info)
3.61+;; "Like `org-export-get-reference', except uses heading titles instead of random numbers."
3.62+;; (let ((cache (plist-get info :internal-references)))
3.63+;; (or (car (rassq datum cache))
3.64+;; (let* ((crossrefs (plist-get info :crossrefs))
3.65+;; (cells (org-export-search-cells datum))
3.66+;; ;; Preserve any pre-existing association between
3.67+;; ;; a search cell and a reference, i.e., when some
3.68+;; ;; previously published document referenced a location
3.69+;; ;; within current file (see
3.70+;; ;; `org-publish-resolve-external-link').
3.71+;; ;;
3.72+;; ;; However, there is no guarantee that search cells are
3.73+;; ;; unique, e.g., there might be duplicate custom ID or
3.74+;; ;; two headings with the same title in the file.
3.75+;; ;;
3.76+;; ;; As a consequence, before re-using any reference to
3.77+;; ;; an element or object, we check that it doesn't refer
3.78+;; ;; to a previous element or object.
3.79+;; (new (or (cl-some
3.80+;; (lambda (cell)
3.81+;; (let ((stored (cdr (assoc cell crossrefs))))
3.82+;; (when stored
3.83+;; (let ((old (org-export-format-reference stored)))
3.84+;; (and (not (assoc old cache)) stored)))))
3.85+;; cells)
3.86+;; (when (org-element-property :raw-value datum)
3.87+;; ;; Heading with a title
3.88+;; (org-export-new-title-reference datum cache))
3.89+;; ;; NOTE: This probably breaks some Org Export
3.90+;; ;; feature, but if it does what I need, fine.
3.91+;; (org-export-format-reference
3.92+;; (org-export-new-reference cache))))
3.93+;; (reference-string new))
3.94+;; ;; Cache contains both data already associated to
3.95+;; ;; a reference and in-use internal references, so as to make
3.96+;; ;; unique references.
3.97+;; (dolist (cell cells) (push (cons cell new) cache))
3.98+;; ;; Retain a direct association between reference string and
3.99+;; ;; DATUM since (1) not every object or element can be given
3.100+;; ;; a search cell (2) it permits quick lookup.
3.101+;; (push (cons reference-string datum) cache)
3.102+;; (plist-put info :internal-references cache)
3.103+;; reference-string))))
3.104
3.105- (defun org-export-new-title-reference (datum cache)
3.106- "Return new reference for DATUM that is unique in CACHE."
3.107- (cl-macrolet ((inc-suffixf (place)
3.108- `(progn
3.109- (string-match (rx bos
3.110- (minimal-match (group (1+ anything)))
3.111- (optional "--" (group (1+ digit)))
3.112- eos)
3.113- ,place)
3.114- ;; HACK: `s1' instead of a gensym.
3.115- (-let* (((s1 suffix) (list (match-string 1 ,place)
3.116- (match-string 2 ,place)))
3.117- (suffix (if suffix
3.118- (string-to-number suffix)
3.119- 0)))
3.120- (setf ,place (format "%s--%s" s1 (cl-incf suffix)))))))
3.121- (let* ((title (org-element-property :raw-value datum))
3.122- (ref (url-hexify-string (substring-no-properties title)))
3.123- (parent (org-element-property :parent datum)))
3.124- (while (--any (equal ref (car it))
3.125- cache)
3.126- ;; Title not unique: make it so.
3.127- (if parent
3.128- ;; Append ancestor title.
3.129- (setf title (concat (org-element-property :raw-value parent)
3.130- "--" title)
3.131- ref (url-hexify-string (substring-no-properties title))
3.132- parent (org-element-property :parent parent))
3.133- ;; No more ancestors: add and increment a number.
3.134- (inc-suffixf ref)))
3.135- ref)))
3.136+;; (defun org-export-new-title-reference (datum cache)
3.137+;; "Return new reference for DATUM that is unique in CACHE."
3.138+;; (cl-macrolet ((inc-suffixf (place)
3.139+;; `(progn
3.140+;; (string-match (rx bos
3.141+;; (minimal-match (group (1+ anything)))
3.142+;; (optional "--" (group (1+ digit)))
3.143+;; eos)
3.144+;; ,place)
3.145+;; ;; HACK: `s1' instead of a gensym.
3.146+;; (-let* (((s1 suffix) (list (match-string 1 ,place)
3.147+;; (match-string 2 ,place)))
3.148+;; (suffix (if suffix
3.149+;; (string-to-number suffix)
3.150+;; 0)))
3.151+;; (setf ,place (format "%s--%s" s1 (cl-incf suffix)))))))
3.152+;; (let* ((title (org-element-property :raw-value datum))
3.153+;; (ref (url-hexify-string (substring-no-properties title)))
3.154+;; (parent (org-element-property :parent datum)))
3.155+;; (while (--any (equal ref (car it))
3.156+;; cache)
3.157+;; ;; Title not unique: make it so.
3.158+;; (if parent
3.159+;; ;; Append ancestor title.
3.160+;; (setf title (concat (org-element-property :raw-value parent)
3.161+;; "--" title)
3.162+;; ref (url-hexify-string (substring-no-properties title))
3.163+;; parent (org-element-property :parent parent))
3.164+;; ;; No more ancestors: add and increment a number.
3.165+;; (inc-suffixf ref)))
3.166+;; ref)))
3.167
3.168 ;; (advice-add #'org-export-get-reference :override #'org-export-get-reference-title)
3.169