From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/33305 Path: main.gmane.org!not-for-mail From: Vladimir Volovich Newsgroups: gmane.emacs.gnus.general Subject: Re: someone broke message-newline-and-reformat Date: 10 Nov 2000 18:16:44 +0300 Sender: owner-ding@hpc.uh.edu Message-ID: References: <874s1gm1al.fsf@serafina-pekkala.dme.org> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1035169438 24439 80.91.224.250 (21 Oct 2002 03:03:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 03:03:58 +0000 (UTC) Return-Path: Original-Received: from spinoza.math.uh.edu (spinoza.math.uh.edu [129.7.128.18]) by mailhost.sclp.com (Postfix) with ESMTP id 13268D049A for ; Fri, 10 Nov 2000 10:17:23 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by spinoza.math.uh.edu (8.9.1/8.9.1) with ESMTP id JAB00192; Fri, 10 Nov 2000 09:16:50 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Fri, 10 Nov 2000 09:16:13 -0600 (CST) Original-Received: from mailhost.sclp.com (postfix@66-209.196.61.interliant.com [209.196.61.66] (may be forged)) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id JAA23186 for ; Fri, 10 Nov 2000 09:16:02 -0600 (CST) Original-Received: from vsu.ru (info.vsu.ru [62.76.169.9]) by mailhost.sclp.com (Postfix) with ESMTP id DF4C0D049A for ; Fri, 10 Nov 2000 10:16:17 -0500 (EST) Original-Received: from video.uic.vsu.ru ([62.76.169.38] verified) by vsu.ru (CommuniGate Pro SMTP 3.3.1) with ESMTP id 2020952 for ding@gnus.org; Fri, 10 Nov 2000 18:16:34 +0300 Original-To: ding@gnus.org In-Reply-To: <874s1gm1al.fsf@serafina-pekkala.dme.org> Original-Lines: 113 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:33305 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:33305 > 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 \\| 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.