changeset 626: |
cc13027df6fa |
parent: |
a304c9713a51
|
child: |
3af20cb389e8 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Mon, 26 Aug 2024 20:09:01 -0400 |
permissions: |
-rw-r--r-- |
description: |
ulang and cli updates |
1 ;;; ulang.el --- ulang compliance lib -*- lexical-binding:t -*- 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. 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. 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/>. 31 "CC Universal Language.") 33 (defvar ulang-link-history nil) 34 (defvar ulang-file-history nil) 36 (defvar ulang-categories 37 (list "note" "link" "code" "doc" "project" "data")) 39 ;; FIX 2024-08-26: doesn't work 40 (defun org-category-allowed-values (prop) 41 (when (string= (upcase prop) "CATEGORY") 42 (append ulang-categories (list ":ETC")))) 44 (cl-pushnew #'org-category-allowed-values org-property-allowed-value-functions) 47 (defun dblock-insert-links (regexp) 48 "Create dblock to insert links matching REGEXP." 49 (interactive (list (read-regexp "Insert links matching: " nil ulang-links-history))) 50 (org-create-dblock (list :name "links" 55 (org-dynamic-block-define "links" 'dblock-insert-links) 57 (org-export-translate-to-lang (list '("Table of Contents" "Index")) "ulang") 58 ;; (setq org-export-global-macros nil) 61 (setq org-stuck-projects '("+PROJECT/-DONE" ("NEXT") nil "")) 63 (setq org-todo-keywords 64 '((sequence "TBD(0!)" "TODO(t!)" "NEXT(n!)" "WIP(i!)" "|" "DONE(d!)") 65 (sequence "HOLD(H@/!)" "WIP(!)" "|") 66 (sequence "WAIT(W@/!)" "WIP(!)" "|") 67 (sequence "RESEARCH(s!)" "REPORT(c!)" "|") 68 (sequence "OUTLINE(O!)" "DRAFT(M!)" "REVIEW(V!)" "|") 69 (type "FIND(q!)" "READ(r@!)" "WATCH(A@!)" "HACK(h!)" 70 "CODE(c!)" "BENCH(b!)" "DEPLOY(D!)" "RUN(X!)" 72 "LOG(L!)" "GOTO(g!)" "|") 73 (type "FIXME(f!)" "WIP(!)" "TEST(T!)" "|") 74 (type "PROJECT(p!)" "PRODUCT(P!)" "SPRINT(S!)" "RELEASE(R!)" "|") 75 (sequence "|" "DONE(d!)" "NOPE(x@!)"))) 77 (setq org-todo-keyword-faces 78 '(("PROJECT" . (:foreground "lightseagreen" :weight bold)) 79 ("PRODUCT" . (:foreground "olivedrab" :weight bold)) 80 ("RELEASE" . (:foreground "maroon3" :weight bold)) 81 ("RESEARCH" . (:foreground "maroon2" :weight bold)) 82 ("HACK" . (:foreground "maroon3" :weight bold)) 83 ("TBD" . (:foreground "darkred2" :weight bold)) 84 ;; ("NOTE" . (:foreground "tomato2" :weight bold)) 85 ("CODE" . (:foreground "bisque" :weight bold :background "midnightblue")) 86 ("HOLD" . (:foreground "red1" :weight bold :background "yellow1")) 87 ("WAIT" . (:foreground "red4" :weight bold :background "yellow1")) 88 ("WIP" . (:foreground "darkorchid2" :weight bold)) 89 ("NOPE" . (:foreground "hotpink" :weight bold :background "darkgreen")))) 92 (setq org-link-abbrev-alist 93 '(("vc" . "https://vc.compiler.company/%s") 94 ("comp" . "https://compiler.company/%s") 95 ("cdn" . "https://cdn.compiler.company/%s") 96 ("packy" . "https://packy.compiler.company/%s") 97 ("yt" . "https://youtube.com/watch?v=%s") 98 ("wikipedia" . "https://en.wikipedia.org/wiki/%s") 99 ("reddit" . "https://reddit.com/%s") 100 ("hn" . "https://news.ycombinator.com/%s") 101 ("so" . "https://stackoverflow.com/%s"))) 104 (defun org-custom-id-get (&optional pom create prefix) 105 "Get the CUSTOM_ID property of the entry at point-or-marker POM. 106 If POM is nil, refer to the entry at point. If the entry does 107 not have an CUSTOM_ID, the function returns nil. However, when 108 CREATE is non nil, create a CUSTOM_ID if none is present 109 already. PREFIX will be passed through to `org-id-new'. In any 110 case, the CUSTOM_ID of the entry is returned." 112 (org-with-point-at pom 113 (let ((id (org-entry-get nil "CUSTOM_ID")) 114 ;; use CUSTOM_ID for links 115 (org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)) 117 ((and id (stringp id) (string-match "\\S-" id)) 120 (setq id (org-id-new prefix)) 121 (org-entry-put pom "CUSTOM_ID" id) 122 (org-id-add-location id (buffer-file-name (buffer-base-buffer))) 126 (defun org-id-add-to-headlines-in-file () 127 "Add ID properties to all headlines in the 128 current file which do not already have one." 130 (org-map-entries (lambda () (org-id-get (point) 'create)))) 132 (defun org-custom-id-add-to-headlines-in-file () 133 "Add CUSTOM_ID properties to all headlines in the 134 current file which do not already have one." 136 (org-map-entries (lambda () (org-custom-id-get (point) 'create)))) 138 (defun org-id-add-to-headlines-in-files (&optional files) 141 (dolist (f (or files org-agenda-files)) 143 (org-id-add-to-headlines-in-file) 146 (defun org-id-add-to-headlines-in-directory (&optional dir) 148 (let ((dir (or dir org-directory))) 149 (org-id-add-to-headlines-in-files 150 (directory-files-recursively dir "[.]org$")))) 152 (message "Initialized ULANG.") 155 ;;; ulang.el ends here