Giter Site home page Giter Site logo

orgsync's Introduction

How to configure

We need 2 hooks

  • starting: after-change-major-mode-hook
  • saving: after-save-hook

Installation

  • Clone this repo / download to `~/orgsync` path. Of course, custom location are fine.
  • In your `.emacs` or `.spacemacs` file, at the very end place this block to load our custom script
    ;; Load custom startup functions
    (load "~/orgsync/emacs/startup")
    ;; if you used a different directory then change it here.
        
  • Thats it!

Default behavior

  • We load the script on emacs/spacemacs launch. This adds hook for org-mode file open & file save.
  • On file open/save we trigger pull (to retrieve) / push (to store) the org file.
  • There are 2 strategy to do so. `Rsync` to a path or Use git. Default is to use `git`.
  • If you open a org file on a directory under git source control; it will commit and push to master. This can be changed by changing parameter in push.py
  • Either you use rsync or git, there is a delay to load/store file. Allow few seconds in this process.

Concept Aside

onLoad hook

;; onLoad org mode hook
;; find if there is a corresponding file in the remote
;; if there is then rsync it and reload
;; if there is not then keep going
(defun sync-from-cloud-if-possible()
  (interactive)
  (when (eq major-mode 'org-mode)
    ;; you can either use `rsync` or `git` as strategy
    (shell-command-to-string (format "python ~/orgsync/pull.py git %s" buffer-file-name))
    (message "Done pulling!")
    )
  )

(add-hook 'after-change-major-mode-hook #'sync-from-cloud-if-possible)

onSaveHook

;; Add hooks afterSave
;; while the mode is org-mode
;; call python syncer. 
(defun sync-to-cloud ()
  "Sync org file to github repo"
  (interactive)
  (when (eq major-mode 'org-mode)
    ;; you can use `rsync` or `git` as strategy
    (shell-command-to-string (format "python ~/orgsync/push.py %s" buffer-file-name))
    (message "Done rsyncing")
    ))

(add-hook 'after-save-hook #'sync-to-cloud)     

Restart emacs. You should be good to go!

Troubleshooting

  • If rsync takes too long and you feel emacs is freezing ==> it is freezing for real. Dont worry. You will get control in few seconds depending on your connection.
  • If rsync doesnot work, try rsyncing to your server in the terminal so that the system can authenticate you for the first time. (I havent done extensive work on this part yet.)

orgsync's People

Contributors

kandelvijaya avatar yikandel avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.