Gnus development mailing list
 help / color / mirror / Atom feed
From: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
To: ding@gnus.org
Subject: Re: [PATCH] Use replace-match in posting-style.
Date: Sun, 11 Apr 2010 16:04:31 +0200	[thread overview]
Message-ID: <87vdbyccgg.fsf@hati.baby-gnu.org> (raw)
In-Reply-To: <m2aatadtda.fsf@igel.home> (Andreas Schwab's message of "Sun, 11 Apr 2010 15:13:53 +0200")


[-- Attachment #1.1: Type: text/plain, Size: 1827 bytes --]

Andreas Schwab <schwab@linux-m68k.org> writes:

>> => ((name . "Daniel Dehennin") (address . "foo@mydomain.com"))
>
> I find this pretty confusing.  I would have expected "foo@mydomain" as
> the address value (assuming it was "\\1@mydomain" originally).

Erf, I notices the replacement in the name but not the trailing ".com"
in the address.

The problem comes from the match, it should match the entire group like
this:

    (match "mydomain\\.\\(foo\\|bar\\).*")

I don't know if it's possible to replace the positionnal parameter
directly in the value, i.e. expanding the positional parameter in value
and not using it as a replacement against group.

For now we can limit the replacement to the matching part of the group:

  (let ((group "mydomain.foo.com")
        (match "mydomain\\.\\(foo\\|bar\\)")
        (values '((name "Daniel Dehennin")
                  (address "\\1@mydomain")))
        value element)
    (and (string-match match group)
         (mapcar (lambda (x)
                   (setq element (car x)
                         value (cadr x))
                   (cons element

                         (cond ((stringp value)
                                (if (and (stringp match)
                                         ;; The FIX
					 (string-match-p "\\\\[&[:digit:]]" value)
                                         (match-beginning 1))
                                    (replace-match value nil nil 
                                                   (substring group (match-beginning 0) (match-end 0)))
                                  value)))))
                 values)))

 => ((name . "Daniel Dehennin") (address . "foo@mydomain"))

Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Use replacement in posting-style --]
[-- Type: text/x-diff, Size: 546 bytes --]

=== modified file 'lisp/gnus-msg.el'
--- lisp/gnus-msg.el	2009-01-22 07:02:15 +0000
+++ lisp/gnus-msg.el	2010-04-11 14:02:03 +0000
@@ -1890,7 +1890,12 @@
 	    (setq v
 		  (cond
 		   ((stringp value)
-		    value)
+		    (if (and (stringp match)
+			     (string-match-p "\\\\[&[:digit:]]" value)
+			     (match-beginning 1))
+			(replace-match value nil nil 
+				       (substring group (match-beginning 0) (match-end 0)))
+		      value))
 		   ((or (symbolp value)
 			(functionp value))
 		    (cond ((functionp value)


[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2010-04-11 14:04 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07 21:15 Daniel Dehennin
2009-07-08 18:51 ` Ted Zlatanov
2010-04-10  9:57   ` Daniel Dehennin
2010-04-10 19:10     ` Johan Bockgård
2010-04-10 23:22       ` Daniel Dehennin
2010-04-11 13:13         ` Andreas Schwab
2010-04-11 14:04           ` Daniel Dehennin [this message]
2010-04-11 15:06             ` Andreas Schwab
2010-04-12 12:18               ` Daniel Dehennin
2010-06-23 21:02                 ` Daniel Dehennin
2010-07-08 13:57                   ` Ted Zlatanov
2010-07-12 19:43                     ` Daniel Dehennin
2010-07-30 17:43                       ` replace matches in any string (was: [PATCH] Use replace-match in posting-style.) Ted Zlatanov
2010-09-01 13:55                         ` replace matches in any string Ted Zlatanov
2010-09-02 11:29                           ` Stefan Monnier
2010-09-02 13:10                             ` Ted Zlatanov
2010-09-02 14:44                               ` Lars Magne Ingebrigtsen
2010-09-02 16:21                               ` Stefan Monnier
2010-09-02 16:45                                 ` David Kastrup
2010-09-02 17:08                                 ` Ted Zlatanov
2010-09-02 17:22                                   ` David Kastrup
2010-09-02 17:51                                     ` Ted Zlatanov
2010-09-02 18:04                                       ` David Kastrup
2010-09-02 19:12                                         ` Ted Zlatanov
     [not found]                                           ` <8739tsosyg.fsf_-_@maguirefamily.org>
2010-09-02 21:52                                             ` Recommended gnus spam filter system? Ted Zlatanov
2010-09-02 20:27                                     ` replace matches in any string Stefan Monnier
2010-09-02 22:18                                       ` Lars Magne Ingebrigtsen
2010-09-03  5:33                                       ` David Kastrup
2010-09-03 17:06                                         ` Lars Magne Ingebrigtsen
2010-08-29 20:07                   ` [PATCH] Use replace-match in posting-style Lars Magne Ingebrigtsen
2010-08-30 13:41                     ` Ted Zlatanov
2010-08-30 17:11                       ` Lars Magne Ingebrigtsen
2010-08-31 18:42                         ` Ted Zlatanov
2010-08-31 18:47                           ` Lars Magne Ingebrigtsen
2010-09-02 17:59                 ` Ted Zlatanov
2010-09-02 19:32                   ` Daniel Dehennin
2010-09-02 19:50                   ` [PATCH] Permit the use of regular expression match and replace in posting styles Daniel Dehennin
2010-09-02 21:56                     ` Ted Zlatanov
2010-09-04 22:47                       ` Mike Kupfer
2010-09-05  2:36                         ` Ted Zlatanov
2010-09-06 22:43                           ` Mike Kupfer
2010-09-06 23:18                             ` Ted Zlatanov

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=87vdbyccgg.fsf@hati.baby-gnu.org \
    --to=daniel.dehennin@baby-gnu.org \
    --cc=ding@gnus.org \
    /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).