Gnus development mailing list
 help / color / mirror / Atom feed
From: Vladimir Volovich <vvv@vvv.vsu.ru>
Subject: Re: someone broke message-newline-and-reformat
Date: 10 Nov 2000 18:16:44 +0300	[thread overview]
Message-ID: <eyem0jq2lf.fsf@video.uic.vsu.ru> (raw)
In-Reply-To: <874s1gm1al.fsf@serafina-pekkala.dme.org>


> This one works for me.  Please could you test and confirm:
> 
> *** message.el	2000/11/04 17:13:56	6.7
> --- message.el	2000/11/10 11:57:50
> ***************
> *** 1711,1724 ****
>   (defun message-newline-and-reformat ()
>     "Insert four newlines, and then reformat if inside quoted text."
>     (interactive)
> !   (let ((prefix "[]>»|:}+ \t]*")
>   	(supercite-thing "[-._a-zA-Z0-9]*[>]+[ \t]*")
>   	quoted point)
>       (unless (bolp)
>         (save-excursion
>   	(beginning-of-line)
> ! 	(when (looking-at (concat prefix "\\|"
> ! 				  supercite-thing))
>   	  (setq quoted (match-string 0))))
>         (insert "\n"))
>       (setq point (point))
> --- 1711,1724 ----
>   (defun message-newline-and-reformat ()
>     "Insert four newlines, and then reformat if inside quoted text."
>     (interactive)
> !   (let ((prefix "[]>»\|:}+ \t]*")
>   	(supercite-thing "[-._a-zA-Z0-9]*[>]+[ \t]*")
>   	quoted point)
>       (unless (bolp)
>         (save-excursion
>   	(beginning-of-line)
> ! 	(when (or (looking-at supercite-thing)
> ! 		  (looking-at prefix))
>   	  (setq quoted (match-string 0))))
>         (insert "\n"))
>       (setq point (point))

i have some questions/suggestions:

1) you changed
  (let ((prefix "[]>»|:}+ \t]*")
to
  (let ((prefix "[]>»\|:}+ \t]*")

But this seems to be not needed (i.e. a backslash before | is not
needed):

(string-equal
  "[]>»|:}+ \t]*"
  "[]>»\|:}+ \t]*")
t

2) (looking-at prefix) will ALWAYS return t because ANY string matches
   a regexp of form [something]*
   so the check for (looking-at prefix) is broken.

   i think that this regexp could be changed to something like
   []>»|:}+]+[ \t]*

   BTW, the broken regexp for prefix was THE reason why your patch
   broke message-newline-and-reformat: the resulting regexp

   <value of prefix>\\|<value of supercite-thing>

   gave a null string match.

3) (supercite-thing "[-._a-zA-Z0-9]*[>]+[ \t]*")
   could be changed (simplified) to
   (supercite-thing "[-._a-zA-Z0-9]*>+[ \t]*")

4) the trick of changing 
  (looking-at (concat prefix "\\|" supercite-thing))
to
  (or (looking-at supercite-thing) (looking-at prefix))
seems to me like a hack.

  of course the original form (the one which you added some time ago)
  should work PROVIDED that prefix is sensibly defined AND
  supercite-thing comes before prefix (because otherwise prefix could
  find a smaller match)

5) the whole concat thing (and assigning prefix and supercite-thing
   variables) is not necessary, and you could just put a ready-to-use
   regexp in looking-at's argument.

6) looking only for latin letters (a-zA-Z) is not necessary (e.g. i
   often need to answer letters written by people with cyrillic
   initials), so it is better to change it to \w.

7) here is a resulting message-newline-and-reformat which seems to
   work much better for me:

(defun message-newline-and-reformat ()
  "Insert four newlines, and then reformat if inside quoted text."
  (interactive)
  (let (quoted point)
    (unless (bolp)
      (save-excursion
        (beginning-of-line)
        (when (looking-at " *\\(\\w\\|[-._]\\)*>+[ \t]*\\|[]>»|:}+ \t]*")
          (setq quoted (match-string 0))))
      (insert "\n"))
    (setq point (point))
    (insert "\n\n\n")
    (delete-region (point) (re-search-forward "[ \t]*"))
    (when quoted
      (insert quoted))
    (fill-paragraph nil)
    (goto-char point)
    (forward-line 1)))

Best,
v.




  reply	other threads:[~2000-11-10 15:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-10 11:39 Vladimir Volovich
2000-11-10 12:20 ` dme
2000-11-10 12:58 ` dme
2000-11-10 15:16   ` Vladimir Volovich [this message]
2000-11-10 15:37     ` dme
2000-11-10 16:52     ` Kai Großjohann
2000-11-11 18:35       ` dme
2000-11-11 22:38         ` Kai Großjohann
2000-11-12 11:21         ` dme
2000-11-13 10:49     ` Vladimir Volovich
2000-11-13 12:17       ` dme
2000-11-13 12:23     ` Vladimir Volovich
2000-11-10 11:46 Vladimir Volovich
2000-11-17 11:42 Vladimir Volovich
2000-11-17 11:51 ` dme
2000-11-17 13:09   ` ShengHuo ZHU
2000-11-17 13:09 ` ShengHuo ZHU

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

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

  git send-email \
    --in-reply-to=eyem0jq2lf.fsf@video.uic.vsu.ru \
    --to=vvv@vvv.vsu.ru \
    /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.
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 NNTP newsgroup(s).