emacs-devel
[Top][All Lists]
Advanced

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

c-mask-paragraph


From: martin rudalics
Subject: c-mask-paragraph
Date: Wed, 28 Nov 2007 14:02:23 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Good afternoon, Alan

In a recent attempt to violate the virginity of a comment I was told

Debugger entered--Lisp error: (error "Invalid search bound (wrong side of 
point)")
  search-forward-regexp("\\=[      ]*\\(//+\\|\\**\\)" 19384 t)
  c-mask-paragraph(nil t do-auto-fill)
  c-do-auto-fill()
  self-insert-command(1)
  newline(nil)
  #[nil "..." [soft allow-auto-fill delete-horizontal-space insert-and-inherit 
10 newline 1] 2]()
  c-indent-new-comment-line(nil t)
  c-context-line-break()
  (let ((go-back ...)) (when (and ... ...) (delete-overlay 
show-paren-overlay-1)) (c-context-line-break) (when go-back (forward-line -1) 
(indent-according-to-mode)))
  c-newline-and-indent-maybe()
  call-interactively(c-newline-and-indent-maybe)

Lack of vigour won't permit me to reproduce this soon, hence there's no
need telling me to "don't do that".

Now I surely appreciate Emacs' efforts to protect the innocence of that
poor thing.  However, I'd prefer C mode to not leave it to the debugger
to tell me the truth about my evil doing.  Rather, I propose to rewrite
the corresponding conjunct in `c-mask-paragraph' as

                    (and (> (- (cdr c-lit-limits) 2) (point))
                         (re-search-forward
                          (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
                          (- (cdr c-lit-limits) 2) t)
                         (not (re-search-forward
                               "\\(\\s \\|\\sw\\)"
                               (- (cdr c-lit-limits) 2) 'limit))
                             ;; The comment ender IS on its own line.  Exclude
                             ;; this line from the filling.
                         (set-marker end (c-point 'bol))))

but maybe the test should _not_ fail in that case and it would be more
appropriate to use (max (- (cdr c-lit-limits) 2) (point)) as second
argument.

I'll leave it to you to work out the gory details.  Thanks in advance.

martin







reply via email to

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