0

I am trying to install simplenote2 to read my org files on my phone. The official setup method is:

(require 'simplenote2)
(setq simplenote2-email "email@example.com")
(setq simplenote2-password "yourpassword")
(simplenote2-setup)

and the app starts with

M-x simplenote2-list

In practice credentials are not necessary in clear and (require...) can be omitted because simplenote2-setup is autoloaded.

I would like to use a use-package declaration, therefore I am using:

(use-package simplenote2
  :config
  (setq simplenote2-email "email@example.com")
  (setq simplenote2-password "yourpassword")
  (setq simplenote2-notes-mode (quote org-mode))
  (simplenote2-setup))

(The extra line is for org-mode integration).

When I start the library with M-x simplenote2-list, I get an error due to a void variable simplenote2-notes-info-version. This variable is defined through a defvar in simplenote2.el. So, it seems that the use-package declaration is not requiring simplenote2.el.

The likely cause is that the autoloaded function simplenote2-list is defined in the separate file simplenote2-list.el. Therefore simplenote2-list requires only simplenote2-list.el, but not simplenote2.el.

If this is the cause, how can I instruct use-package to require also simplenote2.el the first time M-x simplenote2-list is run?
Or alternatively: before running M-x simplenote2-list, how can I run the autoloaded (simplenote2-setup), which automatically requires simplenote2.el?

Note that I have the global option use-package-always-defer set true.

  • A bug-report to simplenote2 would be good – Rusi Feb 23 at 8:02
0

You cannot easily run simplenote2-setup when lazy loading the package.

However, there are several options, to make lazy loading happening:


1. use of :after and defining a use-package declaration for simplenote2-list i.e.:

(use-package simplenote2-list
  :after (simplenote2))

2. require simplenote2 from simplenote2-list use-package declaration

(use-package simplenote2-list
  :config (require 'simplenote2))

3. you could define a keybinding for simplenote2-list from simplenote2 use-package declaration:

(use-package simplenote2
  :bind ("C-c s" . simplenote2-list)
  :config
  ...)

This works for the same reason like the next option.


4. a somewhat hacky one, declaring simplenote2-list as command of simplenote2. This works because simplenote2-list is required by simplenote2.

(use-package simplenote2
  :commands (simplenote2-list)
  :config
  ...)

5. if simplenotes2 is able to be started with hooks or mode-interpreters, you could emulate the simplenote2-setup with keywords :mode or :hook. Please read the use-package manual.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.