Skip to content

Instantly share code, notes, and snippets.

@lamberta
Created October 27, 2009 21:29
Show Gist options
  • Save lamberta/219976 to your computer and use it in GitHub Desktop.
Save lamberta/219976 to your computer and use it in GitHub Desktop.

Revisions

  1. biilly revised this gist Oct 27, 2009. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .emacs
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,8 @@


    ;;key-binding to auto-update with a default commit message
    ;;using todo-list-mode, http://github.com/biilly/scripts/blob/master/emacs/lisp/todo-list-mode.el
    ;;using todo-list-mode:
    ;;http://github.com/biilly/scripts/blob/master/emacs/lisp/todo-list-mode.el
    (add-hook 'todo-list-mode-hook
    '(lambda ()
    (local-set-key (kbd "C-x p")
  2. biilly revised this gist Oct 27, 2009. 1 changed file with 10 additions and 9 deletions.
    19 changes: 10 additions & 9 deletions readme
    Original file line number Diff line number Diff line change
    @@ -4,20 +4,21 @@ Using a remote git repository as a version controlled todo list.
    There are two problems with using a local text file as a todo list,
    remote access and continuity. Hosting the file on a server introduces
    a number of sync issues along with restricting access to an internet
    connection. Marking items off your todo list deletes the item forever,
    making retrieval of previous task details unavailable without some kind
    of backup system is in place.
    connection. Marking items off your todo list deletes them forever,
    making retrieval of previous task details unavailable without some
    kind of backup system in place.
    This example uses git's decentralized version control capabilities to
    manage a todo list that provides backup, retrieval, remote access, and
    that is easily synchronized across multiple machines.
    It uses github.com and some emacs lisp for easy integration.
    that is easily synchronized across multiple machines. It uses git,
    github.com and some emacs lisp for easy integration.


    * Create a new git repository
    After signing up for a GitHub account, create a new 'gist' at http://gist.github.com/
    Copy your current todo list into the file section and create a private gist.
    Copy the url from the 'Private Clone URL' and enter it at the command line.
    This will download your todo list into the todo-list directory:
    After signing up for a GitHub account, create a new 'gist' at
    http://gist.github.com/ Copy your current todo list into the file
    section and create a private gist. Copy the url from the
    'Private Clone URL' and enter it at the command line. This will
    download your todo list into the todo-list directory:
    $ git clone [email protected]:4f5fd685937c0c946f82.git todo-list

    * Update file
  3. biilly created this gist Oct 27, 2009.
    30 changes: 30 additions & 0 deletions .emacs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    ;;add to your .emacs

    (defun git-commit-file-and-push (&optional commit-msg)
    "Commit current file and push to git repository."
    (interactive)
    (if (null commit-msg)
    (setq commit-msg (read-from-minibuffer "Commit message: ")))
    (if (buffer-modified-p (current-buffer))
    (if (y-or-n-p "Save modified buffer? ")
    (save-buffer)))
    (let ((file (buffer-file-name (current-buffer)))
    (git (lambda (command error-msg)
    ;;run git command and check return status
    (if (not (eq 0 (shell-command (concat "git " command))))
    (error "Git: %s" error-msg)))))
    ;;run git commands
    (funcall git (concat "add " file) "Unable to add file")
    (let ((commit (concat "commit -q -m '" commit-msg "'")))
    (funcall git commit "Nothing to commit"))
    (funcall git "push origin" "Unable to update repository")
    (message "Git: Pushed %s to master" file)))


    ;;key-binding to auto-update with a default commit message
    ;;using todo-list-mode, http://github.com/biilly/scripts/blob/master/emacs/lisp/todo-list-mode.el
    (add-hook 'todo-list-mode-hook
    '(lambda ()
    (local-set-key (kbd "C-x p")
    (lambda () (interactive)
    (git-commit-file-and-push "updated from emacs")))))
    38 changes: 38 additions & 0 deletions readme
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    * Abstract
    Using a remote git repository as a version controlled todo list.

    There are two problems with using a local text file as a todo list,
    remote access and continuity. Hosting the file on a server introduces
    a number of sync issues along with restricting access to an internet
    connection. Marking items off your todo list deletes the item forever,
    making retrieval of previous task details unavailable without some kind
    of backup system is in place.
    This example uses git's decentralized version control capabilities to
    manage a todo list that provides backup, retrieval, remote access, and
    that is easily synchronized across multiple machines.
    It uses github.com and some emacs lisp for easy integration.


    * Create a new git repository
    After signing up for a GitHub account, create a new 'gist' at http://gist.github.com/
    Copy your current todo list into the file section and create a private gist.
    Copy the url from the 'Private Clone URL' and enter it at the command line.
    This will download your todo list into the todo-list directory:
    $ git clone [email protected]:4f5fd685937c0c946f82.git todo-list

    * Update file
    Modify the todo list as needed, when finished execute the following
    git commands in your repository to update the remote file:
    $ git add .
    $ git commit -m 'my commit message'
    $ git push origin

    Go back to your github gist and the file should now be synchronized with
    your local todo list. Clicking through the revisions on the right will allow
    you to see older versions of your list.

    * Make it convenient
    By putting the below code in your .emacs file you can automate the git
    commands to a single key-stroke and without leaving Emacs.
    Since github requires authentication you may need to run 'ssh-add' to
    add your public key. See man page for details.