~rgrjr/rgr-hacks

116e02e95b7723327a499b23de276264813ea937 — Bob Rogers 4 months ago 2f5393a master
Fix rgr-fill-sentence when point is between

* rgr-hacks.el:
   + (rgr-fill-sentence):  Bug fix:  Make this smarter when the original
     point is at the start or in between sentences.  Otherwise, we wind
     up filling both adjacent sentences.
1 files changed, 25 insertions(+), 7 deletions(-)

M rgr-hacks.el
M rgr-hacks.el => rgr-hacks.el +25 -7
@@ 257,13 257,31 @@ backup file has already been made)."
  "Fill just the current sentence, as by fill-paragraph."
  (interactive)
  (save-excursion
    (let ((start (save-excursion
		   (backward-sentence)
		   ;; Include everything from bol on the first line so we don't
		   ;; go past the fill column.
		   (beginning-of-line)
		   (point)))
	  (end (save-excursion (forward-sentence) (point))))
    (let ((original (point)) start end)
      ;; Find the start.
      (save-excursion
	(backward-sentence)
	(let ((putative-start (point)))
	  ;; Move to what ought to be the end.
	  (forward-sentence)
	  (when (< (point) original)
	    ;; The original point is at the start or in between sentences, so
	    ;; fill the next sentence.  Since forward-sentence always moves
	    ;; point, we wind up filling two sentences if we don't check for
	    ;; this.  We do so treating forward-sentence as a black box because
	    ;; the default implementation is smart about such things as
	    ;; paragraph boundaries, and may even have been overridden in some
	    ;; modes by forward-sentence-function.
	    (skip-chars-forward " \t\r\n")
	    (setq putative-start (point))
	    (forward-sentence))
	  (setq end (point))
	  ;; Include everything from bol on the first line so we don't go past
	  ;; the fill column.
	  (goto-char putative-start)
	  (beginning-of-line)
	  (setq start (point))))
      ;; Fill between start & end.
      (save-restriction
	(narrow-to-region start end)
	(fill-paragraph)))))