Post 9lKMoV1cHlReGRI4sy by hdasch@fosstodon.org
 (DIR) More posts by hdasch@fosstodon.org
 (DIR) Post #9lK1231czFk2UFLpXk by brandon@fosstodon.org
       2019-07-28T22:06:11Z
       
       0 likes, 0 repeats
       
       Looking for a way to find and replace contents within a variable in emacs/elisp
       
 (DIR) Post #9lK2iPhr9Jsgworucq by montdor@linuxrocks.online
       2019-07-28T22:25:32Z
       
       0 likes, 0 repeats
       
       @brandonWould anzu's search-and-replace work?
       
 (DIR) Post #9lK3FTgJOIigpfucpU by brandon@fosstodon.org
       2019-07-28T22:31:41Z
       
       0 likes, 0 repeats
       
       @montdor I'm not sure, link?
       
 (DIR) Post #9lK3fLJP8BSsP7Wyoa by brandon@fosstodon.org
       2019-07-28T22:36:22Z
       
       0 likes, 0 repeats
       
       Maybe context would help? I have the code in the screenshot below.The /intended/ purpose is to take var contents, replace-regexp, and then write the modified buffer back to the var contentsIt seems that the variable is never modified, but I don't know how to verify if contents originally had the strings I'm regexing anyway
       
 (DIR) Post #9lKIDA7Gf5HaswsI4G by ndegruchy@fosstodon.org
       2019-07-29T01:19:24Z
       
       0 likes, 0 repeats
       
       @brandon My guess is that some part of the regexp just doesn't find anything. You might be able to get away with two 'replace-string's if you're searching for either. You can also use the excellent rx package that makes writing regexp less error-prone.https://www.emacswiki.org/emacs/rx
       
 (DIR) Post #9lKLkUqSud88asbOOO by brandon@fosstodon.org
       2019-07-29T01:59:01Z
       
       0 likes, 0 repeats
       
       @ndegruchy so I was able to figure out that the text wasn't being matched because I want getting the source buffer when I accessed... Whatever it was.I think I'm gonna have to read up on org export
       
 (DIR) Post #9lKMoV1cHlReGRI4sy by hdasch@fosstodon.org
       2019-07-29T02:10:45Z
       
       0 likes, 0 repeats
       
       @brandon I think you need to double the backslashes.  "\\(", "\\)", "\\|".  Otherwise the single backslash is consumed by the string reader.
       
 (DIR) Post #9lKNvi960A44wEn8me by brandon@fosstodon.org
       2019-07-29T02:23:23Z
       
       0 likes, 0 repeats
       
       @hdasch The regex is fine from what I've seen so far. It's actually accessing the "raw" org text that I'm having difficulty with
       
 (DIR) Post #9lKP0ddMIuXGLZrOTo by hdasch@fosstodon.org
       2019-07-29T02:35:34Z
       
       0 likes, 0 repeats
       
       @brandon Hmm.  I'm not sure what is not working.  If you are not sure if the variable bound to the value you expected, (message "contests: %s" contents) before the replace-regexp.  Look at the *Messages* buffer if the minibuffer contents get overwritten to quickly.But on closer inspection, I suspect your let form is not doing what you want.  I believe the "contents" variable declared in the let shadows the variable you are trying to insert in the temporary buffer.
       
 (DIR) Post #9lKPHC59zePBoul5G4 by hdasch@fosstodon.org
       2019-07-29T02:38:32Z
       
       0 likes, 0 repeats
       
       @brandon Moreover, by not including a body form, you should expec the let to return nil.How about (let ((x (with-temp-buffer   (insert contents) ...)))  x)
       
 (DIR) Post #9lKPb2GiBqURAvcg1w by brandon@fosstodon.org
       2019-07-29T02:42:07Z
       
       0 likes, 0 repeats
       
       @hdasch Sorry, I realized that the problem is higher up. So what I want to do is export to epub, converting the regex matched text from the source org file into the newstring. Problem is, I don't know where to access the raw source org file.At this point I've let go of what's in the screenshot, but I'm mostly lost. I'm almost ready to just use org-mode macros for the replacement as I think I might even have to modify ox-html, which I'm not comfortable doing. the epub exporter is ox-epub
       
 (DIR) Post #9lKPctNmCPTKC8oRVY by brandon@fosstodon.org
       2019-07-29T02:42:24Z
       
       0 likes, 0 repeats
       
       @hdasch found here: https://github.com/ofosos/ox-epub/blob/master/ox-epub.el
       
 (DIR) Post #9lKPy1BKOftSSt3zyi by hdasch@fosstodon.org
       2019-07-29T02:46:18Z
       
       0 likes, 0 repeats
       
       @brandon Ahh.  So how is your function getting activated?Are you writing a command that calls ex-epub, or are you adding a hook to the publishing mechanism?
       
 (DIR) Post #9lKQ3YXVniRXN153g0 by brandon@fosstodon.org
       2019-07-29T02:47:11Z
       
       0 likes, 0 repeats
       
       @hdasch I was trying to add a hook to the publishing mechanism, but I think the idea of writing a script that just calls ox-epub at the end 🤔
       
 (DIR) Post #9lKQvVCwP8WqfsBMW0 by hdasch@fosstodon.org
       2019-07-29T02:57:03Z
       
       0 likes, 0 repeats
       
       @brandon That's viable.  There's always a tradeoff between expediency and tastefulness.  Expediency usually wins.I've used org mode to generate html and pdfs, but haven't dug deeply into the mechanism.  But a quick look at org-export-filters-alist suggests a few options.  :filter-body looks useful.  But it would take some digging and lots of (message) calls to understand the mechanism.So, sadly, I don't have a good answer for you.