* patch for make-mode.el
@ 2002-09-16 0:39 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2002-09-16 0:39 UTC (permalink / 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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-09-16 0:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-16 0:39 patch for make-mode.el Tom Tromey
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).