my--smart-end-of-line like my--smart-beginning-of-line.
--- 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)