Add a section on how to write a new binding

This commit is contained in:
James Nguyen 2022-04-14 13:31:36 -04:00
parent ee8b991f3e
commit ec6140e6ca
1 changed files with 61 additions and 0 deletions

View File

@ -654,6 +654,65 @@ Other references:
** Modes left behind
Some modes might still remain unsupported by this package. Should you be
missing your ~<hjkl>~, please feel free to do a pull request.
** Writing a new binding
This [[template][yasnippet template]] can be used to bootstrap a new binding.
For example, if we were to want to add ~evil-collection~ support to ~eldoc~.
(e.g.) There is a package that contains:
#+begin_src emacs-lisp :tangle yes
(provide 'eldoc)
#+end_src
Create a new file under modes/eldoc/ named evil-collection-eldoc.el.
Then use the above template as an example or, using [[yasnippet][yasnippet]],
~yas-expand~ the above template which will result in something like below:
#+begin_src emacs-lisp :tangle yes
;;; evil-collection-eldoc.el --- Bindings for `eldoc'. -*- lexical-binding: t -*-
;; Copyright (C) 2022 James Nguyen
;; Author: James Nguyen <james@jojojames.com>
;; Maintainer: James Nguyen <james@jojojames.com>
;; URL: https://github.com/emacs-evil/evil-collection
;; Version: 0.0.2
;; Package-Requires: ((emacs "27.1"))
;; Keywords: evil, emacs, convenience, tools
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Bindings for eldoc.
;;; Code:
(require 'evil)
(require 'eldoc nil t)
(defvar eldoc-mode-map)
(defconst evil-collection-eldoc-maps '(eldoc-mode-map))
(defun evil-collection-eldoc-setup ()
"Set up `evil' bindings for eldoc."
(evil-collection-define-key 'normal 'eldoc-mode-map
))
(provide 'evil-collection-eldoc)
;;; evil-collection-eldoc.el ends here
#+end_src
Finally, add eldoc to ~evil-collection--supported-modes~.
** Contributing
We welcome any additional modes that are not already supported.
@ -669,3 +728,5 @@ Follow [[https://github.com/bbatsov/emacs-lisp-style-guide/][The Emacs Lisp Styl
#+LINK: evilmagit https://github.com/emacs-evil/evil-magit
#+LINK: evilmu4e https://github.com/JorisE/evil-mu4e
#+LINK: mu4e https://www.djcbsoftware.nl/code/mu/mu4e.html
#+LINK: yasnippet https://github.com/joaotavora/yasnippet
#+LINK: template https://github.com/emacs-evil/evil-collection/blob/master/yasnippet_evil-collection