Potential Improvements to xah-*-of-line-or-block.
Hullo,
I write most of my documents in Groff (using nroff-mode), which only rarely contains blank lines. As such, xah-beginning-of-line-or-block and xah-end-of-line-or-block don't work, as they use static regexes for the matching blank lines.
Instead, I'm now using wrapper functions around Emacs' builtin forward-paragraph and backward-paragraph, which handles local paragraphing styles correctly. I'm not sure how efficient this is, but I don't see any delay compared to xah-fly-keys' block commands.
I also prefer to move 'up the inside' and 'down the outside' of blocks, i.e. moving clockwise around paragraphs, though this is only personal preference. You can revert to the xah-fly-keys anticlockwise method by setting the optional argument, or once by setting the prefix.
The code is posted here: https://pastebin.com/TLJTcYeZ and also just below, please let me know what you think.
(defun 11f-end-line-or-para (&optional arg)
"Move cursor end of current line, or end of current paragraph,
respecting `paragraph-start' and `paragraph-separate' by use of
`forward-paragraph'.
When pressed repeatedly, moves down the 'outside' of paragraphs.
This is slightly different to `xah-fly-keys's
`xah-end-of-line-or-block', but such behaviour can be simulated by
giving the optional argument, or using the prefix-command.
Improvements over xah-fly-keys:
- More common to add text to end of paragraph rather than start when moving forwards.
- Allows less-common paragraphing styles, such as with *roff commands in `nroff-mode'.
- Skips whitespace at end of lines (may be unnecessary).
"
(interactive)
(if (or (equal (point) (line-end-position))
(eq last-command this-command))
(if (or current-prefix-arg arg)
(progn
(forward-paragraph)
(skip-chars-forward "\t\n "))
(progn
(forward-line)
(forward-paragraph)
(skip-chars-backward "\t\n ")))
(end-of-line)
(skip-chars-backward "\t ")))
(defun 11f-start-line-or-para (&optional arg)
"Move cursor beginning of current line, or end of current paragraph,
respecting `paragraph-start' and `paragraph-separate' by use of
`forward-paragraph'.
When pressed repeatedly, moves up the 'inside' of the paragraphs.
This is slightly different to `xah-fly-keys's
`xah-beginning-of-line-or-block', but such behaviour can be simulated
by giving the optional argument, or using the prefix-command.
Improvements over xah-fly-keys:
- Allows less-common paragraphing styles, such as with *roff commands in `nroff-mode'.
- Skips whitespace and indentation.
- Allows easier access to first line of paragraph.
"
(interactive)
(if (or (equal (point) (line-beginning-position))
(eq last-command this-command))
(if (or current-prefix-arg arg)
(progn
(backward-paragraph)
(skip-chars-backward "\t\n "))
(progn
(forward-line -1)
(backward-paragraph)
(skip-chars-forward "\t\n ")))
;; (beginning-of-line)
;; (skip-chars-forward "\t "))
(beginning-of-line-text)))
Posted Mar 16, 2019, 6:18 PM UTC