emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple bugs in lisp-mode M-q on paragraphs within #|..|# comments


From: Bob Rogers
Subject: Re: Multiple bugs in lisp-mode M-q on paragraphs within #|..|# comments
Date: Sat, 24 Mar 2007 20:23:48 -0400

   From: martin rudalics <address@hidden>
   Date: Sat, 24 Mar 2007 23:07:28 +0100

   I suppose `comment-end' is "" in you buffer.

That seems to be the case, at least initially.

   Then the problem is with the following stretch of code in
   `fill-paragraph':

          (and fill-paragraph-handle-comment
              ;; Our code only handles \n-terminated comments right now.
              comment-start (equal comment-end "")
              (let ((fill-paragraph-handle-comment nil))
                (fill-comment-paragraph arg)))

   We have to find something more intelligent here.

Is this really the place?  If I add a call to error just before the
fill-comment-paragraph call, none of the four bugs cause it to be
called.

   It might be better to recognize Lisp "#|...|#" comments explicitly at
a point where we know we're dealing with Lisp.  The attached patch is a
total hack, but it seems to relieve the symptoms of the first three bugs
(and changes that of the fourth).  This style of comment can be nested,
so the hack will get confused if still inside a comment but after an
inner comment.  The changed symptoms of the fourth bug suggest that the
bounds passed to the fill-region-as-paragraph call are wrong.  But I'll
bet someone else can do better.

                                        -- Bob

Index: lisp/emacs-lisp/lisp-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v
retrieving revision 1.200
diff -c -r1.200 lisp-mode.el
*** lisp/emacs-lisp/lisp-mode.el        5 Mar 2007 03:20:58 -0000       1.200
--- lisp/emacs-lisp/lisp-mode.el        25 Mar 2007 00:13:20 -0000
***************
*** 1246,1252 ****
  paragraph of it that point is in, preserving the comment's indentation
  and initial semicolons."
    (interactive "P")
!   (or (fill-comment-paragraph justify)
        ;; Since fill-comment-paragraph returned nil, that means we're not in
        ;; a comment: Point is on a program line; we are interested
        ;; particularly in docstring lines.
--- 1246,1266 ----
  paragraph of it that point is in, preserving the comment's indentation
  and initial semicolons."
    (interactive "P")
!   (or (if (save-excursion
!           (and (re-search-backward "#|\\||#" nil t)
!                (equal (match-string 0) "#|")))
!         ;; We are in a "#|...|#" comment.  [Assuming we haven't been
!         ;; fooled by quoted strings or ;-comments.]
!         (let ((start (save-excursion
!                        (forward-paragraph -1)
!                        (point)))
!               (end (save-excursion
!                      (forward-paragraph 1)
!                      (point))))
!           (message "trying it")
!           (fill-region-as-paragraph start end justify))
!         ;; Try "normal" comment paragraph fill.
!         (fill-comment-paragraph justify))
        ;; Since fill-comment-paragraph returned nil, that means we're not in
        ;; a comment: Point is on a program line; we are interested
        ;; particularly in docstring lines.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]