Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minor mode (feature request) #40

Open
jrbalderrama opened this issue Apr 3, 2014 · 4 comments
Open

Add minor mode (feature request) #40

jrbalderrama opened this issue Apr 3, 2014 · 4 comments

Comments

@jrbalderrama
Copy link

Currently we should explicitly load org-toodledo (with require '...) in order to use it. Enabling a minor mode we can include a hook and load toodledo on demand. For example, we can set:

(defvar org-toodledo-default-todo-file "/path/to/my/file")
(setq org-toodledo-sync-on-save "no")

and then create a function like:

 (defun org-toodledo-sync-silently ()
       "Sync a initialized toodledo file with the server on background."
       (find-file-noselect org-toodledo-default-todo-file)
       (with-temp-buffer
         (when (find-buffer-visiting org-toodledo-default-todo-file)
           (set-buffer (get-file-buffer org-toodledo-default-todo-file))
           (org-toodledo-sync)
           (save-buffer))))

With this function defined (with autoload) we can associate a hook after loading the org-toodledo mode or/and after killing the buffer.

Additionally we can define a cron-like process on Emacs to sync periodically instead of syncing every time we save the file using.

;; sync each 20 min the toodledo file after waiting 5 min.
(run-with-timer (* 5 60) (* 20 60) 'org-toodledo-sync-silently)
@christopherjwhite
Copy link
Owner

This is pretty cool -- one question, though, how does 'minor-mode' come
in to play here? It seems this relies solely on the file name.

...cj

On 4/3/14 9:38 AM, jrbalderrama wrote:

Currently we should explicitly load org-toodledo (with require '...)
in order to use it. Enabling a minor mode we can include a hook and
load toodledo on demand. For example, we can set:

(defvar org-toodledo-default-todo-file "/path/to/my/file")
(setq org-toodledo-sync-on-save "no")

and then create a function like:

(defun org-toodledo-sync-silently ()
"Sync a initialized toodledo file with the server on background."
(find-file-noselect org-toodledo-default-todo-file)
(with-temp-buffer
(when (find-buffer-visiting org-toodledo-default-todo-file)
(set-buffer (get-file-buffer org-toodledo-default-todo-file))
(org-toodledo-sync)
(save-buffer))))

With this function defined (with autoload) we can associate a hook
after loading the org-toodledo mode or/and after killing the buffer.

Additionally we can define a cron-like process on Emacs to sync
periodically instead of syncing every time we save the file using.

;; sync each 20 min the toodledo file after waiting 5 min.
(run-with-timer (* 5 60) (* 20 60) 'org-toodledo-sync-silently)


Reply to this email directly or view it on GitHub
#40.

@jrbalderrama
Copy link
Author

Sorry maybe my explanation isn't clear. If we have a org-toodledo minor mode we can sync the todo list after loading that mode or after killing the buffer (defining those hooks in the minor mode) instead of explicitly call a function or schedule a process to sync periodically. The periodic sync can also be included as well, for convenience, independently.

@christopherjwhite
Copy link
Owner

Aah, yes -- that makes sense. Having a minor mode would also allow
definition of default key bindings and probably some other goodies.

...cj

On 4/3/14 11:39 AM, jrbalderrama wrote:

Sorry maybe my explanation isn't clear. If we have a org-toodledo
minor mode we can sync the todo list after loading that mode or after
killing the buffer (defining those hooks in the minor mode) instead of
explicitly call a function or schedule a process to sync periodically.
The periodic sync can also be included as well, for convenience,
independently.


Reply to this email directly or view it on GitHub
#40 (comment).

@jrbalderrama
Copy link
Author

That's the spirit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants