Add ORG functionality
This commit is contained in:
parent
85c68dcdf6
commit
6fd355d978
8
init.el
8
init.el
|
@ -1047,7 +1047,13 @@ if ripgrep is installed, otherwise `consult-grep'."
|
||||||
org-directory "~/org")
|
org-directory "~/org")
|
||||||
|
|
||||||
(:bind "RET" acdw-org/return-dwim
|
(:bind "RET" acdw-org/return-dwim
|
||||||
"<S-return>" acdw-org/org-table-copy-down)
|
"<S-return>" acdw-org/org-table-copy-down
|
||||||
|
"M-SPC M-SPC" insert-zero-width-space
|
||||||
|
"C-c C-l" org-insert-link-dwim)
|
||||||
|
|
||||||
|
(with-eval-after-load 'org-export
|
||||||
|
(add-to-list 'org-export-filter-final-output-functions
|
||||||
|
#'org-export-remove-zero-width-spaces))
|
||||||
|
|
||||||
(defun acdw/org-fix-lines-before-save ()
|
(defun acdw/org-fix-lines-before-save ()
|
||||||
(add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local))
|
(add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local))
|
||||||
|
|
|
@ -301,5 +301,57 @@ the deletion might narrow the column."
|
||||||
(message "%d words in buffer"
|
(message "%d words in buffer"
|
||||||
(acdw-org/count-words (point-min) (point-max))))))
|
(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)
|
(provide 'acdw-org)
|
||||||
|
;; acdw-org.el ends here
|
||||||
|
|
Loading…
Reference in New Issue