masasam/emacs-easy-hugo

Feature Request : Autocomplete for Categories and Tags

Closed this issue ยท 6 comments

I always keep forgetting the exact categories and tags used in previous post(s)

Sometimes, it is obvious, but a lot of times it is not.

Is is possible to provide auto-complete for the categories and tags ?

This could be done during the "New Post" where you ask for the filename.

Hi @mandarvaze .
Thank you for comment.

It shows a simple implementation.

Example for using popup

(defun easy-hugo-complete-tags ()
(interactive)
(insert (popup-menu* '("Pen" "Pineapple" "Apple"))))

If you write tags to "Pen" "Pineapple" "Apple" it will auto-complete.

screenshot png

Because there is a company-mode user, implementing it in easy-hugo is under discussion.
If you put tags you want to use and write it in your init.el it will move.

@masasam This helps a little.
If and when I add more tags, I will need to update init.el correct ?
I was thinking of design where tags/categories are "mined" from the existing posts, and offered for auto-completion.

This option will work for multiple hugo blog setup, where each blog may have different set of tags/categories. Having it in the init.el won't be much useful (Off course one can have the superset of tags/categories across multiple blogs, but it is less efficient IMO)

Hi @mandarvaze .
I've implemented easy-hugo-complete-tags and easy-hugo-complete-categories.
This is very convenient as you say.
Thank you for a nice idea.

This is great.
Thanks for quick turnaround.

I just installed the latest MELPA package. on M-x easy-hugo-complete-categories I do see the popup, but it has only 3 entries, while I have about 10-12 categories.

I think your code is looking for TOML style front matter i.e. categories = [..]
I migrated to hugo sometime ago from nikola, and it was convenient for me to have YAML style front matter i.e. categories : [...]
But for a few initial posts, I did have TOML style front matter. I think your code finds only those.

Obviously the regex needs to change (I'll send in a PR)

I am facing another problem. After using it once, I get an error :
No such file or directory, /base/dir/content/post/.#filename.md

Looks like you've already addressed the YAML issue.

Man, you are Faaast ๐Ÿ˜„