Files
memex/ellama-sessions/.Emacs Lisp (Open AI).org.session.el
2026-03-15 14:37:05 -04:00

44 lines
3.5 KiB
EmacsLisp

#s(ellama-session "Emacs Lisp (Open AI)" #s(llm-openai-compatible "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" "llama3-70b-8192" "llama3-70b-8192" "https://api.groq.com/openai/v1") "/home/amr/org/ellama-sessions/Emacs Lisp (Open AI).org" #s(llm-chat-prompt nil nil (#s(llm-chat-prompt-interaction system "" nil) #s(llm-chat-prompt-interaction user "#+begin_src emacs-lisp
(defun my/org-move-entry-to-daily-notes ()
\"Move the current org-mode headline to the daily notes file based on its :CREATED: property.\"
(interactive)
(let*
((created-prop (org-entry-get nil \"CREATED\"))
(created-date (when created-prop
(org-parse-time-string created-prop)))
(year (nth 5 created-date)) ; Extract year (6th element)
(month (nth 4 created-date)) ; Extract month (5th element)
(day (nth 3 created-date)) ; Extract day (4th element)
(target-date (format \"%04d-%02d-%02d\" year month day)) ; Format date string
(target-file (org-roam-dailies-goto target-date))
)
(when target-file
(org-cut-subtree)
(find-file target-file)
(goto-char (point-max))
(unless (bolp) (newline))
(org-paste-subtree)
)
)
)
#+end_src
" nil) #s(llm-chat-prompt-interaction assistant "This is an Emacs Lisp function named `my/org-move-entry-to-daily-notes`. It's an interactive function that moves the current org-mode headline to a daily notes file based on its `:CREATED:` property.
Here's a breakdown of the function:
1. It first retrieves the `CREATED` property of the current headline using `org-entry-get`.
2. If the property exists, it parses the timestamp using `org-parse-time-string` and extracts the year, month, and day components from the parsed timestamp.
3. It then constructs a target date string in the format `YYYY-MM-DD` using the extracted year, month, and day components.
4. It uses the `org-roam-dailies-goto` function (which is not a built-in Emacs function, so it must be defined elsewhere) to find or create a daily notes file for the target date and returns the file path.
5. If a target file is found or created, the function cuts the current subtree using `org-cut-subtree`, opens the target file, moves to the end of the file, and pastes the subtree using `org-paste-subtree`.
The purpose of this function is to move a headline from the current org-mode file to a daily notes file corresponding to the date when the headline was created." nil) #s(llm-chat-prompt-interaction user #("
" 0 1 (fontified t line-prefix #(" " 0 4 (face org-indent)) wrap-prefix #(" " 0 4 (face org-indent)))) nil) #s(llm-chat-prompt-interaction assistant "It seems like you didn't ask a question or provide any additional context. If you have any questions about the code or need help with something, feel free to ask!
If you're looking for feedback on the code, here are a few minor suggestions:
* The function name `my/org-move-entry-to-daily-notes` is not following the conventional Emacs Lisp naming convention, which is to use a `-` instead of a `/` separator. It should be `my-org-move-entry-to-daily-notes`.
* The function is not checking if the `:CREATED:` property exists before trying to parse it. You might want to add a check to avoid errors.
* The `org-roam-dailies-goto` function is not a built-in Emacs function, so you should make sure it's defined somewhere in your Emacs configuration.
Other than that, the code looks clean and well-organized." nil)) nil nil nil) nil)