1
0
Fork 0

[oni-org] Get rid of any ‘(setf (map-elt ...) ...)’ occurrences

Right now this doesn't seem to work at all... It works fine when I evaluate this
using ‘eval-defun’ or ‘eval-last-sexp’, but when I try to byte-compile it
doesn't work.

I've added my own custom macro that expands to the same thing that
‘(setf (map-elt ...) ...)’ should. I have forgotten how to write macros properly
so I may have made some mistakes.

This should only be temporary until I figure out why this is happening... it
might just be that I'm using a version of Emacs built from a faulty commit.
This commit is contained in:
Tom Willemse 2023-06-21 00:27:35 -07:00
parent c36f9ff2f7
commit 9fe6381afd

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; Keywords: local
;; Version: 2023.0613.234632 ;; Version: 2023.0621.002708
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table) ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table)
;; This program is free software; you can redistribute it and/or modify ;; This program is free software; you can redistribute it and/or modify
@ -1162,7 +1162,25 @@ This is done by adding a :hidden t header argument to the code block."
,(/ (length text) 2))))) ,(/ (length text) 2)))))
text)) text))
(setf (map-elt org-agenda-custom-commands "o") (defmacro oni-org--map-put (collection key value)
"The result of (setf (map-elt ...) ...) on a list.
Trying to byte-compile the above form doesn't work at the moment.
This is a temporary hack to make sure I don't have to repeat this
same code all the time."
(declare (indent 2))
(let ((key-name (gensym))
(value-name (gensym)))
`(let ((,key-name ,key)
(,value-name ,value))
(condition-case nil
(with-no-warnings
(map-put! ,collection ,key-name ,value-name nil))
(map-not-inplace
(setq ,collection
(map-insert ,collection ,key-name ,value-name))
,value-name)))))
(oni-org--map-put org-agenda-custom-commands "o"
'("Overview" ((tags-todo "TODO=\"WAITING\"" '("Overview" ((tags-todo "TODO=\"WAITING\""
((org-agenda-overriding-header (oni-org--center-align "Waiting")))) ((org-agenda-overriding-header (oni-org--center-align "Waiting"))))
(tags-todo "TODO=\"WIP\"" (tags-todo "TODO=\"WIP\""
@ -1181,7 +1199,7 @@ This is done by adding a :hidden t header argument to the code block."
((org-agenda-max-todos 5) ((org-agenda-max-todos 5)
(org-agenda-overriding-header (oni-org--center-align "Listen"))))))) (org-agenda-overriding-header (oni-org--center-align "Listen")))))))
(setf (map-elt org-agenda-custom-commands "t") (oni-org--map-put org-agenda-custom-commands "t"
'("To Do" ((tags-todo "TODO=\"WAITING\"+#todo" '("To Do" ((tags-todo "TODO=\"WAITING\"+#todo"
((org-agenda-overriding-header (oni-org--center-align "Waiting To Do")))) ((org-agenda-overriding-header (oni-org--center-align "Waiting To Do"))))
(tags-todo "TODO=\"WIP\"+#todo" (tags-todo "TODO=\"WIP\"+#todo"
@ -1189,7 +1207,7 @@ This is done by adding a :hidden t header argument to the code block."
(tags-todo "TODO=\"TODO\"+#todo" (tags-todo "TODO=\"TODO\"+#todo"
((org-agenda-overriding-header (oni-org--center-align "To Do"))))))) ((org-agenda-overriding-header (oni-org--center-align "To Do")))))))
(setf (map-elt org-agenda-custom-commands "r") (oni-org--map-put org-agenda-custom-commands "r"
'("Reading" ((tags-todo "TODO=\"WAITING\"+#reading" '("Reading" ((tags-todo "TODO=\"WAITING\"+#reading"
((org-agenda-overriding-header (oni-org--center-align "Waiting To Read")))) ((org-agenda-overriding-header (oni-org--center-align "Waiting To Read"))))
(tags-todo "TODO=\"WIP\"+#reading" (tags-todo "TODO=\"WIP\"+#reading"
@ -1197,7 +1215,7 @@ This is done by adding a :hidden t header argument to the code block."
(tags-todo "TODO=\"TODO\"+#reading" (tags-todo "TODO=\"TODO\"+#reading"
((org-agenda-overriding-header (oni-org--center-align "To Read"))))))) ((org-agenda-overriding-header (oni-org--center-align "To Read")))))))
(setf (map-elt org-agenda-custom-commands "w") (oni-org--map-put org-agenda-custom-commands "w"
'("Watching" ((tags-todo "TODO=\"WAITING\"+#watching" '("Watching" ((tags-todo "TODO=\"WAITING\"+#watching"
((org-agenda-overriding-header (oni-org--center-align "Waiting To Watch")))) ((org-agenda-overriding-header (oni-org--center-align "Waiting To Watch"))))
(tags-todo "TODO=\"WIP\"+#watching" (tags-todo "TODO=\"WIP\"+#watching"
@ -1205,7 +1223,7 @@ This is done by adding a :hidden t header argument to the code block."
(tags-todo "TODO=\"TODO\"+#watching" (tags-todo "TODO=\"TODO\"+#watching"
((org-agenda-overriding-header (oni-org--center-align "To Watch"))))))) ((org-agenda-overriding-header (oni-org--center-align "To Watch")))))))
(setf (map-elt org-agenda-custom-commands "l") (oni-org--map-put org-agenda-custom-commands "l"
'("Listening" ((tags-todo "TODO=\"WAITING\"+#listening" '("Listening" ((tags-todo "TODO=\"WAITING\"+#listening"
((org-agenda-overriding-header (oni-org--center-align "Waiting To Listen To")))) ((org-agenda-overriding-header (oni-org--center-align "Waiting To Listen To"))))
(tags-todo "TODO=\"WIP\"+#listening" (tags-todo "TODO=\"WIP\"+#listening"
@ -1213,7 +1231,7 @@ This is done by adding a :hidden t header argument to the code block."
(tags-todo "TODO=\"TODO\"+#listening" (tags-todo "TODO=\"TODO\"+#listening"
((org-agenda-overriding-header (oni-org--center-align "To Listen To"))))))) ((org-agenda-overriding-header (oni-org--center-align "To Listen To")))))))
(setf (map-elt org-capture-templates "sE") (oni-org--map-put org-capture-templates "sE"
'("Questions for Emacs packages" plain (function ignore) '("Questions for Emacs packages" plain (function ignore)
"- Do I want to integrate this in my configuration? "- Do I want to integrate this in my configuration?
- %? - %?
@ -1224,31 +1242,31 @@ This is done by adding a :hidden t header argument to the code block."
:empty-lines 1 :empty-lines 1
:immediate-finish t :immediate-finish t
:jump-to-captured t)) :jump-to-captured t))
(setf (map-elt org-capture-templates-contexts "sE") (oni-org--map-put org-capture-templates-contexts "sE"
'(((in-mode . "org-mode")))) '(((in-mode . "org-mode"))))
(setf (map-elt org-capture-templates "se") (oni-org--map-put org-capture-templates "se"
'("Questions for Emacs articles" plain (function ignore) '("Questions for Emacs articles" plain (function ignore)
"- What can I add to my config from this? "- What can I add to my config from this?
- %?" - %?"
:empty-lines 1 :empty-lines 1
:immediate-finish t :immediate-finish t
:jump-to-captured t)) :jump-to-captured t))
(setf (map-elt org-capture-templates-contexts "se") (oni-org--map-put org-capture-templates-contexts "se"
'(((in-mode . "org-mode")))) '(((in-mode . "org-mode"))))
(setf (map-elt org-capture-templates "s") (oni-org--map-put org-capture-templates "s"
'("Snippets")) '("Snippets"))
(setf (map-elt org-capture-templates-contexts "s") (oni-org--map-put org-capture-templates-contexts "s"
'(((in-mode . "org-mode")))) '(((in-mode . "org-mode"))))
(setf (map-elt org-capture-templates "t") (oni-org--map-put org-capture-templates "t"
'("A simple TODO item." entry (file "") "* TODO %? '("A simple TODO item." entry (file "") "* TODO %?
:PROPERTIES: :PROPERTIES:
:CREATED: %U :CREATED: %U
:END:")) :END:"))
(setf (map-elt org-capture-templates "U") (oni-org--map-put org-capture-templates "U"
'("A TODO capture from the browser." entry (file "") "* TODO %:description '("A TODO capture from the browser." entry (file "") "* TODO %:description
:PROPERTIES: :PROPERTIES:
:CREATED: %U :CREATED: %U