github-alphapapaB
Probably not what you want to do, but IIUC you could run Emacs from Cygwin and it wouldn’t have that problem.
These should be functions instead of macros.
As well, being that simple, they shouldn’t generally exist at all. Rather, the dolist
forms should just be inlined. (This is probably the usual case of a user who just learned about macros and is excited to use them, and so overuses them. We’ve all been there. :)
My first suggestion would be to use plz
for HTTP. Then I’d use cl-loop
and pcase
to simplify the rest of the code. Here’s a partial rewrite with a TODO for further exercise. :)
(defun wikipedia-article-references (subject)
(let* ((url (format "https://en.wikipedia.org/wiki/%s" (url-hexify-string subject)))
(dom (plz 'get url :as #'libxml-parse-html-region)))
(cl-loop for cite-tag in (dom-by-tag dom 'cite)
for cite-class = (dom-attr cite-tag 'class)
collect (pcase cite-class
((rx "journal")
(let ((a-tag (dom-search cite-tag
(lambda (tag)
(string-prefix-p "https://doi.org" (dom-attr tag 'href))))))
(cons (concat "doi:" (dom-text a-tag))
;; TODO: Use `string-match' with `rx' and `match-string' here.
(let* ((cite-texts (dom-texts cite-tag))
(title-beg (1+ (string-search "\"" cite-texts)))
(title-end (string-search "\"" cite-texts (1+ title-beg))))
(substring cite-texts title-beg title-end)))))
((rx "book")
(let ((a-tag (dom-search cite-tag
(lambda (tag)
(string-prefix-p "/wiki/Special:BookSources" (dom-attr tag 'href))))))
(cons (concat "isbn:" (dom-text (dom-child-by-tag a-tag 'bdi)))
(dom-text (dom-child-by-tag cite-tag 'i)))))
(_ (let ((a-tag (assoc 'a cite-tag)))
(cons (dom-attr a-tag 'href) (dom-text a-tag))))))))
Regarding this:
And yes, I know that I could probably use a library like s, dash, seq, or cl, but I try to keep my elisp functions free of those kind of things
First of all, cl
and seq
are built-in to Emacs and are used in core Emacs code. There’s no reason not to use them. Second, dash
and s
are on ELPA and are widely used; it’s largely a matter of style, but they are solid libraries, so again, no reason not to use them. They don’t have cooties. ;)
Why did you add :after general
? I use :general
in many of my use-package
forms, but never have I added that.
You’ve asked for help with code but haven’t shown the code that you tried.
You can do M-x customize-option RET mode-line-padding RET
, or if you want to do it only for that theme, see https://github.com/alphapapa/unpackaged.el#customize-theme-faces for code that does that for faces; you could adapt it to do the same for an option.
Here’s an example of one of my current views: https://i.imgur.com/aZIncEM.png I use bufler-workspace
to save and restore a tab-bar tab of 4 windows, the left one being the project’s Org file, and the right ones showing 3 org-ql-search
views.
FYI, Org QL recently gained Embark support, so you can C-.
on one of the org-ql-view
items, just like in an Org Agenda buffer, and act on them, as well as candidates from the org-ql-find
series of commands.
(And before someone asks, the theme is ef-elea-light
by Prot.)