changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / emacs/lib/ulang.el

changeset 623: a304c9713a51
parent: 35a579313b80
child: cc13027df6fa
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 25 Aug 2024 00:14:17 -0400
permissions: -rw-r--r--
description: init graph.el
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  '((type "TBD(0!)" "TODO(t!)" "|")
55  (type "WIP(w!)" "|")
56  (type "HOLD(H@!)" "WAIT(/j@!)" "|")
57  (sequence "FIND(q!)" "READ(r@!)" "WATCH(A@!)" "|")
58  (sequence "RESEARCH(s!)" "RECORD(e!)" "WRITE(W!)" "|")
59  (sequence "OUTLINE(O!)" "DRAFT(M!)" "REVIEW(V!)" "|")
60  (type "FIXME(i!)" "TEST(T!)" "BENCH(b!)" "DEPLOY(D!)" "RUN(X!)" "LOG(L!)" "GOTO(g!)" "|")
61  (type "HACK(h!)" "CODE(c!)" "|")
62  (type "NOTE(n!)" "LINK(l!)")
63  (type "PROJECT(p!)" "PRODUCT(P!)" "SPRINT(S!)" "RELEASE(R!)" "|")
64  (sequence "|" "DONE(d!)" "NOPE(x@!)" "FOUND(f@!)" "FIXED(F!)")))
65 
66 (setq org-todo-keyword-faces
67  '(("PROJECT" . (:foreground "lightseagreen" :weight bold))
68  ("PRODUCT" . (:foreground "olivedrab" :weight bold))
69  ("RELEASE" . (:foreground "maroon3" :weight bold))
70  ("RESEARCH" . (:foreground "maroon2" :weight bold))
71  ("HACK" . (:foreground "maroon3" :weight bold))
72  ("TBD" . (:foreground "darkred2" :weight bold))
73  ("NOTE" . (:foreground "tomato2" :weight bold))
74  ("CODE" . (:foreground "bisque" :weight bold :background "midnightblue"))
75  ("HOLD" . (:foreground "red1" :weight bold :background "yellow1"))
76  ("WAIT" . (:foreground "red4" :weight bold :background "yellow1"))
77  ("WIP" . (:foreground "darkorchid2" :weight bold))
78  ("NOPE" . (:foreground "hotpink" :weight bold :background "darkgreen"))))
79 
80 ;; link abbrevs
81 (setq org-link-abbrev-alist
82  '(("vc" . "https://vc.compiler.company/%s")
83  ("comp" . "https://compiler.company/%s")
84  ("cdn" . "https://cdn.compiler.company/%s")
85  ("packy" . "https://packy.compiler.company/%s")
86  ("yt" . "https://youtube.com/watch?v=%s")
87  ("wikipedia" . "https://en.wikipedia.org/wiki/%s")
88  ("reddit" . "https://reddit.com/%s")
89  ("hn" . "https://news.ycombinator.com/%s")
90  ("so" . "https://stackoverflow.com/%s")))
91 
92 ;;; IDs
93 (defun org-custom-id-get (&optional pom create prefix)
94  "Get the CUSTOM_ID property of the entry at point-or-marker POM.
95  If POM is nil, refer to the entry at point. If the entry does
96  not have an CUSTOM_ID, the function returns nil. However, when
97  CREATE is non nil, create a CUSTOM_ID if none is present
98  already. PREFIX will be passed through to `org-id-new'. In any
99  case, the CUSTOM_ID of the entry is returned."
100  (interactive)
101 (org-with-point-at pom
102  (let ((id (org-entry-get nil "CUSTOM_ID"))
103  ;; use CUSTOM_ID for links
104  (org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id))
105  (cond
106  ((and id (stringp id) (string-match "\\S-" id))
107  id)
108  (create
109  (setq id (org-id-new prefix))
110  (org-entry-put pom "CUSTOM_ID" id)
111  (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
112  id)))))
113 
114 ;;;###autoload
115 (defun org-id-add-to-headlines-in-file ()
116  "Add ID properties to all headlines in the
117  current file which do not already have one."
118  (interactive)
119  (org-map-entries (lambda () (org-id-get (point) 'create))))
120 
121 (defun org-custom-id-add-to-headlines-in-file ()
122  "Add CUSTOM_ID properties to all headlines in the
123  current file which do not already have one."
124  (interactive)
125  (org-map-entries (lambda () (org-custom-id-get (point) 'create))))
126 
127 (defun org-id-add-to-headlines-in-files (&optional files)
128  (interactive)
129  (with-temp-buffer
130  (dolist (f (or files org-agenda-files))
131  (find-file f)
132  (org-id-add-to-headlines-in-file)
133  (save-buffer))))
134 
135 (defun org-id-add-to-headlines-in-directory (&optional dir)
136  (interactive)
137  (let ((dir (or dir org-directory)))
138  (org-id-add-to-headlines-in-files
139  (directory-files-recursively dir "[.]org$"))))
140 
141 (message "Initialized ULANG.")
142 
143 (provide 'ulang)
144 ;;; ulang.el ends here