Created
January 9, 2017 08:47
-
-
Save Kungsgeten/9be1b6e16475a2e0adf33ea6b229b15b to your computer and use it in GitHub Desktop.
My ryo-mode config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;* Helper functions | |
;; Taken from http://endlessparentheses.com/emacs-narrow-or-widen-dwim.html | |
(defun narrow-or-widen-dwim (p) | |
"Widen if buffer is narrowed, narrow-dwim otherwise. | |
Dwim means: region, org-src-block, org-subtree, or | |
defun, whichever applies first. Narrowing to | |
org-src-block actually calls `org-edit-src-code'. | |
With prefix P, don't widen, just narrow even if buffer | |
is already narrowed." | |
(interactive "P") | |
(declare (interactive-only)) | |
(cond ((and (buffer-narrowed-p) (not p)) (widen)) | |
((region-active-p) | |
(narrow-to-region (region-beginning) | |
(region-end))) | |
((derived-mode-p 'org-mode) | |
;; `org-edit-src-code' is not a real narrowing | |
;; command. Remove this first conditional if | |
;; you don't want it. | |
(cond ((ignore-errors (org-edit-src-code) t) | |
(delete-other-windows)) | |
((ignore-errors (org-narrow-to-block) t)) | |
(t (org-narrow-to-subtree)))) | |
((derived-mode-p 'latex-mode) | |
(LaTeX-narrow-to-environment)) | |
(t (narrow-to-defun)))) | |
(bind-key "C-c n" 'narrow-or-widen-dwim) | |
;;* ryo-modal-mode | |
(use-package ryo-modal :load-path "mylisp/ryo-modal" | |
:commands ryo-modal-mode | |
:bind ("§" . ryo-modal-mode) | |
:init | |
(add-hook 'ryo-modal-mode-hook | |
(lambda () | |
(if ryo-modal-mode | |
(selected-minor-mode 1) | |
(selected-minor-mode -1)))) | |
:config | |
(use-package misc :commands forward-to-word) | |
(use-package evil-nerd-commenter :ensure t) | |
(defun replace-char-at-point () | |
"Like vim's replace command." | |
(interactive) | |
(delete-char 1) | |
(insert " ") | |
(backward-char 1) | |
(message "Replace with char.") | |
(setq-local cursor-type '(hbar . 3)) | |
(call-interactively #'quoted-insert) | |
(setq-local cursor-type (default-value 'cursor-type)) | |
(delete-char 1) | |
(backward-char 1)) | |
(defun copy-line () | |
"Saves current line to kill ring." | |
(interactive) | |
(kill-ring-save (line-beginning-position) (line-end-position))) | |
(defun move-current-line () | |
"Kills line and move it using avy." | |
(interactive) | |
(let ((beg (beginning-of-line)) | |
(end (end-of-line))) | |
(kill-whole-line) | |
(avy-goto-line) | |
(yank))) | |
(defun change-current-line () | |
"Kill current line, but do not remove it." | |
(crux-move-beginning-of-line) | |
(kill-line 1)) | |
(ryo-modal-keys | |
;; Misc | |
("0" "M-0") | |
("1" "M-1") | |
("2" "M-2") | |
("3" "M-3") | |
("4" "M-4") | |
("5" "M-5") | |
("6" "M-6") | |
("7" "M-7") | |
("8" "M-8") | |
("9" "M-9") | |
("s" helm-M-x) | |
;; Navigation | |
("j" next-line) | |
("J" forward-paragraph) | |
("k" previous-line) | |
("K" backward-paragraph) | |
("h" backward-char) | |
("H" backward-sentence) | |
("l" forward-char) | |
("L" forward-sentence) | |
("a" crux-move-beginning-of-line) | |
("e" end-of-line) | |
("g g" beginning-of-buffer) | |
("g l" avy-goto-line) | |
("g m" pop-to-mark-command) | |
("g G" end-of-buffer) | |
("f" avy-goto-word-1) | |
("w" forward-to-word) | |
("b" backward-word) | |
;; Programming and commenting | |
("i" hs-toggle-hiding) | |
("I" hs-hide-all) | |
("ö ö" evilnc-comment-or-uncomment-lines) | |
("ö p" evilnc-comment-or-uncomment-paragraphs) | |
("ö e" comment-dwim :exit t) | |
("s" dumb-jump-go) | |
;; Editing/marking | |
("r" replace-char-at-point) | |
("R" query-replace) | |
("M" hydra-mc/body) | |
("." er/expand-region) | |
("u" undo-tree-undo) | |
("U" undo-tree-redo) | |
("x" delete-char) | |
("o" crux-smart-open-line :exit t) | |
("O" crux-smart-open-line-above :exit t) | |
("p" yank) | |
("P" yank-rectangle) | |
("N" narrow-or-widen-dwim) | |
;; Change/replace (c keyword) | |
("c c" change-current-line :exit t) | |
("c w" kill-word :exit t) | |
;; ("c l" avy-kill-whole-line :exit t) | |
("c b" backward-kill-word :exit t) | |
("c r" avy-kill-region :exit t) | |
("c a" crux-move-beginning-of-line :exit t) | |
("c e" end-of-line :exit t) | |
("c f" avy-goto-word-1 :name "avy-kill-word-1" :exit t :then '(kill-word)) | |
("c o" avy-goto-line :then '(open-line) :exit t) | |
;; Killing (d verb) | |
("d d" crux-kill-whole-line) | |
("d w" kill-word) | |
("d l" avy-kill-whole-line) | |
("d b" backward-kill-word) | |
("d r" avy-kill-region) | |
("d J" kill-paragraph) | |
("d K" backward-kill-paragraph) | |
("d H" backward-kill-sentence) | |
("d L" kill-sentence) | |
;; Copying (y verb) | |
("y y" copy-line) | |
("y l" avy-kill-ring-save-whole-line) | |
("y w" kill-word :name "save-word" :then '(yank)) | |
;; Variant/clone/duplicate (v verb) | |
("v v" crux-duplicate-current-line-or-region) | |
("v ö" crux-duplicate-and-comment-current-line-or-region) | |
("v l" avy-copy-line) | |
("v r" avy-copy-region) | |
;; Move (m verb) | |
("m m" move-current-line) | |
("m r" avy-move-region) | |
("m l" avy-move-line) | |
;; Space map | |
("SPC" | |
(("SPC" helm-M-x) | |
("g" :hydra | |
'(hydra-git () | |
"A hydra for git!" | |
("g" magit-status "magit" :color blue) | |
("j" git-gutter:next-hunk "next") | |
("k" git-gutter:previous-hunk "previous") | |
("d" git-gutter:popup-hunk "diff") | |
("s" git-gutter:stage-hunk "stage") | |
("r" git-gutter:revert-hunk "revert") | |
("m" git-gutter:mark-hunk "mark") | |
("q" nil "cancel" :color blue))) | |
("1" zygospore-toggle-delete-other-windows) | |
("2" split-window-below) | |
("3" split-window-right) | |
("0" delete-window) | |
)) | |
;; Lisp | |
("o" lispy-open-line :then '(newline) :exit t :mode 'emacs-lisp-mode :name "open-line") | |
;; Org-mode | |
("a" worf-beginning-of-line :mode 'org-mode) | |
("i" org-cycle :mode 'org-mode) | |
("I" worf-shifttab :mode 'org-mode) | |
)) | |
;;* selected.el | |
(use-package google-this :ensure t | |
:commands (translate-query-or-region | |
google-this-noconfirm) | |
:config | |
(use-package google-translate :ensure t)) | |
(use-package randomize-region) | |
(use-package selected :load-path "mylisp/selected" | |
:commands (selected-mode selected-minor-mode) | |
:config | |
(use-package move-text :ensure t) | |
(defvar surf-engines | |
'(("sitepoint" . "http://reference.sitepoint.com/?s=%s") | |
("google" . "http://www.google.com/search?q=%s") | |
("youtube" . "http://www.youtube.com/results?search_type=&search_query=%s&aq=f") | |
("twitter" . "http://search.twitter.com/search?q=%s") | |
("emacswiki" . "http://www.google.com/cse?cx=004774160799092323420%%3A6-ff2s0o6yi&q=%s&sa=Search") | |
("amazon" . "http://www.amazon.com/s/url=search-alias%%3Daps&field-keywords=%s") | |
("wikipedia" . "http://www.wikipedia.org/search-redirect.php?search=%s&language=en") | |
("stackoveflow" . "http://stackoverflow.com/search?q=%s") | |
("duck" . "https://duckduckgo.com/?q=%s"))) | |
(defun surf-region () | |
(interactive) | |
(let ((search (buffer-substring-no-properties (mark) (point)))) | |
(browse-url (format | |
(cdr (assoc (completing-read "Web engine: " surf-engines) | |
surf-engines)) | |
(url-hexify-string search))))) | |
(defun delete-region-then-insert-mode (beg end) | |
(interactive "r") | |
(delete-region beg end) | |
(ryo-modal-mode -1)) | |
(defhydra hydra-move-region () | |
("j" move-text-down) | |
("k" move-text-up) | |
("h" indent-rigidly-left) | |
("l" indent-rigidly-right)) | |
(defun region-or-rectangle-copy (beg end) | |
(interactive "r") | |
(if rectangle-mark-mode | |
(copy-rectangle-as-kill beg end) | |
(copy-region-as-kill))) | |
(defun region-or-rectangle-kill (beg end) | |
(interactive "r") | |
(if rectangle-mark-mode | |
(kill-rectangle beg end) | |
(kill-rectangle))) | |
:bind (("C-c r" . selected-minor-mode) | |
:map selected-keymap | |
("q" . selected-off) | |
("!" . shell-command-on-region) | |
("RET" . keyboard-quit) | |
("," . exchange-point-and-mark) | |
("c" . delete-region-then-insert-mode) | |
("F" . surf-region) | |
("ö" . evilnc-comment-or-uncomment-lines) | |
("d" . region-or-rectangle-kill) | |
("y" . region-or-rectangle-copy) | |
("m" . hydra-move-region/body) | |
;; randomize-region | |
("R" . randomize-region) | |
;; org-mode (e for export) | |
("E h" . org-html-convert-region-to-html) | |
("E l" . org-latex-convert-region-to-latex) | |
("E m" . org-md-convert-region-to-md) | |
;; google-this | |
("T" . translate-query-or-region) | |
;; move-text | |
;; ("J" . move-text-down) | |
;; ("K" . move-text-up) | |
;; ("u" . upcase-region) | |
;; ("d" . downcase-region) | |
;; ("c" . capitalize-region) | |
;; ("w" . count-words-region) | |
;; ("s" . sort-lines) | |
;; ("i" . indent-rigidly) | |
;; ("N" . narrow-to-region) | |
;; ("v" . selected-indent-right) | |
)) |
The call to quoted-insert, sees a numbers as octal.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I like this command from your config very much
but on my mashine it only works for letters and not for numbers, can you tell me why?
Thanks!
Thorsten