documentation on writing extensions?

18 views
Skip to first unread message

John Kitchin

unread,
May 7, 2017, 9:19:16 PM5/7/17
to magit
Has the documentation for writing extensions to magit been moved? All I could find is labeled: Magit User Manual (1.2 OBSOLETE): Activating extensions.

Kyle Meyer

unread,
May 7, 2017, 10:58:11 PM5/7/17
to John Kitchin, magit
I'm not sure what documentation may have existed in the past, but I'm
not aware of any documentation for recent versions of Magit. The
section you reference was removed quite a while ago -- before version
2.1.0 -- in 6a0a73f5 (magit-{stgit,svn,topgit}.el: add longer library
commentaries, 2014-04-09).

Do you have specific questions about writing an extension?

--
Kyle

John Kitchin

unread,
May 8, 2017, 11:10:58 AM5/8/17
to Kyle Meyer, magit
I am working on an extension to list issues in a section that are found
in org-files within the git repo. Sort of a local issue tracker that is
under vc.

I have figured out most of it by looking at other extensions, but there
have been a few points that still aren't clear, mostly related to
keymaps, menu items, etc.. that I thought there might be some
documentation somewhere on. Also, how to hook into pressing return to
magit-visit-thing, or k to magit-delete-thing, etc.
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

Kyle Meyer

unread,
May 8, 2017, 11:43:16 AM5/8/17
to John Kitchin, magit
John Kitchin <jkit...@andrew.cmu.edu> writes:

> I have figured out most of it by looking at other extensions, but there
> have been a few points that still aren't clear, mostly related to
> keymaps, menu items, etc.. that I thought there might be some
> documentation somewhere on.

Some information on sections and their keymaps is here:

https://magit.vc/manual/magit/Creating-Sections.html#Creating-Sections

The main point is that a section type can be associated with a keymap,
magit-TYPE-section-map.

> Also, how to hook into pressing return to magit-visit-thing, or k to
> magit-delete-thing, etc.

If you have your own section type, you can remap magit-visit-thing and
magit-delete-thing in the keymap. For example, here's the key map for
the "unstaged" section type:

(defvar magit-unstaged-section-map
(let ((map (make-sparse-keymap)))
(define-key map [remap magit-visit-thing] 'magit-diff-unstaged)
(define-key map [remap magit-delete-thing] 'magit-discard)
(define-key map "s" 'magit-stage)
(define-key map "u" 'magit-unstage)
map)
"Keymap for the `unstaged' section.")

--
Kyle
Reply all
Reply to author
Forward
0 new messages