{"id":12130,"date":"2023-03-31T16:23:22","date_gmt":"2023-03-31T14:23:22","guid":{"rendered":"https:\/\/www.q-software-solutions.de\/blog\/?p=12130"},"modified":"2023-03-31T16:23:24","modified_gmt":"2023-03-31T14:23:24","slug":"that-really-was-helpful","status":"publish","type":"post","link":"https:\/\/www.q-software-solutions.de\/blog\/2023\/03\/that-really-was-helpful\/","title":{"rendered":"That really was helpful."},"content":{"rendered":"\n<p>I struggled with some &#8222;profane&#8220; text edit duties, but well, in <br>over 100 files, and as a programmer &#8230; you know what we do.<br>Spend 3 hours to save repeating a task a few hundred times \ud83d\ude09<br><br>My problem, I had to match [[SomeContent]]<br>And I had an assoc list <br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setq 'assoc-listt'((\"Key-1\", \"Value1\"\n                    (\"SomeContent\", \"Some Link to\")<\/code><\/pre>\n\n\n\n<p>I did not get the regular expression right, ChatGPT did it:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(defun my-function ()\n  (interactive)\n  (with-temp-buffer\n    (insert-file-contents \"filename.txt\")\n    (goto-char (point-min))\n\n    ;; Search and replace\n    (while (re-search-forward \"\\\\&#91;\\\\&#91;\\\\(.*?\\\\)\\\\]\\\\]\" nil t)\n      (let* ((match (match-string 1))\n             (value (cdr (assoc match some-alist))))\n        (when value\n          (replace-match (format \"&#91;&#91;file:\/\/%s]&#91;%s]]\" value match) nil t nil 1))))))<\/code><\/pre>\n\n\n\n<p>Just one problem the last 1 , that lead to the non replacement of [[ and]] replace it with zero and you&#8217;re fine. With some stuff around, with some saving of buffers, did I get what I wanted. <br>It&#8217;s always nice if you can program your editor, and I doubt there is anything as programmable as an Emacs \ud83d\ude09<br><br>Thanks for the fish &#8211; ah sorry code &#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I struggled with some &#8222;profane&#8220; text edit duties, but well, in over 100 files, and as a programmer &#8230; you know what we do.Spend 3 hours to save repeating a task a few hundred times \ud83d\ude09 My problem, I had to match [[SomeContent]]And I had an assoc list I did not get the regular expression [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7979],"tags":[8350,8236],"class_list":["post-12130","post","type-post","status-publish","format-standard","hentry","category-programmierung","tag-chatgpt","tag-emacs-lisp"],"_links":{"self":[{"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/posts\/12130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/comments?post=12130"}],"version-history":[{"count":0,"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/posts\/12130\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/media?parent=12130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/categories?post=12130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.q-software-solutions.de\/blog\/wp-json\/wp\/v2\/tags?post=12130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}