bugGforth - Bugs: bug #55867, Bug in forth-fill-paragraph, and...

 
 

bug #55867: Bug in forth-fill-paragraph, and fix

Submitter:  Reuben Thomas <rrt>
Submitted:  Fri 08 Mar 2019 05:21:09 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  anton
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 08 Mar 2019 06:02:59 PM UTC, comment #1: 

Thanks.  I applied the second fix.  The shorter fix does not work on the Emacs 21.4 on one of our machines.

Anton Ertl <anton>
Group administrator
Fri 08 Mar 2019 05:21:09 PM UTC, original submission:  

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!)

Reuben Thomas <rrt>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by anton (Posted a comment)
  • -email is unavailable- added by rrt (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-08 anton StatusNone Fixed
        Assigned toNone anton
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code