Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge most changes from upstream evil-org-mode #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ From version 1.3 it was taken over by Somelauw.
See [[file:doc/changelog.org][changelog]] for a history of changes.

** Features

- normal, visual and insert mode bindings
- key bindings organised in key themes
- operators like > and < to work on headings
Expand Down Expand Up @@ -68,7 +69,7 @@ See [[file:doc/changelog.org][changelog]] for a history of changes.
|-------------------------+-------------------------+-----------------------------------------------------------------------------------|
| Evil key | Emacs key | explanation |
|-------------------------+-------------------------+-----------------------------------------------------------------------------------|
| <tab>, S-<return> | <tab> | go to the corresponding entry at point |
| TAB, S-<return> | TAB | go to the corresponding entry at point |
| <return> | <return> | go to the Org mode file which contains the item at point |
| M-<return> | L | Display Org file and center around the item |
| <space> | <space> | scroll up |
Expand Down Expand Up @@ -101,10 +102,10 @@ See [[file:doc/changelog.org][changelog]] for a history of changes.
| gR | g | refresh all agendas |
| ZQ | x | exit agenda |
| ZZ | Q | quit agenda |
| z | v | tweak display (deadlines, diary, follow/log-mode, entry text, grid, day/week/year |
| gD | v | tweak display (deadlines, diary, follow/log-mode, entry text, grid, day/week/year |
| ZD | # | dim blocked tasks |
| sc, sr, se, st, s^ | <, =, _, /, ^ | filter by category, regexp, effort, tag, top headline |
| su | \vert | remove all filters |
| S | \vert | remove all filters |
| ss | ~ | filter/limit interactively |
| I | I | clock in |
| O | O | clock out |
Expand All @@ -130,15 +131,16 @@ See [[file:doc/changelog.org][changelog]] for a history of changes.
** Installation

*** Manual installation

#+BEGIN_SRC sh
mkdir -p ~/.emacs.d/plugins; git clone
git://github.com/somelauw/evil-org.git ~/.emacs.d/plugins/evil-org
mkdir -p ~/.emacs.d/plugins; git clone \
git://github.com/somelauw/evil-org-mode.git ~/.emacs.d/plugins/evil-org-mode
#+END_SRC

**** Configuration emacs.el

#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path "~/.emacs.d/plugins/evil-org")
(add-to-list 'load-path "~/.emacs.d/plugins/evil-org-mode")
(require 'evil-org)
(add-hook 'org-mode-hook 'evil-org-mode)
(evil-org-set-key-theme '(navigation insert textobjects additional calendar))
Expand All @@ -152,15 +154,15 @@ See [[file:doc/changelog.org][changelog]] for a history of changes.
#+END_SRC

*** Installation by use-package

#+BEGIN_SRC emacs-lisp
(use-package evil-org
:ensure t
:after org
:hook ((org-mode . evil-org-mode)
(org-agenda-mode . evil-org-agenda-mode))
:config
(add-hook 'org-mode-hook 'evil-org-mode)
(add-hook 'evil-org-mode-hook
(lambda ()
(evil-org-set-key-theme)))
(evil-org-set-key-theme)
(require 'evil-org-agenda)
(evil-org-agenda-set-keys))
#+END_SRC
Expand Down
10 changes: 5 additions & 5 deletions evil-org-agenda.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; evil-org-agenda.el --- evil keybindings for org-agenda-mode
;;; evil-org-agenda.el --- evil keybindings for org-agenda-mode -*- lexical-binding: t; -*-

;; Copyright (C) 2012-2017 by Somelauw
;; Maintainer: Somelauw
Expand Down Expand Up @@ -95,8 +95,8 @@
"gk" 'org-agenda-previous-item
(kbd "C-j") 'org-agenda-next-item
(kbd "C-k") 'org-agenda-previous-item
(kbd "[") 'org-agenda-earlier
(kbd "]") 'org-agenda-later
(kbd "[[") 'org-agenda-earlier
(kbd "]]") 'org-agenda-later
"0" 'evil-org-agenda-digit-argument-or-evil-beginning-of-line

;; manipulation
Expand Down Expand Up @@ -134,7 +134,7 @@
"~" 'org-agenda-bulk-toggle-all
"*" 'org-agenda-bulk-mark-all
"%" 'org-agenda-bulk-mark-regexp
"M" 'org-agenda-bulk-remove-all-marks
"M" 'org-agenda-bulk-unmark-all
"x" 'org-agenda-bulk-action

;; refresh
Expand All @@ -156,7 +156,7 @@
;; 'org-agenda-day-view
;; 'org-agenda-week-view
;; 'org-agenda-year-view
"z" 'org-agenda-view-mode-dispatch
"gD" 'org-agenda-view-mode-dispatch
"ZD" 'org-agenda-dim-blocked-tasks

;; filter
Expand Down
1 change: 1 addition & 0 deletions evil-org-test.el
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
;; -*- lexical-binding: t -*-
(require 'evil-org)
(require 'ert)

Expand Down
49 changes: 25 additions & 24 deletions evil-org.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; evil-org.el --- evil keybindings for org-mode
;;; evil-org.el --- evil keybindings for org-mode -*- lexical-binding: t; -*-

;; Copyright (C) 2012-2017 by Somelauw
;; Maintainer: Somelauw
Expand All @@ -7,8 +7,8 @@
;; Git-Repository: git://github.com/Somelauw/evil-org-mode.git
;; Created: 2012-06-14
;; Forked-since: 2017-02-12
;; Version: 1.0.2
;; Package-Requires: ((emacs "24.4") (evil "1.0"))
;; Version: 1.0.3
;; Package-Requires: ((emacs "25.1") (evil "1.0"))
;; Keywords: evil vim-emulation org-mode key-bindings presets

;; This file is not part of GNU Emacs
Expand Down Expand Up @@ -36,8 +36,10 @@
;;
;;; Code:
(eval-when-compile
(require 'let-alist))
(require 'let-alist)
(require 'org-capture))
(require 'cl-lib)
(require 'cl-seq)
(require 'evil)
(require 'org)
(require 'org-element)
Expand Down Expand Up @@ -86,7 +88,7 @@ This can be used by non-qwerty users who don't use hjkl."
(defcustom evil-org-special-o/O '(table-row item)
"When o and O should be special.
This makes them continue item lists and table rows.
By default, o and O are bound to evil-org-open-above and evil-org-open-below."
By default, o and O are bound to `evil-org-open-above' and `evil-org-open-below'."
:group 'evil-org
:type '(set (const table-row) (const item)))

Expand Down Expand Up @@ -125,7 +127,7 @@ before calling `evil-org-set-keytheme'."
"Go to end of line and call provided function.
FUN function callback
Optional argument ARGUMENTS arguments to pass to FUN."
(obsolete 'evil-org-define-bol-command "0.9.4")
(declare (obsolete 'evil-org-define-eol-command "0.9.4"))
(end-of-visible-line)
(apply fun arguments)
(evil-insert nil))
Expand All @@ -134,7 +136,7 @@ Optional argument ARGUMENTS arguments to pass to FUN."
"Go to beginning of line and call provided function.
FUN function callback
Optional argument ARGUMENTS arguments to pass to FUN."
(obsolete 'evil-org-define-bol-command "0.9.4")
(declare (obsolete 'evil-org-define-bol-command "0.9.4"))
(beginning-of-line)
(apply fun arguments)
(evil-insert nil))
Expand Down Expand Up @@ -311,7 +313,7 @@ makes `org-special-ctrl-a/e' work as well."
;;; insertion commands
(defun evil-org-insert-line (count)
"Insert at beginning of line.
If org-special-ctrl-a/e insertion will be done after heading and item markers.
If `org-special-ctrl-a/e' insertion will be done after heading and item markers.
The insertion will be repeated COUNT times."
(interactive "p")
(if (org-at-heading-or-item-p)
Expand All @@ -323,7 +325,7 @@ The insertion will be repeated COUNT times."

(defun evil-org-append-line (count)
"Append at end of line before ellipses if present.
If org-special-ctrl-a/e insert before tags on headlines.
If `org-special-ctrl-a/e' insert before tags on headlines.
The insertion will be repeated COUNT times."
(interactive "p")
(if (org-at-heading-p)
Expand All @@ -336,7 +338,7 @@ The insertion will be repeated COUNT times."
(defun evil-org-open-below (count)
"Clever insertion of org item.
Argument COUNT number of lines to insert.
The behavior in items and tables can be controlled using evil-org-special-o/O.
The behavior in items and tables can be controlled using `evil-org-special-o/O'.
Passing in any prefix argument, executes the command without special behavior."
(interactive "P")
(cond ((and (memq 'table-row evil-org-special-o/O) (org-at-table-p))
Expand All @@ -361,7 +363,7 @@ Passing in any prefix argument, executes the command without special behavior."
(defun evil-org-open-above (count)
"Clever insertion of org item.
Argument COUNT number of lines to insert.
The behavior in items and tables can be controlled using evil-org-special-o/O.
The behavior in items and tables can be controlled using `evil-org-special-o/O'.
Passing in any prefix argument, executes the command without special behavior."
(interactive "P")
(cond ((and (memq 'table-row evil-org-special-o/O) (org-at-table-p))
Expand All @@ -382,7 +384,7 @@ Passing in any prefix argument, executes the command without special behavior."
"Like `org-return', but continues items and tables like `evil-open-below'.
Pressing return twice cancels the continuation of the itemlist or table.
If ARG is set it will not cancel the continuation.
The behavior of this function can be controlled using `evil-org-special-o/O."
The behavior of this function can be controlled using `evil-org-special-o/O'."
(interactive "P")
(cond ((and (not arg) (evil-org--empty-element-p))
(delete-region (line-beginning-position) (line-end-position)))
Expand All @@ -400,7 +402,7 @@ The behavior of this function can be controlled using `evil-org-special-o/O’."
(row (nth (1- (org-table-current-line)) rows)))
(cl-every 'string-empty-p row)))
((org-at-item-p)
(string-match-p "^[[:space:]]*\\([+-]\\|[1-9]+\\.\\)[[:space:]]*\\(::[[:space:]]*\\)?$"
(string-match-p "^[[:space:]]*\\([+-]\\|[[:digit:]]+[.)]\\)[[:space:]]*\\(::[[:space:]]*\\)?$"
(thing-at-point 'line)))))

;; other
Expand Down Expand Up @@ -514,7 +516,7 @@ Argument END, second column
If ARG > 0, move column BEG to END.
If ARG < 0, move column END to BEG"
(let* ((text (buffer-substring beg end))
(n-cells-selected (max 1 (count ?| text)))
(n-cells-selected (max 1 (cl-count ?| text)))
(n-columns-to-move (* n-cells-selected (abs arg)))
(move-left-p (< arg 0)))
(goto-char (if move-left-p end beg))
Expand Down Expand Up @@ -565,7 +567,7 @@ Argument INCOG whether to open in incognito mode."
;; break from outer loop when there are no more
;; org links
(when (or (not (< (point) end))
(not (null org-link-search-failed)))
(not (null org-link--search-failed)))
(throw 'break 0))
(if (not (null incog))
(evil-org-open-incognito)
Expand Down Expand Up @@ -736,6 +738,7 @@ Includes tables, list items and subtrees."
(defun evil-org--populate-base-bindings ()
"Bindings that are always available."
(evil-define-key 'motion evil-org-mode-map
(kbd "0") #'evil-org-beginning-of-line
(kbd "$") #'evil-org-end-of-line
(kbd ")") #'evil-org-forward-sentence
(kbd "(") #'evil-org-backward-sentence
Expand All @@ -756,7 +759,7 @@ Includes tables, list items and subtrees."
(evil-define-key '(normal visual) evil-org-mode-map
(kbd "TAB") #'org-cycle
(kbd "<tab>") #'org-cycle
(kbd "<S-tab>") #'org-shifttab
(kbd "<backtab>") #'org-shifttab
(kbd "<") #'evil-org-<
(kbd ">") #'evil-org->))

Expand Down Expand Up @@ -812,10 +815,10 @@ Includes tables, list items and subtrees."
"Shift bindings that conflict with evil bindings."
(let-alist evil-org-movement-bindings
(evil-define-key 'normal evil-org-mode-map
(capitalize .left) 'org-shiftleft
(capitalize .right) 'org-shiftright
(capitalize .down) 'org-shiftdown
(capitalize .up) 'org-shiftup)
(capitalize .left) #'org-shiftleft
(capitalize .right) #'org-shiftright
(capitalize .down) #'org-shiftdown
(capitalize .up) #'org-shiftup)

;; Make shift keys fall back on the keys they have replaced
(when evil-org-want-hybrid-shift
Expand Down Expand Up @@ -876,7 +879,7 @@ Includes tables, list items and subtrees."

(defun evil-org-set-key-theme (&optional theme)
"Select what keythemes to enable.
Optional argument THEME list of themes. See evil-org-keytheme for a list of values."
Optional argument THEME list of themes. See `evil-org-key-theme' for a list of values."
(let ((theme (or theme evil-org-key-theme)))
(setq evil-org-mode-map (make-sparse-keymap))
(evil-org--populate-base-bindings)
Expand All @@ -890,9 +893,7 @@ Optional argument THEME list of themes. See evil-org-keytheme for a list of valu
(when (memq 'todo theme) (evil-org--populate-todo-bindings))
(when (memq 'heading theme) (evil-org--populate-heading-bindings))
(when (memq 'calendar theme) (evil-org--populate-calendar-bindings))
(setcdr
(assq 'evil-org-mode minor-mode-map-alist)
evil-org-mode-map)))
(setcdr (assq 'evil-org-mode minor-mode-map-alist) evil-org-mode-map)))

(defun evil-org-edit-src-exit ()
"Save then `evil-edit-src-exit'."
Expand Down