unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tom Tromey <tromey@redhat.com>
Subject: patch for make-mode.el
Date: 15 Sep 2002 18:39:20 -0600	[thread overview]
Message-ID: <87ptve6a4n.fsf@fleche.redhat.com> (raw)

Currently, make-mode will fill adjacent code when M-q is used in a
comment.  The appended patch fixes this by finding the boundaries of
the comment before filling.

Similar code already exists in tcl.el and lisp-mode.el, and recently I
added code like this to the (as yet unintegrated) python.el; it seems
like perhaps this should be a general feature of newcomment.el...?

This patch is against the cvs head.  I tested it in Emacs 21.2, but I
think it doesn't contain anything really version-dependent.

Tom

2002-09-15  Tom Tromey  <tromey@redhat.com>

	* progmodes/make-mode.el (makefile-fill-paragraph): Find comment
	boundaries before filling.

Index: lisp/progmodes/make-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/make-mode.el,v
retrieving revision 1.71
diff -u -r1.71 make-mode.el
--- lisp/progmodes/make-mode.el	28 Nov 2001 20:41:49 -0000	1.71
+++ lisp/progmodes/make-mode.el	16 Sep 2002 00:37:36 -0000
@@ -1,6 +1,6 @@
 ;;; make-mode.el --- makefile editing commands for Emacs
 
-;; Copyright (C) 1992,94,99,2000,2001  Free Software Foundation, Inc.
+;; Copyright (C) 1992,94,99,2000,2001, 2002  Free Software Foundation, Inc.
 
 ;; Author: Thomas Neumann <tom@smart.bo.open.de>
 ;;	Eric S. Raymond <esr@snark.thyrsus.com>
@@ -1011,12 +1011,30 @@
     (beginning-of-line)
     (cond
      ((looking-at "^#+ ")
-      ;; Found a comment.  Set the fill prefix and then fill.
+      ;; Found a comment.  Set the fill prefix, and find the paragraph
+      ;; boundaries by searching for lines that look like comment-only
+      ;; lines.
       (let ((fill-prefix (buffer-substring-no-properties (match-beginning 0)
 							 (match-end 0)))
 	    (fill-paragraph-function nil))
-	(fill-paragraph nil)
-	t))
+	(save-excursion
+	  (save-restriction
+	    (narrow-to-region
+	     ;; Search backwards.
+	     (save-excursion
+	       (while (and (zerop (forward-line -1))
+			   (looking-at "^#")))
+	       ;; We may have gone too far.  Go forward again.
+	       (or (looking-at "^#")
+		   (forward-line 1))
+	       (point))
+	     ;; Search forwards.
+	     (save-excursion
+	       (while (looking-at "^#")
+		 (forward-line))
+	       (point)))
+	    (fill-paragraph nil)
+	    t))))
 
      ;; Must look for backslashed-region before looking for variable
      ;; assignment.

                 reply	other threads:[~2002-09-16  0:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ptve6a4n.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).