No Description

Jonas Hoersch 4c6395ce04 os: os-headline-to-buglist calls os-headline-to-bug on its descendants 8 years ago 9559d8153a update feature name in example. 8 years ago b0ff48fc7b remove DELETE status from TODO. 8 years ago
omd.el 1d8ae05dfc omd.el: respect `recurse' arg when shuffling. 8 years ago
os-bb.el a276e49450 change feature name to os. 8 years ago
os-github.el bdcbaebaba os-github: use authentication data also for os-github-fetch-json-page 8 years ago
os-rmine.el a276e49450 change feature name to os. 8 years ago
os-rtm.el a276e49450 change feature name to os. 8 years ago
os.el 4c6395ce04 os: os-headline-to-buglist calls os-headline-to-bug on its descendants 8 years ago


Org-sync is a tool to synchronize online bugtrackers with org documents.


Put the org-sync directory in your load-path and load the org-sync backend you need. You can add this to your .emacs:

(add-to-list 'load-path "path/to/org-sync") (mapc 'load '("org-element" "os" "os-bb" "os-github" "os-rmine"))

Make sure you have org-element.el (it's in the contrib directory of org-mode). If you don't have it you can download a recent version in the org-sync directory:

wget -O org-element.el ';a=blob_plain;f=contrib/lisp/org-element.el;hb=5057ae0fc2'


Next, open a new org-mode buffer and run M-x os-import. It prompts you for an URL. You can try my github test repo: Org-sync should import the issues from the repo.

Now, let's try to add a new issue. First you have to set a user/password to be able to modify the issue remotely.

Set the variable os-github-auth to like so: =(setq os-github-auth '("ostesting" . "thisisostesting42"))=

Try to add another issue e.g. insert ** OPEN my test issue. You can type a description under it if you want.

The next step is simple, just run M-x os-sync. It synchronize all the buglists in the document.

How to write a new backend

Writing a new backend is easy. If something is not clear, try to read the header in os.el or one of the existing backend.

;; backend symbol/name: demo ;; the symbol is used to find and call your backend functions (for now)

;; what kind of urls does you backend handle? ;; add it to os-backend-alist in os.el:

(defvar os-backend-alist '(("\\(?:repos/\\)?[^/]+/[^/]+" . os-github-backend) ("[^/]+/[^/]+" . os-bb-backend) ("" . os-demo-backend)))

;; if you have already loaded os.el, you'll have to add it ;; manually in that case just eval this in *scratch* (add-to-list 'os-backend-alist (cons "" 'os-demo-backend))

;; now, in its own file os-demo.el:

(require 'os)

;; this is the variable used in os-backend-alist (defvar os-demo-backend '((base-url . os-demo-base-url) (fetch-buglist . os-demo-fetch-buglist) (send-buglist . os-demo-send-buglist)) "Demo backend.")

;; this overrides os--base-url. ;; the argument is the url the user gave. ;; it must return a cannonical version of the url that will be ;; available to your backend function in the os-base-url variable.

;; In the github backend, it returns API base url ;; ie. https://api.github/reposa//

(defun os-demo-base-url (url) "Return proper URL." "")

;; this overrides os--fetch-buglist ;; you can use the variable os-base-url (defun os-demo-fetch-buglist (last-update) "Fetch buglist from (anything that happened after LAST-UPDATE)" ;; a buglist is just a plist `(:title "Stuff at" :url ,os-base-url

;; add a :since property set to last-update if you return ;; only the bugs updated since it. omit it or set it to ;; nil if you ignore last-update and fetch all the bugs of ;; the repo.

;; bugs contains a list of bugs ;; a bug is a plist too :bugs ((:id 1 :title "Foo" :status open :desc "bar."))))

;; this overrides os--send-buglist (defun os-demo-send-buglist (buglist) "Send BUGLIST to and return updated buglist" ;; here you should loop over :bugs in buglist (dolist (b (os-get-prop :bugs buglist)) (cond ;; new bug (no id) ((null (os-get-prop :id b) '(do-stuff)))

;; delete bug ((os-get-prop :delete b) '(do-stuff))

;; else, modified bug (t '(do-stuff))))

;; return any bug that has changed (modification date, new bugs, ;; etc). they will overwrite/be added in the buglist in os.el

;; we return the same thing for the demo. ;; :bugs is the only property used from this function in os.el `(:bugs ((:id 1 :title "Foo" :status open :desc "bar."))))

That's it. A bug has to have at least an id, title and status properties. Other recognized but optionnal properties are =:date-deadline=, :date-creation, :date-modification, :desc. Any other properties are automatically added in the PROPERTIES block of the bug via prin1-to-string and are read back by org-sync. All the dates are regular emacs time object. For more details you can look at the github backend in os-github.el.

More information

You can find more in the os.el commentary headers.