reddit / emacs

Preview any link or tweet directly within emacs

aviaviaviavi · 2022-10-04 01:20
I found myself compiling a list of tweets and other links in org mode and was wishing I could easily pull in the tweet details to see them directly in the file. Notion does this nicely, and I couldn’t find anything existing that would give me that. Here’s a quick function to pull that data in automatically. If anyone else would find this useful, I can put a little more effort into polishing it.
lebensterben · 2022-10-04 02:11
I see that you use Spacemacs and the naming of the function is influenced by its naming convention. (using / to separate namespace) but note that by convention all symbols should prefixed with the file name/feature name. so instead of lp/expand-link-at-cursor, it should be link-preview/expand-link-at-cursor. also link-preview-api should first be declared. Since it seems to be a constant, you should use defcustom. third, by convention you should also use (provide 'link-preview) to declare the feature. Spacemacs by default turns off flycheck for elisp, by you should enable it and it will give you many useful suggestions.
aviaviaviavi · 2022-10-04 02:30
Thanks for the input! Wasn’t aware of those parts of the convention, good to know.
lebensterben · 2022-10-04 02:32
I just updated my comment.
nv-elisp · 2022-10-04 03:35
You're missing a Package-Requires in the package header. You should declare, at least, the "request" dependency and a minimum supported Emacs version. You'll want to enable lexical binding in your package's file. You have a number of linter errors you can see by using flymake and/or checkdoc.
aviaviaviavi · 2022-10-04 03:38
Thanks! Will go in and fix these. I don’t write much elisp :)
lebensterben · 2022-10-04 20:54
just checked your latest code. - you can exit early if `PEEKALINK_API_KEY` is not found. - the indentation from L23 and forward are incorrect.