2017-12-07 02:41:09 +01:00
;;; evil-collection-outline.el --- Evil bindings for outline-mode -*- lexical-binding: t -*-
2017-11-06 11:51:28 +01:00
;; Copyright (C) 2017 Pierre Neidhardt
2018-08-27 10:41:51 +02:00
;; Author: Pierre Neidhardt <mail@ambrevar.xyz>
2017-11-07 11:04:12 +01:00
;; Maintainer: James Nguyen <james@jojojames.com>
2018-08-27 10:41:51 +02:00
;; Pierre Neidhardt <mail@ambrevar.xyz>
2018-03-02 02:22:38 +01:00
;; URL: https://github.com/emacs-evil/evil-collection
2017-11-07 11:04:12 +01:00
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, outline, tools
2017-11-06 11:51:28 +01:00
;; This file 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, or (at your
;; option) any later version.
;;
;; This file 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.
;;
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.
;;; Commentary:
2017-11-07 11:04:12 +01:00
;; Evil bindings for outline-mode.
2017-11-06 11:51:28 +01:00
;;; Code:
2018-06-20 03:14:50 +02:00
( require 'evil-collection )
2017-11-06 11:51:28 +01:00
( require 'outline )
2017-12-12 16:35:20 +01:00
( defcustom evil-collection-outline-bind-tab-p t
" Enable <tab>-based bindings in Outline mode.
Unless you have Evil bindings set up for Org mode, Org will
inherit the <tab>-based bindings from Outline. Set this option
to nil if you want to preserve the Emacs-state <tab> keys in Org
mode. "
:group 'evil-collection-outline
:type 'boolean )
2017-12-18 04:26:31 +01:00
( defconst evil-collection-outline-maps ' ( outline-mode-map ) )
2018-10-15 12:30:19 +02:00
;;;###autoload
2017-12-07 02:41:09 +01:00
( defun evil-collection-outline-setup ( )
2017-11-17 03:53:35 +01:00
" Set up `evil' bindings for `outline' . "
2018-02-22 17:54:36 +01:00
( evil-set-initial-state 'outline-mode 'normal )
2017-12-12 16:35:20 +01:00
( when evil-collection-outline-bind-tab-p
2018-06-06 13:32:19 +02:00
( evil-collection-define-key 'normal 'outline-mode-map
2018-02-22 17:54:36 +01:00
( kbd " <backtab> " ) 'outline-show-all ; Also "z r" by default
2017-12-12 16:35:20 +01:00
( kbd " <tab> " ) 'outline-toggle-children ) ) ; Also "z a" by default
2018-06-06 13:32:19 +02:00
( evil-collection-define-key 'normal 'outline-mode-map
2017-11-06 11:51:28 +01:00
;; folding
;; Evil default keys:
;; zO: Show recursively for current branch only.
;; za: Toggle first level like outline-toggle-children.
;; zc: Hide complete subtree.
;; zm: Show only root notes.
;; zo: Show current node like "za".
;; zr: Show everything.
;; "ze" 'outline-hide-entry
;; "zE" 'outline-show-entry
;; "zl" 'outline-hide-leaves
;; "zb" 'outline-show-branches
;; "zo" 'outline-hide-other
" zB " 'outline-hide-body ; Hide all bodies, Emacs has "C-c C-t".
" zb " 'outline-hide-entry ; Hide current body, Emacs has "C-c C-c".
" ze " 'outline-show-entry ; Show current body only, not subtree, reverse of outline-hide-entry, Emacs has "C-c C-e".
" zl " 'outline-hide-leaves ; Like `outline-hide-body' but for current subtree only, Emacs has "C-c C-l".
" zK " 'outline-show-branches ; Show all children recursively but no body. Emacs has "C-c C-k".
" zk " 'outline-show-children ; Direct children only unlike `outline-show-branches', and no content unlike `outline-show-entry' and `outline-toggle-children'. Emacs has "C-c TAB".
2019-03-28 03:04:13 +01:00
" zu " 'outline-up-heading
2017-11-06 11:51:28 +01:00
" zp " 'outline-hide-other ; Hide all nodes and bodies except current body. Emacs has "C-c C-o".
;; outline-hide-sublevels ; q ; Is it any different from `outline-hide-body'?
;; outline-hide-subtree ; Emacs has "C-c C-d", Evil has default "zc".
;; outline-show-subtree ; Emacs has "C-c C-s", Evil has default "zO".
;; TODO: To mark subtree ("C-c @"), we would need to define a tree object.
;; motion
2019-03-16 18:54:12 +01:00
" [[ " 'outline-previous-visible-heading
" ]] " 'outline-next-visible-heading
2017-11-06 11:51:28 +01:00
( kbd " C-k " ) 'outline-backward-same-level
( kbd " C-j " ) 'outline-forward-same-level
2017-11-23 16:28:46 +01:00
" gk " 'outline-backward-same-level
" gj " 'outline-forward-same-level
2017-11-06 11:51:28 +01:00
2018-02-22 17:54:36 +01:00
( kbd " M-h " ) 'outline-promote ; Org-mode has "M-<left>", Evil-org has "M-h"
2017-11-06 11:51:28 +01:00
( kbd " M-j " ) 'outline-move-subtree-down ; Org-mode has "M-<down>", Evil-org has "M-j"
( kbd " M-k " ) 'outline-move-subtree-up ; Org-mode has "M-<up>", Evil-org has "M-k"
2018-02-22 17:54:36 +01:00
( kbd " M-l " ) 'outline-demote ; Org-mode has "M-<right>", Evil-org has "M-l"
2017-11-06 11:51:28 +01:00
( kbd " M-<return> " ) 'outline-insert-heading ) ) ; Org-mode has "M-<return>"
2017-12-07 02:41:09 +01:00
( provide 'evil-collection-outline )
;;; evil-collection-outline.el ends here