masasam / emacs-easy-hugo

Emacs major mode for managing hugo
https://gohugo.io/tools/editors/#emacs
GNU General Public License v3.0
355 stars 26 forks source link

Questions about configuring multiple blogs #49

Closed treese closed 5 years ago

treese commented 5 years ago

Thanks for creating this!

I am puzzled about configuring multiple blogs. I tried adding a second one as described in the README:

 ;; Main blog
(setq easy-hugo-basedir "~/bookshelf/")
(setq easy-hugo-url "https://yourblogdomain")
(setq easy-hugo-sshdomain "blogdomain")
(setq easy-hugo-root "/home/blog/")
(setq easy-hugo-previewtime "300")
(define-key global-map (kbd "C-c C-e") 'easy-hugo)

(setq easy-hugo-bloglist
    ;; blog2 setting
    '(((easy-hugo-basedir . "~/src/github.com/masasam/hugo2/")
    (easy-hugo-url . "http://example2.com")
    (easy-hugo-sshdomain . "myblogdomain")
    (easy-hugo-root . "/home/hugo/"))))

However, using the > and < keys to go back and forth between them doesn't work. From a quick look at the code, it seems that if easy-hugo-bloglist is defined, the configuration is only updated when there is more than one blog in that list, and it works if I add another entry like blog3 in the example.

When I do have the 3 blogs defined, < does not go back to the original one.

masasam commented 5 years ago

Hi @treese . Thank you for comment. Please tell me your environment in a little more detail. For example, your OS, the version of emacs you use, init.el, etc. Is easy-hugo-nth-blog (J key) moving? Is easy-hugo-select-blog (; key) moving? What happens when you run M-x easy-hugo-next-blog? What happens when you run M-x easy-hugo-previous-blog?

treese commented 5 years ago

Thanks for the quick response.

Ah, OK. After restarting, the configuration works. I had changed the configuration while Emacs was running and after easy-hug was loaded. When I called setq to add another item to easy-hugo-bloglist, it overwrote the value that was created when easy-hugo is loaded and pushes the variables for the first blog configuration onto the list.

How that works is a question of design and implementation. It might help to mention it in the README, or to provide a command to update the list correctly if the configuration is changed. I can propose something in a pull request if you like.

In any case, I know how to work with it now. You can close this if you want.

masasam commented 5 years ago

@treese Thank you for the good suggestions. It is nice idea. I will mention it in the README.