about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el8
-rw-r--r--lisp/acdw-org.el52
2 files changed, 59 insertions, 1 deletions
diff --git a/init.el b/init.el index b970012..fc5927e 100644 --- a/init.el +++ b/init.el
@@ -1047,7 +1047,13 @@ if ripgrep is installed, otherwise `consult-grep'."
1047 org-directory "~/org") 1047 org-directory "~/org")
1048 1048
1049 (:bind "RET" acdw-org/return-dwim 1049 (:bind "RET" acdw-org/return-dwim
1050 "<S-return>" acdw-org/org-table-copy-down) 1050 "<S-return>" acdw-org/org-table-copy-down
1051 "M-SPC M-SPC" insert-zero-width-space
1052 "C-c C-l" org-insert-link-dwim)
1053
1054 (with-eval-after-load 'org-export
1055 (add-to-list 'org-export-filter-final-output-functions
1056 #'org-export-remove-zero-width-spaces))
1051 1057
1052 (defun acdw/org-fix-lines-before-save () 1058 (defun acdw/org-fix-lines-before-save ()
1053 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local)) 1059 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local))
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."
301 (message "%d words in buffer" 301 (message "%d words in buffer"
302 (acdw-org/count-words (point-min) (point-max)))))) 302 (acdw-org/count-words (point-min) (point-max))))))
303 303
304
305;;; Zero-width spaces
306;; https://blog.tecosaur.com/tmio/2021-05-31-async.html#easy-zero-width
307
308(defun insert-zero-width-space ()
309 "Insert a zero-width space."
310 (interactive)
311 (insert "\u200b"))
304 312
313(defun org-export-remove-zero-width-spaces (text _backend _info)
314 "Remove zero-width spaces from TEXT."
315 (unless (org-export-derived-backend-p 'org)
316 (replace-regexp-in-string "\u200b" "" text)))
317
318
319;;; Insert links .. DWIM
320;; https://xenodium.com/emacs-dwim-do-what-i-mean/
321
322(defun org-insert-link-dwim ()
323 "Like `org-insert-link' but with personal dwim preferences."
324 (interactive)
325 (let* ((point-in-link (org-in-regexp org-link-any-re 1))
326 (clipboard-url (when (string-match-p
327 (rx (sequence bos
328 (or "http"
329 "gemini"
330 "gopher")))
331 (current-kill 0))
332 (current-kill 0)))
333 (region-content (when (region-active-p)
334 (buffer-substring-no-properties (region-beginning)
335 (region-end)))))
336 (cond ((and region-content clipboard-url (not point-in-link))
337 (delete-region (region-beginning) (region-end))
338 (insert (org-make-link-string clipboard-url region-content)))
339 ((and clipboard-url (not point-in-link))
340 (insert (org-make-link-string
341 clipboard-url
342 (read-string "title: "
343 (with-current-buffer
344 (url-retrieve-synchronously
345 clipboard-url)
346 (dom-text
347 (car
348 (dom-by-tag (libxml-parse-html-region
349 (point-min)
350 (point-max))
351 'title))))))))
352 (t
353 (call-interactively 'org-insert-link)))))
354
355
305(provide 'acdw-org) 356(provide 'acdw-org)
357;; acdw-org.el ends here