[Bug: 21.4.13] CPerl Bug

sti at cam.org sti at cam.org
Fri Feb 13 00:37:25 EST 2004


================================================================
Dear Bug Team!

I have just come across a bug in cperl-mode, (from the version in the
perl-modes package V1.05) related to its handling of paragraphs in large
block comments. Given the following set of comments:

# set, for documentation purposes:
#
# Types and Syntax
# ----------------
# The base syntax for CSX is similar to that of lisp, with angle brackets
# taking the place of parenthesis. One wrinkle is that the outermost set of
# angle brackets are of a different form, so that a fast scan of the CSX source can pick out pairs of matching brackets and process them as a single
# unit. (So be sure they ONLY appear at the beginnings and ends of CSX
# expressions.) Syntactically, they are treated just as if they were normal
# angle brackets.
#

When in cperl-mode, placing the point anywhere after the line of hyphens
and executing fill-paragraph-or-region twice in a row causes a number of
the leading hatches to be deleted. This is reproduceable even on an Xemacs
started with the -q flag.

I am somewhat new to elisp, so I am unsure of the general validity of my
fix, but I discovered that if I modify cperl-fill-paragraph by commenting
out a few lines (marked with ';sti;' tokens below), then the function behaves as
expected. I can only imagine that the commented-out code was a workaround
for a bug in some other version of Emacs. Here's the modified function:

