reddit / emacs
I made my first emacs package to add links in plain text messages
Qwarctick · 2022-09-21 09:51
Link : [https://github.com/PhilippeNoel1/message-links.el](https://github.com/PhilippeNoel1/message-links.el)
This is my first emacs package and my first contribution on github. So any comments for improvement are welcome :)
ideasman_42 · 2022-09-21 10:30
Hey nice idea for a package, I'd like to use it when writing commit logs, where I use this style of links. I didn't try the package yet but looks like it could be handy, suggestions:
- A way to select a region, detect and URL's, move all links after `---links---`.
- Support for not requiring `--links---`, simply detect block of `[#]:` prefixed lines, add one when none are found.
- Why limit of 9 links?
- Ability to start links at 0'th.
- A way to tweak spacing? Or a format string `[1]: link`.
- Note, `search-forward` should be wrapped in `(save-match-data ...)` so as not to modify the users match-data.
Qwarctick · 2022-09-21 10:57
Many thanks for your feedback. Obviously the package is subject to improvement:
>A way to select a region, detect and URL's, move all links after ---links---.
Don't know how to do this now, but it could be a real improvement.
>Support for not requiring --links---, simply detect block of \[#\]: prefixed lines, add one when none are found.
I tried but I preferred to start simply with a "tag" that would separate the real message from the links
>Why limit of 9 links?
That's an error in the regex. I will change it.
>Ability to start links at 0'th.
>
>A way to tweak spacing? Or a format string \[1\]: link.
Good idea, and it's not difficult to add.
>Note, search-forward should be wrapped in (save-match-data ...) so as not to modify the users match-data.
TIL this. Thanks
ideasman_42 · 2022-09-21 12:27
> Support for not requiring --links---, simply detect block of [#]: prefixed lines, add one when none are found.
> I tried but I preferred to start simply with a "tag" that would separate the real message from the links
This is an important feature for me (as in, I wouldn't use this package if it required `--links---`), would you accept a pull request to optionally not use this? (if it's set to an empty string auto-detect, for e.g.).
Qwarctick · 2022-09-21 12:39
Of course yes.
The idea was to look for the header (\`---links---\`) and to consider the \[#\] blocks afterwards. I was afraid to take into account the \[#\] blocks which were not concerned.
In fact, it is possible to take into account ALL the \[#\] blocks of the mail, get the biggest one, add and generate the new entry
ideasman_42 · 2022-09-21 13:03
I don't think detecting lines starting with `[#]: ` is likely to back-fire, and if someone is really concerned about this possability they can always use `---links---` marker.
doolio_ · 2022-09-21 13:11
The grammar for the docstring for `message-links-add-link` is incorrect. Plus I think you are supposed to upcase the parameter in the docstring.
Edit: the autoload cookie should also be on the line before that which you wish autoloaded.
github-alphapapa · 2022-09-21 18:43
Another option is to write emails in Org with the package `org-msg`, having them exported to plain text with org-export, which formats them similarly.
Qwarctick · 2022-09-21 18:47
Ah! Didn't know about that.
JoshuaOC · 2022-09-21 18:57
Super job! Looks great :)
I point this out only for your information, there is a similar built-in package. `footnote.el`, you can have a go with `M-x footnote-mode`.
But it's somewhat more compl
Qwarctick · 2022-09-21 20:22
Gosh ... Didn't know. \`footnote.el\` has the same goal but does it better.
Qwarctick · 2022-09-22 09:31
>Ability to start links at 0'th.
Done
>Why limit of 9 links?
Fixed
>Support for not requiring --links---, simply detect block of \[#\]: prefixed lines, add one when none are found.
Done
Qwarctick · 2022-09-22 09:32
Thanks, I fixed it :)
ideasman_42 · 2022-09-23 07:27
Great, I've submitted some PR's and plan some other changes (mainly to be able to extract links and auto-insert them - if you don't get to it first).