emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* link to magit-status buffers
@ 2009-08-15 13:27 Stephan Schmitt
  0 siblings, 0 replies; only message in thread
From: Stephan Schmitt @ 2009-08-15 13:27 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-15 13:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-15 13:27 link to magit-status buffers Stephan Schmitt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).