Advertisement
Guest User

11f Move by Line or Paragraphs

a guest
Mar 16th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 2.22 KB | None | 0 0
  1. (defun 11f-end-line-or-para (&optional arg)
  2.   "Move cursor end of current line, or end of current paragraph,
  3. respecting `paragraph-start' and `paragraph-separate' by use of
  4. `forward-paragraph'.
  5.  
  6. When pressed repeatedly, moves down the 'outside' of paragraphs.
  7.  
  8. This is slightly different to `xah-fly-keys's
  9. `xah-end-of-line-or-block', but such behaviour can be simulated by
  10. giving the optional argument, or using the prefix-command.
  11.  
  12. Improvements over xah-fly-keys:
  13. - More common to add text to end of paragraph rather than start when moving forwards.
  14. - Allows less-common paragraphing styles, such as with *roff commands in `nroff-mode'.
  15. - Skips whitespace at end of lines (may be unnecessary).
  16. "
  17.   (interactive)
  18.   (if (or (equal (point) (line-end-position))
  19.           (eq last-command this-command))
  20.       (if (or current-prefix-arg arg)
  21.       (progn
  22.         (forward-paragraph)
  23.         (skip-chars-forward "\t\n "))
  24.     (progn
  25.       (forward-line)
  26.       (forward-paragraph)
  27.       (skip-chars-backward "\t\n ")))
  28.     (end-of-line)
  29.     (skip-chars-backward "\t ")))
  30.  
  31. (defun 11f-start-line-or-para (&optional arg)
  32.   "Move cursor beginning of current line, or end of current paragraph,
  33. respecting `paragraph-start' and `paragraph-separate' by use of
  34. `forward-paragraph'.
  35.  
  36. When pressed repeatedly, moves up the 'inside' of the paragraphs.
  37.  
  38. This is slightly different to `xah-fly-keys's
  39. `xah-beginning-of-line-or-block', but such behaviour can be simulated
  40. by giving the optional argument, or using the prefix-command.
  41.  
  42. Improvements over xah-fly-keys:
  43. - Allows less-common paragraphing styles, such as with *roff commands in `nroff-mode'.
  44. - Skips whitespace and indentation.
  45. - Allows easier access to first line of paragraph.
  46. "
  47.   (interactive)
  48.   (if (or (equal (point) (line-beginning-position))
  49.           (eq last-command this-command))
  50.       (if (or current-prefix-arg arg)
  51.       (progn
  52.         (backward-paragraph)
  53.         (skip-chars-backward "\t\n "))
  54.     (progn
  55.       (forward-line -1)
  56.       (backward-paragraph)
  57.       (skip-chars-forward "\t\n ")))
  58.     ;; (beginning-of-line)
  59.     ;; (skip-chars-forward "\t "))
  60.     (beginning-of-line-text)))
  61.  
  62. (global-set-key (quote [f5]) '11f-start-line-or-para)
  63. (global-set-key (quote [f6]) '11f-end-line-or-para)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement