# HG changeset patch # User Oleksandr Gavenko # Date 1442258572 -10800 # Node ID 9cef82dd4c45f63cc03663fba08f52b8aa025bbf # Parent a3ec0437c4f1f9b820b47a55504ff9215d4ab3dd my--smart-end-of-line like my--smart-beginning-of-line. diff -r a3ec0437c4f1 -r 9cef82dd4c45 .emacs-my --- a/.emacs-my Mon Aug 10 22:47:53 2015 +0300 +++ b/.emacs-my Mon Sep 14 22:22:52 2015 +0300 @@ -819,17 +819,26 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "key binding, short-keys") -(defun my-smart-beginning-of-line () - "Move point to beginning-of-line. If repeat command it cycle +(defun my--smart-beginning-of-line () + "Move point to `beginning-of-line'. If repeat command it cycle position between `back-to-indentation' and `beginning-of-line'." (interactive "^") - (if (and (eq last-command 'my-smart-beginning-of-line) + (if (and (eq last-command 'my--smart-beginning-of-line) (= (line-beginning-position) (point))) (back-to-indentation) (beginning-of-line))) -(global-set-key [home] 'my-smart-beginning-of-line) -(global-set-key [end] 'end-of-line) +(defun my--smart-end-of-line () + "Move point to `end-of-line'. If repeat command it cycle +position between last non-whitespace and `end-of-line'." + (interactive "^") + (if (and (eq last-command 'my--smart-end-of-line) + (= (line-end-position) (point))) + (skip-syntax-backward " " (line-beginning-position)) + (end-of-line))) + +(global-set-key [home] 'my--smart-beginning-of-line) +(global-set-key [end] 'my--smart-end-of-line) (global-set-key [C-home] 'beginning-of-buffer) (global-set-key [C-end] 'end-of-buffer) (global-set-key [C-delete] 'kill-word)