[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnosis 48ca4aa6f2 07/19: [Refactor] Rewrite org-insert-hea
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnosis 48ca4aa6f2 07/19: [Refactor] Rewrite org-insert-heading |
Date: |
Thu, 5 Sep 2024 13:00:30 -0400 (EDT) |
branch: elpa/gnosis
commit 48ca4aa6f2420676de468f3ce43608d4cab41fca
Author: Thanos Apollo <public@thanosapollo.org>
Commit: Thanos Apollo <public@thanosapollo.org>
[Refactor] Rewrite org-insert-heading
* Adjust for list answers.
* Use gnosis-id.
---
gnosis-org.el | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/gnosis-org.el b/gnosis-org.el
index e194e88bc7..e977083e58 100644
--- a/gnosis-org.el
+++ b/gnosis-org.el
@@ -64,24 +64,29 @@ BUFFER defaults to the current buffer if not specified."
(if results (reverse results)
(message "No custom properties found for %s" property)
nil))))
-
-(cl-defun gnosis-org-insert-custom-heading (&key main id body type (buffer
(current-buffer)))
- "Insert an Org heading in BUFFER.
+;; TODO: Add support for tags.
+(cl-defun gnosis-org-insert-heading (&key main id answer type)
+ "Insert an Org heading in current buffer.
- MAIN as the title.
-- ID as CUSTOM_ID.
-- BODY as the content.
+- ID as GNOSIS_ID.
+- ANSWER as the subheading.
- TYPE as the note type.
If BUFFER is not specified, defaults to the current buffer."
(cl-assert (stringp main) nil "MAIN must be a string representing the
heading title.")
- (cl-assert (stringp id) nil "ID must be a string representing the
CUSTOM_ID.")
- (cl-assert (stringp body) nil "BODY must be a string representing the
content.")
+ (cl-assert (stringp id) nil "ID must be a string representing the
GNOSIS_ID.")
(cl-assert (stringp type) nil "TYPE must be a string representing the TYPE
property.")
- (with-current-buffer buffer
+ (let ((main (if (string-match-p "\n" main) (replace-regexp-in-string "\n"
"\\\\n" main) main))
+ (answer (cond ((stringp answer)
+ answer)
+ ((numberp answer)
+ (number-to-string answer))
+ (t (mapconcat 'identity answer ", ")))))
(goto-char (point-max)) ;; Ensure we're at the end of the buffer
- (insert (format "* %s\n:PROPERTIES:\n:CUSTOM_ID: %s\n:TYPE:
%s\n:END:\n%s\n" main id type body))
- (message "Inserted heading: %s with CUSTOM_ID %s and TYPE %s" main id
type)))
+ (insert (format "* %s\n:PROPERTIES:\n:GNOSIS_ID: %s\n:TYPE: %s\n:END:\n**
%s\n"
+ main id type answer))
+ (message "Inserted heading: %s with GNOSIS_ID %s and TYPE %s" main id
type)))
(provide 'gnosis-org)
;;; gnosis-org.el ends here.
- [nongnu] elpa/gnosis updated (013fca6bae -> 731f0ba491), ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 48ca4aa6f2 07/19: [Refactor] Rewrite org-insert-heading,
ELPA Syncer <=
- [nongnu] elpa/gnosis a783b56772 10/19: New function: Add validate-custom-values., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 56ed928045 09/19: export-deck: Add demo export., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 1e8e5fc529 11/19: New variable-watcher: custom-values-watcher., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis d034335bde 18/19: Packaging: Add version 0.4.2., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 4d90489c5b 05/19: elpaignore: Add manifest.scm, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 11e526b496 02/19: New module: gnosis-org: Use org-mode with gnosis., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis cfa0462972 01/19: packaging: Version 0.4.2-dev, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 061633adca 03/19: packaging: Require emacsql-4.0.1., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 487d903de1 04/19: New file: Add manifest.scm, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 02a4e13520 12/19: [fix] display-images: Display images only on graphical envs., ELPA Syncer, 2024/09/05