changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / emacs/lib/ulang.el

changeset 628: f7a10d8ee5ee
parent: 3af20cb389e8
child: f4a464cc1628
author: Richard Westhaver <ellis@rwest.io>
date: Mon, 26 Aug 2024 22:12:39 -0400
permissions: -rw-r--r--
description: no categories
1 ;;; ulang.el --- ulang compliance lib -*- lexical-binding:t -*-
2 
3 ;; Copyright (C) 2023
4 
5 ;; Author: <ellis@zor>
6 ;; Keywords: comm
7 
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12 
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17 
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20 
21 ;;; Commentary:
22 
23 ;;
24 
25 
26 ;;; Code:
27 (require 'org)
28 (require 'ox)
29 
30 (defgroup ulang nil
31  "CC Universal Language.")
32 
33 (defvar ulang-link-history nil)
34 (defvar ulang-file-history nil)
35 
36 ;;;###autoload
37 (defun dblock-insert-links (regexp)
38  "Create dblock to insert links matching REGEXP."
39  (interactive (list (read-regexp "Insert links matching: " nil ulang-links-history)))
40  (org-create-dblock (list :name "links"
41  :regexp regexp
42  :id-only nil))
43  (org-update-dblock))
44 
45 (org-dynamic-block-define "links" 'dblock-insert-links)
46 
47 (org-export-translate-to-lang (list '("Table of Contents" "Index")) "ulang")
48 ;; (setq org-export-global-macros nil)
49 
50 ;; todo keywords
51 (setq org-stuck-projects '("+PROJECT/-DONE" ("NEXT") nil ""))
52 
53 (setq org-todo-keywords
54  '((sequence "TBD(0!)" "TODO(t!)" "NEXT(n!)" "WIP(i!)" "|" "DONE(d!)")
55  (sequence "HOLD(H@/!)" "WIP(!)" "|")
56  (sequence "WAIT(W@/!)" "WIP(!)" "|")
57  (sequence "RESEARCH(s!)" "REPORT(c!)" "|")
58  (sequence "OUTLINE(O!)" "DRAFT(M!)" "REVIEW(V!)" "|")
59  (type "FIND(q!)" "READ(r@!)" "WATCH(A@!)" "HACK(h!)"
60  "CODE(c!)" "BENCH(b!)" "DEPLOY(D!)" "RUN(X!)"
61  "REFILE(w!)"
62  "LOG(L!)" "GOTO(g!)" "|")
63  (type "FIXME(f!)" "WIP(!)" "TEST(T!)" "|")
64  (type "PROJECT(p!)" "PRODUCT(P!)" "SPRINT(S!)" "RELEASE(R!)" "|")
65  (sequence "|" "DONE(d!)" "NOPE(x@!)")))
66 
67 (setq org-todo-keyword-faces
68  '(("PROJECT" . (:foreground "lightseagreen" :weight bold))
69  ("PRODUCT" . (:foreground "olivedrab" :weight bold))
70  ("RELEASE" . (:foreground "maroon3" :weight bold))
71  ("RESEARCH" . (:foreground "maroon2" :weight bold))
72  ("HACK" . (:foreground "maroon3" :weight bold))
73  ("TBD" . (:foreground "darkred2" :weight bold))
74  ;; ("NOTE" . (:foreground "tomato2" :weight bold))
75  ("CODE" . (:foreground "bisque" :weight bold :background "midnightblue"))
76  ("HOLD" . (:foreground "red1" :weight bold :background "yellow1"))
77  ("WAIT" . (:foreground "red4" :weight bold :background "yellow1"))
78  ("WIP" . (:foreground "darkorchid2" :weight bold))
79  ("NOPE" . (:foreground "hotpink" :weight bold :background "darkgreen"))))
80 
81 ;; link abbrevs
82 (setq org-link-abbrev-alist
83  '(("vc" . "https://vc.compiler.company/%s")
84  ("comp" . "https://compiler.company/%s")
85  ("cdn" . "https://cdn.compiler.company/%s")
86  ("packy" . "https://packy.compiler.company/%s")
87  ("yt" . "https://youtube.com/watch?v=%s")
88  ("wikipedia" . "https://en.wikipedia.org/wiki/%s")
89  ("reddit" . "https://reddit.com/%s")
90  ("hn" . "https://news.ycombinator.com/%s")
91  ("so" . "https://stackoverflow.com/%s")))
92 
93 ;;; IDs
94 (defun org-custom-id-get (&optional pom create prefix)
95  "Get the CUSTOM_ID property of the entry at point-or-marker POM.
96  If POM is nil, refer to the entry at point. If the entry does
97  not have an CUSTOM_ID, the function returns nil. However, when
98  CREATE is non nil, create a CUSTOM_ID if none is present
99  already. PREFIX will be passed through to `org-id-new'. In any
100  case, the CUSTOM_ID of the entry is returned."
101  (interactive)
102 (org-with-point-at pom
103  (let ((id (org-entry-get nil "CUSTOM_ID"))
104  ;; use CUSTOM_ID for links
105  (org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id))
106  (cond
107  ((and id (stringp id) (string-match "\\S-" id))
108  id)
109  (create
110  (setq id (org-id-new prefix))
111  (org-entry-put pom "CUSTOM_ID" id)
112  (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
113  id)))))
114 
115 ;;;###autoload
116 (defun org-id-add-to-headlines-in-file ()
117  "Add ID properties to all headlines in the
118  current file which do not already have one."
119  (interactive)
120  (org-map-entries (lambda () (org-id-get (point) 'create))))
121 
122 (defun org-custom-id-add-to-headlines-in-file ()
123  "Add CUSTOM_ID properties to all headlines in the
124  current file which do not already have one."
125  (interactive)
126  (org-map-entries (lambda () (org-custom-id-get (point) 'create))))
127 
128 (defun org-id-add-to-headlines-in-files (&optional files)
129  (interactive)
130  (with-temp-buffer
131  (dolist (f (or files org-agenda-files))
132  (find-file f)
133  (org-id-add-to-headlines-in-file)
134  (save-buffer))))
135 
136 (defun org-id-add-to-headlines-in-directory (&optional dir)
137  (interactive)
138  (let ((dir (or dir org-directory)))
139  (org-id-add-to-headlines-in-files
140  (directory-files-recursively dir "[.]org$"))))
141 
142 (message "Initialized ULANG.")
143 
144 (provide 'ulang)
145 ;;; ulang.el ends here