diff options
author | Tom Willemse | 2020-04-07 02:09:43 -0700 |
---|---|---|
committer | Tom Willemse | 2020-04-07 02:09:43 -0700 |
commit | a709f502f88821bdef956cebfb304010f46503c0 (patch) | |
tree | c55ec5fc2af75cc5408887d5ca32ad1fdfc4fc4d /oni-core.el | |
parent | 378ef3d590a5227d238281f78b2521ad3dfb915a (diff) | |
download | emacs-config-a709f502f88821bdef956cebfb304010f46503c0.tar.gz emacs-config-a709f502f88821bdef956cebfb304010f46503c0.zip |
Add navigation functions for end-of-line and beginning-of-line
Diffstat (limited to 'oni-core.el')
-rw-r--r-- | oni-core.el | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/oni-core.el b/oni-core.el index 7ff16bc..dbea8c3 100644 --- a/oni-core.el +++ b/oni-core.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse <tom@ryuslash.org> ;; Keywords: local -;; Version: 2020.0225.095408 +;; Version: 2020.0407.015402 ;; Package-Requires: (oni-data-dir expand-region multiple-cursors embrace helpful) ;; This program is free software; you can redistribute it and/or modify @@ -53,6 +53,31 @@ "Create the autosave directory if doesn't exist." (mkdir oni-core--auto-save-directory t)) +(defun oni-core-move-beginning-of-dwim () + "Move to beginning of line either after indentation or before." + (interactive) + (let ((start (point))) + (back-to-indentation) + (unless (/= start (point)) + (move-beginning-of-line 1)))) + +(defun oni-core-move-end-of-dwim () + "Move to end of line, either before any comments or after." + (interactive) + (let ((start (point)) + (eolpos (line-end-position))) + (beginning-of-line) + (if (and comment-start + (not (looking-at (regexp-quote comment-start))) + (comment-search-forward eolpos t)) + (progn + (search-backward-regexp (concat "[^ \t" comment-start "]")) + (forward-char) + (when (or (bolp) + (= start (point))) + (end-of-line))) + (end-of-line)))) + (add-to-list 'auto-save-file-name-transforms `(".*" ,oni-core--auto-save-directory t) :append) @@ -108,6 +133,8 @@ (global-set-key (kbd "C-c (") 'embrace-commander) (global-set-key (kbd "C-x M-f") 'ffap) (global-set-key (kbd "C-x C-b") 'ibuffer-jump) +(global-set-key [remap move-beginning-of-line] #'oni-core-move-beginning-of-dwim) +(global-set-key [remap move-end-of-line] #'oni-core-move-end-of-dwim) (global-set-key [remap describe-function] 'helpful-callable) (global-set-key [remap describe-key] 'helpful-key) |