[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gforth] [bug #55867] Bug in forth-fill-paragraph, and fix
From: |
Reuben Thomas |
Subject: |
[Bug-gforth] [bug #55867] Bug in forth-fill-paragraph, and fix |
Date: |
Fri, 8 Mar 2019 12:21:11 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0 |
URL:
<https://savannah.gnu.org/bugs/?55867>
Summary: Bug in forth-fill-paragraph, and fix
Project: Gforth
Submitted by: rrt
Submitted on: Fri 08 Mar 2019 05:21:09 PM UTC
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
This bug report supersedes #54866.
The bug is that forth-fill-paragraph globally sets fill-prefix.
While investigating this bug, I discovered that an assertion (that it's not
possible to use `fill-paragraph`) is (no longer?) true, which led to a much
simpler definition:
(defun forth-fill-paragraph ()
"Fill comments starting with '\\' which start a line; do not fill code."
;; Something like lisp-fill-paragraph may be better.
(interactive)
(save-excursion
(beginning-of-line)
(if (looking-at "[ \t]*\\\\g?[ \t]+")
(fill-paragraph))))
This also fixes another problem: it does not reformat a comment that ends on
the line above point. However, this is presumably not backwards compatible to
very old Emacsen.
A fix that is more backwards-compatible (but only fixes the first problem)
goes like this:
(defun forth-fill-paragraph ()
"Fill comments starting with '\\' which start a line; do not fill code."
;; Something like lisp-fill-paragraph may be better.
(interactive)
(save-excursion
(beginning-of-line)
(while (and (= (forward-line -1) 0)
(looking-at "[ \t]*\\\\g?[ \t]+")))
(if (not (looking-at "[ \t]*\\\\g?[ \t]+"))
(forward-line 1))
(let ((from (point))
(to (save-excursion (forward-paragraph) (point))))
(if (looking-at "[ \t]*\\\\g?[ \t]+")
(progn (goto-char (match-end 0))
(let ((fill-prefix-save fill-prefix))
(set-fill-prefix)
(fill-region from to nil)
(setq fill-prefix fill-prefix-save)))))))
(This is an example of why I would like to maintain a version of gforth.el
that is compatible with only current Emacsen; see #54559!)
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55867>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Bug-gforth] [bug #55867] Bug in forth-fill-paragraph, and fix,
Reuben Thomas <=