From 763350f5bd3a47c58a52d85b15a46854fd28af74 Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Tue, 20 May 2025 14:21:47 +0100 Subject: [PATCH] Add qwan/paste-stripped-url qwen 0.6 had the good sense to go untiil end of the line with the regexp, but called the wrong regexp function - or called it wrongly. elisp 'helpfully' gave End of File error. qwen MoE 30 got the correct function, but put in a regexp that only removed the ?. So I added `.*$` by hand, and it passed manual testing. Since I will be using this a lot, no unit-ish test needed. (test everything that can possibly break). Tested on mac, should work on linux (according to MoE30) --- qwan/qwan-blog.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/qwan/qwan-blog.el b/qwan/qwan-blog.el index 90f9358..226e9d7 100644 --- a/qwan/qwan-blog.el +++ b/qwan/qwan-blog.el @@ -48,7 +48,19 @@ only the description" (insert content))))))) (bind-key "C-c r" 'qwan/org-replace-link-by-link-description) -(defun org-roam-replace-file-link-by-website-or-description () +(defun strip-url (url) + "Remove everything after ? from the url, to hinder tracking." + (replace-regexp-in-string "\\?.*$" "" url)) + +;; TODO define key for this maybe SPC q is available? no, that is quit. +(defun qwan/paste-stripped-url () + "Paste a URL without tracking from the clipboard into the current buffer." + (interactive) + (let ((url (x-get-selection 'CLIPBOARD))) + (when url + (insert (strip-url url))))) + +(defun qwan/org-roam-replace-file-link-by-website-or-description () "If a linked org-roam file has a website as key, use that as the link target instead of the filename. Otherwise, remove the link, and leave just the description.