blob: 9c48513bc74ccf074b9ddc5bced5831fda9e5669 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
;;; evil-collection-reftex.el --- Bindings for `reftex'. -*- lexical-binding: t -*-
;; Copyright (C) 2017 Pierre Neidhardt
;; Author: Maximiliano Sandoval <msandova@protonmail.com>
;; Maintainer: James Nguyen <james@jojojames.com>
;; Pierre Neidhardt <ambrevar@gmail.com>
;; URL: https://github.com/emacs-evil/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, reftex, tools
;; 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:
;; Evil bindings for `reftex-mode'.
;;; Code:
(require 'evil-collection)
(require 'reftex-ref nil t)
(require 'reftex-ref nil t)
(require 'reftex-cite nil t)
(defconst evil-collection-reftex-maps '(reftex-select-shared-map
reftex-toc-mode-map))
;; original code can be found in reftex-ref.el
(setq reftex-select-label-prompt
"Select: [RET]select [j]next [k]previous [gr]escan [go]context [q]uit [g?]help")
;; original code can be found in reftex-cite.el
(setq reftex-citation-prompt
"Select: [RET]select [j]next [k]previous [q]uit [g?]help")
;; original at reftex-ref.el
(setq reftex-select-label-help
" j / k Go to next/previous label (Cursor motion works as well)
[ / ] Go to previous/next section heading.
c Reuse last referenced label.
J Jump to a specific section, e.g. '3 J' jumps to section 3.
s Switch label type.
gr Reparse document.
go / gO Show context / Show insertion point.
S Switch to label menu of external document (with LaTeX package `xr').
r / R Toggle \\ref <-> \\vref / Rotate \\ref <=> \\fref <=> \\Fref.
TAB Enter a label with completion.
m / M Mark/unmark entry.
x / X Put all marked entries into one/many \\ref commands.
q / RET Quit without referencing / Accept current label.")
;; code can be found in reftex-cite.el
(setq reftex-citation-help
" j / k Go to next/previous entry (Cursor motion works as well).
go / gO Show citation / Show insertion point.
q Quit without inserting \\cite macro into buffer.
TAB Enter citation key with completion.
RET Accept current entry and create \\cite macro.
m / M Mark/Unmark the entry.
o / O Create BibTeX file with all marked / unmarked entries.
X / X Put all (marked) entries into one/many \\cite commands.")
(defun evil-collection-reftex-setup ()
"Set up `evil' bindings for `reftex'."
(evil-set-initial-state 'reftex-select-label-mode 'normal)
(evil-set-initial-state 'reftex-select-bib-mode 'normal)
(evil-collection-define-key 'normal 'reftex-select-shared-map
"j" 'reftex-select-next
"k" 'reftex-select-previous
(kbd "]") 'reftex-select-next-heading
(kbd "[") 'reftex-select-previous-heading
(kbd "gj") 'reftex-select-next-heading
(kbd "gk") 'reftex-select-previous-heading
(kbd "C-j") 'reftex-select-next-heading
(kbd "C-k") 'reftex-select-previous-heading
"go" 'reftex-select-callback ;shows the point where the label is
"gr" (lambda nil "Press `?' during selection to find out
about this key" (interactive) (throw (quote myexit) 114)) ;reftex binds keys in a very arcane way using the number asigned by describe-char, in this case the value of "g" is 114
"q" 'reftex-select-quit
"ZZ" 'reftex-select-quit
"ZQ" 'evil-quit
"g?" 'reftex-select-help
"c" (lambda nil "Press `?' during selection to find out
about this key." (interactive) (throw (quote myexit) 108))
"J" 'reftex-select-jump ;; weird binding, using default
(kbd "<tab>") 'reftex-select-read-label
"s" (lambda nil "Press `?' during selection to find out
about this key." (interactive) (throw (quote myexit) 115))
"x" (lambda nil "Press `?' during selection to find out
about this key." (interactive) (throw (quote myexit) 97))
"X" (lambda nil "Press `?' during selection to find out
about this key." (interactive) (throw (quote myexit) 65))
"S" (lambda nil "Press `?' during selection to find out
about this key." (interactive) (throw (quote myexit) 120))
"r" 'reftex-select-cycle-ref-style-forward
"R" 'reftex-select-cycle-ref-style-backward
"gO" 'reftex-select-show-insertion-point
"o" (lambda nil "Press `?' during selection to find out
about this key." (interactive) (throw (quote myexit) 101))
"O" (lambda nil "Press `?' during selection to find out
about this key." (interactive) (throw (quote myexit) 69))
;; mark
"m" 'reftex-select-mark ; TODO: Need a mark toggle function.
"u" 'reftex-select-unmark)
(evil-set-initial-state 'reftex-toc-mode 'normal)
;; This one is more involved, in reftex-toc.el, line 282 it shows the prompt
;; string with the keybinds and I don't see any way of changing it to show evil-like binds.
(evil-collection-define-key 'normal 'reftex-toc-mode-map
"j" 'reftex-toc-next
"k" 'reftex-toc-previous
(kbd "RET") 'reftex-toc-goto-line-and-hide
(kbd "<tab>") 'reftex-toc-goto-line
"g?" 'reftex-toc-show-help
"q" 'reftex-toc-quit
"ZZ" 'reftex-toc-quit
"ZQ" 'evil-quit
"gr" 'reftex-toc-rescan
"r" 'reftex-toc-rescan
"l" 'reftex-toc-toggle-labels
"?" 'reftex-toc-show-help
"x" 'reftex-toc-external
;; (kbd "SPC") 'reftex-toc-view-line
"f" 'reftex-toc-toggle-follow))
(provide 'evil-collection-reftex)
;;; evil-collection-reftex.el ends here
|