]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
added Xah Lee's xah-beginning-of-line-or-block
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 15 Mar 2017 10:34:02 +0000 (11:34 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Wed, 15 Mar 2017 10:34:02 +0000 (11:34 +0100)
Thanks!

Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
bba.org

diff --git a/bba.org b/bba.org
index 21203a9acce07dfe0bbb4f36c2d88093cc090155..1fd3c9d2551e75ca0b7b0d01e9e5596f0fcce5eb 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -2676,6 +2676,49 @@ safe files with #! in first line as user executable.
 
 #+END_SRC
 
+* Move Cursor to Beginning of Line/Paragraph
+[2017-03-02 Thu 13:46]
+
+Thanks to [[http://ergoemacs.org/emacs/emacs_keybinding_design_beginning-of-line-or-block.html][Xah Lee]]:
+
+#+BEGIN_SRC emacs-lisp :tangle yes
+  (defun xah-beginning-of-line-or-block ()
+    "Move cursor to beginning of line, or beginning of current or previous text block.
+
+  • When called first time, move cursor to beginning of line.
+  • When called again, move cursor to beginning of paragraph.
+  • When called again, move cursor to beginning of previous paragraph.
+
+  URL `http://ergoemacs.org/emacs/emacs_keybinding_design_beginning-of-line-or-block.html'
+  Version 2017-01-17"
+    (interactive)
+    (if (or (equal (point) (line-beginning-position))
+            (equal last-command this-command ))
+       (if (re-search-backward "\n[\t\n ]*\n+" nil "NOERROR")
+            (skip-chars-backward "\n\t ")
+          (goto-char (point-min)))
+      (beginning-of-line)))
+
+
+  (defun xah-end-of-line-or-block ()
+    "Move cursor to end of line, or end of current or next text block.
+
+  • When called first time, move cursor to end of line.
+  • When called again, move cursor to end of paragraph.
+  • When called again, move cursor to end of next paragraph.
+
+  URL `http://ergoemacs.org/emacs/emacs_keybinding_design_beginning-of-line-or-block.html'
+  Version 2017-01-17"
+    (interactive)
+    (if (or (equal (point) (line-end-position))
+            (equal last-command this-command ))
+       (re-search-forward "\n[\t\n ]*\n+" nil "NOERROR" )
+      (end-of-line)))
+
+  (global-set-key (kbd "s-a") 'xah-beginning-of-line-or-block)
+  (global-set-key (kbd "s-e") 'xah-end-of-line-or-block)
+#+END_SRC
+
 * move lines
     [2014-11-11 Tue 12:24]