lang/org: make TAB keybind dwim; including yas-expand

This commit is contained in:
Henrik Lissner 2017-04-10 01:10:42 -04:00
parent 335d9c27a9
commit 5402521647
2 changed files with 12 additions and 4 deletions

View file

@ -26,10 +26,18 @@
(t (call-interactively 'self-insert-command)))) (t (call-interactively 'self-insert-command))))
;;;###autoload ;;;###autoload
(defun +org/indent-or-next-field () (defun +org/indent-or-next-field-or-yas-expand ()
"Depending on the context either indent the current item or go the next table field." "Depending on the context either a) indent the current line, b) go the next
table field or c) run `yas-expand'."
(interactive) (interactive)
(call-interactively (if (org-at-table-p) 'org-table-next-field '+org/indent))) (call-interactively
(cond ((and (bound-and-true-p yas-minor-mode)
(yas--templates-for-key-at-point))
'yas-expand)
((org-at-table-p)
'org-table-next-field)
(t
'+org/indent))))
;;;###autoload ;;;###autoload
(defun +org/dedent () (defun +org/dedent ()

View file

@ -239,7 +239,7 @@
:i "C-e" 'org-end-of-line :i "C-e" 'org-end-of-line
:i "C-a" 'org-beginning-of-line :i "C-a" 'org-beginning-of-line
:i "<tab>" '+org/indent-or-next-field :i "<tab>" '+org/indent-or-next-field-or-yas-expand
:i [S-iso-lefttab] '+org/dedent-or-prev-field ; for GNU Emacs :i [S-iso-lefttab] '+org/dedent-or-prev-field ; for GNU Emacs
:i [(shift tab)] '+org/dedent-or-prev-field :i [(shift tab)] '+org/dedent-or-prev-field
:i [backtab] '+org/dedent-or-prev-field :i [backtab] '+org/dedent-or-prev-field