emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] link to magit-status buffers


From: Stephan Schmitt
Subject: [Orgmode] link to magit-status buffers
Date: Sat, 15 Aug 2009 15:27:53 +0200
User-agent: Thunderbird 2.0.0.22 (X11/20090814)

Hello,

if you use magit mode for your git repositories and want to
create/follow links to magit status buffers (showing the current branch) like 
this:

[[magit:/usr/local/emacs/org-mode/][/usr/local/emacs/org-mode/]]

you may want to use this code snippet:

--8<---------------cut here---------------start------------->8---
(defun org-magit-store-link ()
  "Store a link to a directory to open with magit."
  (when (eq major-mode 'magit-mode)
    (let* ((dir default-directory)
           (link (org-make-link "magit:" dir))
           (desc (abbreviate-file-name dir)))
      (org-store-link-props :type "magit" :link link :description desc)
      link)))

(defun org-magit-open (dir)
  "Follow a magit link to DIR."
  (require 'magit)
  (magit-status dir))

(org-add-link-type "magit" 'org-magit-open nil)
(add-hook 'org-store-link-functions 'org-magit-store-link)
--8<---------------cut here---------------end--------------->8---

Greetings,
        Stephan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]