This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'org-element) | |
(require 'org-id) | |
(defun my-org-link-to-headline () | |
"Insert org-id link to a headline from a selected Org file." | |
(interactive) | |
(let ((file (read-file-name "Select Org file: " default-directory nil t nil)) | |
(table (make-hash-table :test 'equal)) | |
(parsed-data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lt/combined-search () | |
"Combines orgrr-search and metasearch-search-set." | |
(interactive) | |
(let ((search-query)) | |
(if (region-active-p) | |
(setq search-query (buffer-substring-no-properties (region-beginning)(region-end))) | |
(setq search-query (read-from-minibuffer "Search: "))) | |
(orgrr-search '(4) search-query) | |
(metasearch-search-set "Search" search-query))) | |
(global-set-key (kbd "C-c d c") 'lt/combined-search) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar attachment-folder "~/Desktop/") | |
(defvar compose-buffer nil) | |
(with-eval-after-load 'mu4e | |
(define-key mu4e-compose-mode-map (kbd "C-c C-a") 'lt/mml-attach-file)) | |
(with-eval-after-load 'dired | |
(define-key dired-mode-map (kbd "E") 'lt/process-marked-files-as-attachments)) | |
(defun lt/mml-attach-file () | |
"Opens a Dired buffer to select attachments. The keybinding to send these back to the email draft is E." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq instance-selection-list '()) | |
(push "https://mastodon.social@laotang" instance-selection-list) | |
(push "https://emacs.ch@laotang" instance-selection-list) | |
(defun lt/switch-mastodon-user () | |
(interactive) | |
(let* ((instance-user (completing-read "" instance-selection-list))) | |
(when (string-match "\\(.*\\)\\(@.*\\)" instance-user) | |
(let* ((selected-instance (match-string 1 instance-user)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun fastgpt-dictionary-sentence () | |
"Provide a separate translation and dictionary look-up for all Chinese words in the next sentence, including pinyin." | |
(interactive) | |
(set-mark (point)) | |
(forward-sentence) | |
(unless (region-active-p) | |
(user-error "No region active")) | |
(let ((buffer (get-buffer-create "*ChatGPT Chinese Dictionary*")) | |
(prompt "You emulate a traditional dictionary. First repeat the Chinese sentence, then provide a separate translation for all words in the Chinese sentence that follows. The format of the translation should be: X (Y) - Z, whereby X stands for the Chinese characters, Y stands for pinyin with markers for tones and Z stands for English. Add a line break after each translation. Add a translation of the whole sentence at the end. Also, do not translate the interpunction and do not provide additional links. ") | |
(buffer-text (buffer-substring-no-properties (region-beginning) (region-end)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lt/kagi () | |
"Kagi the selected region if any, display a query prompt otherwise." | |
(interactive) | |
(browse-url | |
(concat | |
"https://kagi.com/search?q=" | |
(url-hexify-string (if mark-active | |
(buffer-substring (region-beginning) (region-end)) | |
(read-string "Kagi: ")))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lt/mastodon-toot--copy-orgified-toot-to-clipboard () | |
"Copy org-ified toot at point to clipboard." | |
(interactive) | |
(let* ((toot (or (mastodon-tl--property 'base-toot) | |
(mastodon-tl--property 'item-json)))) | |
(let* ((url (mastodon-toot--toot-url)) | |
(content (mastodon-tl--content toot))) | |
(-let* ((dom (plz 'get url :as #'org-web-tools--sanitized-dom)) | |
((title . readable) (org-web-tools--eww-readable dom))) | |
(with-temp-buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lt/wttr () | |
"A tiny wrapper for wttr and world clock." | |
(interactive) | |
(with-current-buffer (get-buffer-create "*wttr*") | |
(erase-buffer) | |
(insert (shell-command-to-string "curl -s de.wttr.in/Freiburg?3nFqT")) | |
(insert "\n") | |
(lt/world-clock-display (time--display-world-list))) | |
(switch-to-buffer "*wttr*") | |
(read-char "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lt/gpt-dictionary-sentence () | |
"Provide a separate translation and dictionary look-up for all Chinese words in the current sentence, including pinyin." | |
(interactive) | |
(set-mark (point)) | |
(forward-sentence) | |
(unless (region-active-p) | |
(user-error "No region active")) | |
(let ((buffer (get-buffer-create "*ChatGPT Chinese Dictionary*")) | |
(prompt "You emulate a traditional dictionary. Provide a separate translation for all (!) words in the Chinese sentence that follows the final colon. The format of the translation should be: Chinese characters   (pinyin) - English. Add a line break after each translation. Add a translation of the whole sentence at the end, but don't start this translation with Translation: : ") | |
(buffer-text (buffer-substring-no-properties (region-beginning) (region-end)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lt/auto-add-org-agenda () | |
"Automatically adds or removes org-files to org-agenda-files, based on whether or not they contain org-keywords." | |
(interactive) | |
(with-temp-file org-agenda-files (insert (shell-command-to-string (concat "rg -e '\\*.(TODO|NEXT|WAITING|RECREATION|PROJECT).[^%]' -g \"*.org\" -l " org-directory))))) ;; Adjust this to fit your own org-keywords | |
(add-hook 'org-agenda-mode-hook 'lt/auto-add-org-agenda) |