;; Stolen from lisp-mode with a lot of improvements
;; 5Dec2001: modified to always return t
(defun cperl-fill-paragraph (&optional justify iteration)
  "Like \\[fill-paragraph], but handle CPerl comments.
If any of the current line is a comment, fill the comment or the
block of it that point is in, preserving the comment's initial
indentation and initial hashes.  Behaves usually outside of comment."
  (interactive "P")
  (let (
	;; Non-nil if the current line contains a comment.
	has-comment

	;; If has-comment, the appropriate fill-prefix for the comment.
	comment-fill-prefix
	;; Line that contains code and comment (or nil)
	start
	c spaces len dc (comment-column comment-column))
    ;; Figure out what kind of comment we are looking at.
    (save-excursion
      (beginning-of-line)
      (cond

       ;; A line with nothing but a comment on it?
       ((looking-at "[ \t]*#[# \t]*")
	(setq has-comment t
	      comment-fill-prefix (buffer-substring (match-beginning 0)
						    (match-end 0))))

       ;; A line with some code, followed by a comment?  Remember that the
       ;; semi which starts the comment shouldn't be part of a string or
       ;; character.
       ((cperl-to-comment-or-eol)
	(setq has-comment t)
	(looking-at "#+[ \t]*")
	(setq start (point) c (current-column)
	      comment-fill-prefix
	      (concat (make-string (current-column) ?\ )
		      (buffer-substring (match-beginning 0) (match-end 0)))
	      spaces (progn (skip-chars-backward " \t")
			    (buffer-substring (point) start))
	      dc (- c (current-column)) len (- start (point))
	      start (point-marker))
	(delete-char len)
	(insert (make-string dc ?-)))))
    (if (not has-comment)
	(fill-paragraph justify)	; Do the usual thing outside of comment
      ;; Narrow to include only the comment, and then fill the region.
      (save-restriction
	(narrow-to-region
	 ;; Find the first line we should include in the region to fill.
	 (if start (progn (beginning-of-line) (point))
	   (save-excursion
	     (while (and (zerop (forward-line -1))
			 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
	     ;; We may have gone to far.  Go forward again.
	     (or (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")
		 (forward-line 1))
	     (point)))
	 ;; Find the beginning of the first line past the region to fill.
	 (save-excursion
	   (while (progn (forward-line 1)
			 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
	   (point)))
	;; Remove existing hashes
;sti;	(goto-char (point-min))
;sti;	(while (progn (forward-line 1) (< (point) (point-max)))
;sti;	  (skip-chars-forward " \t")
;sti;	  (and (looking-at "#+")
;sti;	       (delete-char (- (match-end 0) (match-beginning 0)))))

	;; Lines with only hashes on them can be paragraph boundaries.
	(let ((paragraph-start (concat paragraph-start "\\|^[ \t#]*$"))
	      (paragraph-separate (concat paragraph-start "\\|^[ \t#]*$"))
	      (fill-prefix comment-fill-prefix))
	  (fill-paragraph justify)))
      (if (and start)
	  (progn
	    (goto-char start)
	    (if (> dc 0)
	      (progn (delete-char dc) (insert spaces)))
	    (if (or (= (current-column) c) iteration) nil
	      (setq comment-column c)
	      (indent-for-comment)
	      ;; Repeat once more, flagging as iteration
	      (cperl-fill-paragraph justify t))))))
  t)

Oh, and I would just like to add a big thank-you for finally producing a
version of Emacs that runs as well on Windows as this one does. I find I
can now use literally dozens of packages that never worked under any other
DOS port before (including the bug-report mailer :-) )

================================================================

System Info to help track down your bug:
---------------------------------------

OS version:

Microsoft Windows 2000 [Version 5.00.2195]
OS: Windows_NT

XEmacs 21.4.13 "Rational FORTRAN" configured for `i586-pc-win32'.

  Building XEmacs in "d:\\xemacs\\xemacs-21.4-release\\nt".
  Using compiler "cl -nologo -W3 -O2 -G5 -ML".
  Installing XEmacs in "c:\\Program Files\\XEmacs\\XEmacs-21.4.13".
  Package path is "~\\.xemacs;;c:\\Program Files\\XEmacs\\site-packages;c:\\Program Files\\XEmacs\\xemacs-packages".
  Compiling in support for Microsoft Windows native GUI.
  Compiling in support for XPM images.
  Compiling in support for GIF images.
  Compiling in support for PNG images.
  Compiling in support for TIFF images.
  Compiling in support for JPEG images.
  Compiling in support for X-Face message headers.
  Compiling in support for toolbars.
  Compiling in support for dialogs.
  Compiling in support for widgets.
  Compiling in support for native sounds.
  Compiling in fast dired implementation.
  Using portable dumper.


Load-Path Lisp Shadows:
----------------------
(C:\Program Files\XEmacs\XEmacs-21.4.13\site-lisp\wrap\word-wrapping
c:\Program Files\XEmacs\XEmacs-21.4.13\site-lisp\wrap\word-wrapping C:\Program
Files\XEmacs\XEmacs-21.4.13\site-lisp\wrap\longlines c:\Program
Files\XEmacs\XEmacs-21.4.13\site-lisp\wrap\longlines c:\Program
Files\XEmacs\xemacs-packages\lisp\build\build-report c:\Program
Files\XEmacs\XEmacs-21.4.13\lisp\build-report)


Installed XEmacs Packages:
-------------------------
(zenirc ver: 1.15 upstream: 2.112)
(xslt-process ver: 1.11 upstream: regular)
(xslide ver: 1.09 upstream: 0.2.2)
(xemacs-devel ver: 1.61 upstream: No-Upstream-Ver)
(xemacs-base ver: 1.84 upstream: No-Upstream-Ver)
(x-symbol ver: 1.09 upstream: 4.5.1)
(w3 ver: 1.29 upstream: 4.0pre47)
(vm ver: 7.18 upstream: 7.17)
(viper ver: 1.37 upstream: 3.09)
(view-process ver: 1.13 upstream: 2.4)
(vhdl ver: 1.18 upstream: 3.31.20)
(vc-cc ver: 1.22 upstream: No-Upstream-Ver)
(vc ver: 1.38 upstream: No-Upstream-Ver)
(tramp ver: 1.17 upstream: 2.0.35)
(tpu ver: 1.14 upstream: 4.2X)
(tooltalk ver: 1.15 upstream: No-Upstream-Ver)
(tm ver: 1.37 upstream: No-Upstream-Ver)
(time ver: 1.14 upstream: 1.17)
(textools ver: 1.15 upstream: No-Upstream-Ver)
(text-modes ver: 1.73 upstream: No-Upstream-Ver)
(texinfo ver: 1.25 upstream: No-Upstream-Ver)
(supercite ver: 1.2 upstream: 3.55x3)
(strokes ver: 1.1 upstream: No-Upstream-Ver)
(speedbar ver: 1.27 upstream: 0.14beta4)
(sounds-wav ver: 1.12 upstream: No-Upstream-Ver)
(sounds-au ver: 1.12 upstream: No-Upstream-Ver)
(sml-mode ver: 0.11 upstream: 3.9.5)
(slider ver: 1.15 upstream: 0.3x1)
(sieve ver: 1.15 upstream: No-Upstream-Ver)
(sh-script ver: 1.18 upstream: 2.0e)
(sgml ver: 1.11 upstream: No-Upstream-Ver)
(semantic ver: 1.18 upstream: 1.4.2)
(scheme ver: 1.14 upstream: No-Upstream-Ver)
(sasl ver: 1.14 upstream: 1.14.4)
(ruby-modes ver: 1.02 upstream: 1.6.8)
(rmail ver: 1.14 upstream: No-Upstream-Ver)
(riece ver: 1.14 upstream: 0.1.7)
(reftex ver: 1.33 upstream: 4.21)
(python-modes ver: 1.03 upstream: No-Upstream-Ver)
(psgml-dtds ver: 1.03 upstream: No-Upstream-Ver)
(psgml ver: 1.42 upstream: 1.3.1)
(ps-print ver: 1.09 upstream: 6.5.6)
(prog-modes ver: 1.94 upstream: No-Upstream-Ver)
(pgg ver: 1.04 upstream: 0.1)
(perl-modes ver: 1.05 upstream: No-Upstream-Ver)
(pcomplete ver: 1.03 upstream: 1.1.6)
(pcl-cvs ver: 1.65 upstream: R-2_9_9)
(pc ver: 1.26 upstream: No-Upstream-Ver)
(os-utils ver: 1.35 upstream: No-Upstream-Ver)
(oo-browser ver: 1.04 upstream: 4.08)
(ocaml ver: 0.05 upstream: 3.06)
(net-utils ver: 1.38 upstream: N/A)
(mmm-mode ver: 1.01 upstream: 0.4.7)
(misc-games ver: 1.18 upstream: No-Upstream-Ver)
(mine ver: 1.16 upstream: 1.9)
(mh-e ver: 1.28 upstream: 7.4.2)
(mew ver: 1.18 upstream: 1.94.2)
(mailcrypt ver: 2.14 upstream: 3.5.8)
(mail-lib ver: 1.64 upstream: No-Upstream-Ver)
(liece ver: 1.13 upstream: 1.4.9)
(jde ver: 1.46 upstream: regular)
(ispell ver: 1.29 upstream: 3.6)
(ilisp ver: 1.33 upstream: 5.12.0)
(igrep ver: 1.12 upstream: 2.95)
(idlwave ver: 1.31 upstream: 5.1)
(ibuffer ver: 1.09 upstream: No-Upstream-Ver)
(hyperbole ver: 1.15 upstream: 4.18)
(hm--html-menus ver: 1.23 upstream: 5.9)
(haskell-mode ver: 1.06 upstream: 1.44)
(gnus ver: 1.79 upstream: 5.10.6)
(gnats ver: 1.16 upstream: 3.101)
(general-docs ver: 1.01 upstream: No-Upstream-Ver)
(games ver: 1.15 upstream: 1.04)
(fsf-compat ver: 1.14 upstream: No-Upstream-Ver)
(frame-icon ver: 1.11 upstream: No-Upstream-Ver)
(fortran-modes ver: 1.04 upstream: No-Upstream-Ver)
(forms ver: 1.15 upstream: 2.37)
(footnote ver: 1.16 upstream: 0.18x)
(eudc ver: 1.39 upstream: 1.32)
(eterm ver: 1.15 upstream: No-Upstream-Ver)
(ess ver: 1.07 upstream: 5.1.21)
(eshell ver: 1.06 upstream: 2.4.1)
(emerge ver: 1.11 upstream: No-Upstream-Ver)
(elib ver: 1.11 upstream: 1.0)
(eieio ver: 1.05 upstream: 0.17)
(efs ver: 1.32 upstream: 1.22)
(edt ver: 1.13 upstream: No-Upstream-Ver)
(edit-utils ver: 2.11 upstream: No-Upstream-Ver)
(ediff ver: 1.49 upstream: 2.75)
(edebug ver: 1.2 upstream: No-Upstream-Ver)
(ecrypto ver: 0.17 upstream: 2.0)
(ecb ver: 1.15 upstream: 2.20)
(docbookide ver: 0.07000000000000001 upstream: 0.1)
(dired ver: 1.15 upstream: 7.11)
(dictionary ver: 1.12 upstream: regular)
(debug ver: 1.17 upstream: No-Upstream-Ver)
(crisp ver: 1.14 upstream: 1.34)
(cookie ver: 1.15 upstream: No-Upstream-Ver)
(clearcase ver: 1.08 upstream: No-Upstream-Ver)
(cc-mode ver: 1.42 upstream: 5.30.8)
(calendar ver: 1.23 upstream: No-Upstream-Ver)
(calc ver: 1.24 upstream: 2.02fX3)
(c-support ver: 1.2 upstream: No-Upstream-Ver)
(build ver: 1.14 upstream: 2.02)
(bbdb ver: 1.24 upstream: 2.34)
(auctex ver: 1.36 upstream: 11.13)
(apel ver: 1.27 upstream: 10.2)
(ada ver: 1.14 upstream: 2.27)
(Sun ver: 1.15 upstream: No-Upstream-Ver)



Features:
--------

(mail-abbrevs xemacsbug shadow sendmail rfc822 font-lock cperl-mode timer
efs-cu font disp-table paren blink-paren avoid balloon-help filladapt advice
advice-preload cus-face overlay easy-mmode pc-select pending-del
zenirc-autoloads xslt-process-autoloads xslide-autoloads
xemacs-devel-autoloads xemacs-base-autoloads x-symbol-autoloads w3-autoloads
vm-autoloads viper-autoloads view-process-autoloads vhdl-autoloads
vc-cc-autoloads vc-autoloads tramp-autoloads tpu-autoloads tooltalk-autoloads
tm-autoloads time-autoloads textools-autoloads text-modes-autoloads
texinfo-autoloads supercite-autoloads strokes-autoloads speedbar-autoloads
sounds-wav-autoloads sounds-au-autoloads sml-mode-autoloads slider-autoloads
sieve-autoloads sh-script-autoloads sgml-autoloads semantic-autoloads
scheme-autoloads sasl-autoloads ruby-modes-autoloads rmail-autoloads
riece-autoloads reftex-autoloads python-modes-autoloads psgml-dtds-autoloads
psgml-autoloads ps-print-autoloads prog-modes-autoloads pgg-autoloads
perl-modes-autoloads pcomplete-autoloads pcl-cvs-autoloads pc-autoloads
os-utils-autoloads oo-browser-autoloads ocaml-autoloads net-utils-autoloads
mmm-mode-autoloads misc-games-autoloads mine-autoloads mh-e-autoloads
mew-autoloads mailcrypt-autoloads mail-lib-autoloads liece-autoloads
jde-autoloads ispell-autoloads ilisp-autoloads igrep-autoloads
idlwave-autoloads ibuffer-autoloads hyperbole-autoloads
hm--html-menus-autoloads haskell-mode-autoloads gnus-autoloads gnats-autoloads
general-docs-autoloads games-autoloads fsf-compat-autoloads
frame-icon-autoloads fortran-modes-autoloads forms-autoloads
footnote-autoloads eudc-autoloads eterm-autoloads ess-autoloads
eshell-autoloads emerge-autoloads elib-autoloads eieio-autoloads efs-autoloads
edt-autoloads edit-utils-autoloads ediff-autoloads edebug-autoloads
ecrypto-autoloads ecb-autoloads docbookide-autoloads dired-autoloads
dictionary-autoloads debug-autoloads crisp-autoloads cookie-autoloads
clearcase-autoloads cc-mode-autoloads calendar-autoloads calc-autoloads
c-support-autoloads build-autoloads bbdb-autoloads auctex-autoloads
apel-autoloads ada-autoloads Sun-autoloads lisp-autoloads loadhist auto-show
fontl-hooks code-cmds gutter-items menubar-items x-menubar dragdrop
mode-motion mouse itimer auto-save lisp-mode easymenu iso8859-1 page buff-menu
lib-complete help-nomule cus-file derived frame text-props obsolete cus-start
custom widget cl-extra mini-cl cl cl-19 packages backquote very-early-lisp
file-coding mswindows-scrollbars mswindows toolbar native-sound scrollbar
network-streams subprocesses menu-accelerator-support menubar md5 xemacs
gutter tiff png gif jpeg xface xpm xbm lisp-float-type windows-nt dragdrop-api
dialog devices window-system base64)


Recent keystrokes:
-----------------

C-f C-o c : \ p r o g TAB x e m TAB x e m TAB - p TAB 
p e r l TAB BS BS TAB BS BS l i s p \ p e r l TAB c 
p e r l TAB RET C-next prior prior prior prior prior 
prior prior prior prior prior prior Sh-up Sh-up Sh-up 
down down prior misc-user


Recent messages (most recent first):
-----------------------------------

Loading xemacsbug...done
Loading xemacsbug...
Loading cperl-mode...done
Loading timer...done
Loading timer...
Loading cperl-mode...
Loading efs-cu...done
Loading efs-cu...
Loading font...done
Loading font...
Paren mode is paren
Loading paren...done
Loading paren...
Loading avoid...done
Loading avoid...
Loading balloon-help...done
Loading balloon-help...
Loading sounds...done
Loading sounds...
Loading sound...done






More information about the XEmacs-Beta mailing list