From 6fd355d978c0f6146ed101effa12661453ecea04 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 1 Jun 2021 22:30:05 -0500 Subject: Add ORG functionality --- lisp/acdw-org.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 7e68712..a9c0a8c 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -301,5 +301,57 @@ the deletion might narrow the column." (message "%d words in buffer" (acdw-org/count-words (point-min) (point-max)))))) + +;;; Zero-width spaces +;; https://blog.tecosaur.com/tmio/2021-05-31-async.html#easy-zero-width + +(defun insert-zero-width-space () + "Insert a zero-width space." + (interactive) + (insert "\u200b")) +(defun org-export-remove-zero-width-spaces (text _backend _info) + "Remove zero-width spaces from TEXT." + (unless (org-export-derived-backend-p 'org) + (replace-regexp-in-string "\u200b" "" text))) + + +;;; Insert links .. DWIM +;; https://xenodium.com/emacs-dwim-do-what-i-mean/ + +(defun org-insert-link-dwim () + "Like `org-insert-link' but with personal dwim preferences." + (interactive) + (let* ((point-in-link (org-in-regexp org-link-any-re 1)) + (clipboard-url (when (string-match-p + (rx (sequence bos + (or "http" + "gemini" + "gopher"))) + (current-kill 0)) + (current-kill 0))) + (region-content (when (region-active-p) + (buffer-substring-no-properties (region-beginning) + (region-end))))) + (cond ((and region-content clipboard-url (not point-in-link)) + (delete-region (region-beginning) (region-end)) + (insert (org-make-link-string clipboard-url region-content))) + ((and clipboard-url (not point-in-link)) + (insert (org-make-link-string + clipboard-url + (read-string "title: " + (with-current-buffer + (url-retrieve-synchronously + clipboard-url) + (dom-text + (car + (dom-by-tag (libxml-parse-html-region + (point-min) + (point-max)) + 'title)))))))) + (t + (call-interactively 'org-insert-link))))) + + (provide 'acdw-org) +;; acdw-org.el ends here -- cgit 1.4.1-21-gabe81