Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-12-03 Thread Tatsuya Kinoshita
On December 2, 2013 at 10:08AM +0900, yamaoka (at jpl.org) wrote:
  * mew-w3m.el (mew-w3m-region): Set point to minimum for
  `mew-w3m-cite-blockquote' to work.
 
 Thanks for verifying and fixing it.  I've installed the version.

One more patch to prevent infloop.

Thanks,
-- 
Tatsuya Kinoshita
2013-12-03  Tatsuya Kinoshita  t...@vega.ocn.ne.jp

	* mew-w3m.el (mew-w3m-region): Set point to the end of div tag to
	prevent infinite loop.

--- a/mew-w3m.el
+++ b/mew-w3m.el
@@ -195,9 +195,9 @@ The variable `mew-w3m-region-cite-mark' specifies the citation mark.
 	(while (and (re-search-forward
 		 [\t\n ]*div\\(?:[\t\n ]*\\|[\t\n ]+[^]+\\) nil t)
 		(w3m-end-of-tag div))
-	  (goto-char (match-end 0))
-	  (insert \n)
 	  (goto-char (match-beginning 0))
+	  (insert \n)
+	  (goto-char (1+ (match-end 0)))
 	  (insert \n))
 	(goto-char (point-min))
 	(while (re-search-forward ^[\t ]+$ nil t)


Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-12-03 Thread Katsumi Yamaoka
In [emacs-w3m : No.12236] Tatsuya Kinoshita wrote:
 2013-12-03  Tatsuya Kinoshita  t...@vega.ocn.ne.jp

   * mew-w3m.el (mew-w3m-region): Set point to the end of div tag to
   prevent infinite loop.

Indeed.  I've applied your patch.  Thanks.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-12-01 Thread Tatsuya Kinoshita
On November 5, 2013, [emacs-w3m:12210], yamaoka (at jpl.org) wrote:
 I tried improving `mew-w3m-region' (I'm not a Mew user though).
 Does the attached patch make it do what you think right?

Works fine with the attached patch.

Thanks,
-- 
Tatsuya Kinoshita
2013-12-01  Tatsuya Kinoshita  t...@vega.ocn.ne.jp

	* mew-w3m.el (mew-w3m-region): Set point to minimum for
	`mew-w3m-cite-blockquote' to work.

diff --git a/mew-w3m.el b/mew-w3m.el
index c52e06a..f1d66ee 100644
--- a/mew-w3m.el
+++ b/mew-w3m.el
@@ -242,6 +242,7 @@ The variable `mew-w3m-region-cite-mark' specifies the citation mark.
   (w3m-region start end url charset)
 (save-restriction
   (narrow-to-region start end)
+  (goto-char (point-min))
   (mew-w3m-cite-blockquote)
   (w3m-region (point-min) (point-max) url charset)
   (goto-char (point-min))


Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-12-01 Thread Christophe TROESTLER
Hi,

As an alternative solution, I have been using the replacement of
`mew-w3m-region` below.  Comments are welcome.  I had no time to try
the proposed patch yet.

My 0.02€,
C.


(defun mew-w3m-insert-quote-mark ()
  We assume to be the beginning of a line.  Skip any HTML tags
to the data.  This is to put the quotation mark right before the
text.
  (catch 'Break
(while (looking-at [ \t\f\n]*\\(/?[a-zA-Z]+\\)\\([ \t\f\n]+[^]*\\)?)
  (let ((tag (buffer-substring (match-beginning 1) (match-end 1)))
(tagbeg (match-beginning 0))
(tagend (match-end 0)))
(cond
 ((string-equal tag br)
  (goto-char tagbeg)
  (insert mew-w3m-region-cite-mark)
  (goto-char tagend))
 ((member tag '(ul /ul ol /ol))
  (delete-region tagbeg tagend))
 ((string-equal tag li)
  ;; Replace li to put the mark at the beginning of the line.
  (delete-region tagbeg tagend)
  (insert mew-w3m-region-cite-mark  * )
  (throw 'Break nil)
  )
 ((string-equal tag /li)
  (delete-region tagbeg tagend)
  (insert br/)
  (throw 'Break nil)
  )
 (t
  (goto-char tagend)
(insert mew-w3m-region-cite-mark)))

(defun mew-w3m-region (start end optional url charset)
  w3m-region with inserting the cite mark.
  (if (null mew-w3m-region-cite-mark)
  (w3m-region start end url charset)
(save-restriction
  (narrow-to-region start end)
  (let ((case-fold-search t)
(has-blockquote nil)
lines tagbeg0 tagend0 tagbeg1 tagend1)
(goto-char (point-min))
(while (w3m-search-tag blockquote)
  (setq has-blockquote t)
  (setq tagbeg0 (match-beginning 0))
  (setq tagend0 (match-end 0))
  (when (w3m-end-of-tag blockquote t)
(setq tagend1 (point))
(re-search-backward / *blockquote)
(setq tagbeg1 (match-beginning 0))
(setq lines (buffer-substring tagend0 tagbeg1))
(delete-region tagbeg0 tagend1)
(insert (with-temp-buffer
  (insert lines)
  (goto-char (point-min))
  (mew-w3m-insert-quote-mark)
  ;; div also start new lines.
  (while (w3m-search-tag br /div div)
;; brdiv* is a single new line
(mew-w3m-insert-quote-mark))
  (buffer-substring (point-min) (point-max
(goto-char (point-min)); deal with other blockquote
))
(let ((f w3m-fill-column))
  (setq w3m-fill-column (if has-blockquote 8192 0))
  (w3m-region (point-min) (point-max) url charset)
  (setq w3m-fill-column f)))
  )))


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-12-01 Thread Katsumi Yamaoka
In [emacs-w3m : No.12231] Tatsuya Kinoshita wrote:
 2013-12-01  Tatsuya Kinoshita  t...@vega.ocn.ne.jp

   * mew-w3m.el (mew-w3m-region): Set point to minimum for
   `mew-w3m-cite-blockquote' to work.

Thanks for verifying and fixing it.  I've installed the version.

In [emacs-w3m : No.12232] christophe.troest...@umons.ac.be wrote:
 As an alternative solution, I have been using the replacement of
 `mew-w3m-region` below.  Comments are welcome.  I had no time to try
 the proposed patch yet.

Thank you for contributing the imporvements.  But I'm not capable
to test your proposal since I'm not a Mew user, so please provide
a patch against the present CVS version and the ChangeLog entry
when you have time.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-11-04 Thread Tatsuya Kinoshita
Forwarding from Debian Bug:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728501

On November 2, 2013 at 12:00AM +0100, Christophe.Troestler (at umons.ac.be) 
wrote:
 Package: w3m-el
 Version: 1.4.483+0.20120614-3
 Severity: normal
 
 Dear Maintainer,
 
 The function `mew-w3m-region` in mew-w3m.el does not work with a
 blockquote inside another blockquote (this may happen when citations
 are inside other citations in emails).  I guess one must use
 `w3m-end-of-tag` instead of `w3m-search-tag` to locate the closing
 tag.
 
 Also, div start new lines ― which must be quoted ― but one has to be
 careful that brdiv, br/divdivdiv,... only produce a single
 new line.
 
 It will be appreciated that these problems be fixed.
 
 Best,
 C.

Thanks,
-- 
Tatsuya Kinoshita


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-11-04 Thread Tatsuya Kinoshita
tags 728501 + upstream
forwarded 728501 http://emacs-w3m.namazu.org/ml/msg12101.html
thanks


pgp6sk8IIshsA.pgp
Description: PGP signature


Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-11-04 Thread Katsumi Yamaoka
In [emacs-w3m : No.12209] Kinoshita-san wrote:
 Forwarding from Debian Bug:
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728501

 On November 2, 2013 at 12:00AM +0100, Christophe.Troestler (at
 umons.ac.be) wrote:
 Package: w3m-el
 Version: 1.4.483+0.20120614-3
 Severity: normal

 Dear Maintainer,

 The function `mew-w3m-region` in mew-w3m.el does not work with a
 blockquote inside another blockquote (this may happen when citations
 are inside other citations in emails).  I guess one must use
 `w3m-end-of-tag` instead of `w3m-search-tag` to locate the closing
 tag.

 Also, div start new lines ― which must be quoted ― but one has to be
 careful that brdiv, br/divdivdiv,... only produce a single
 new line.

 It will be appreciated that these problems be fixed.

 Best,
 C.

I tried improving `mew-w3m-region' (I'm not a Mew user though).
Does the attached patch make it do what you think right?
If not, could you send me an html example?

--- mew-w3m.el~	2010-01-13 00:59:40.0 +
+++ mew-w3m.el	2013-11-05 03:31:53.844275200 +
@@ -161,56 +161,102 @@
 	  (mew-w3m-add-text-properties `(w3m-images ,(not image)))
 	  (set-buffer-modified-p nil)))
 
+(defun mew-w3m-cite-blockquote (optional inside-blockquote)
+  Quote paragraphs in blockquote.../blockquote with the citation mark.
+The variable `mew-w3m-region-cite-mark' specifies the citation mark.
+  (let ((case-fold-search t))
+(while (and (re-search-forward \
+\[\t\n ]*[\t\n ]*blockquote\\(?:[\t\n ]*\\|[\t\n ]+[^]+\\) nil t)
+		(w3m-end-of-tag blockquote t))
+  (save-restriction
+	(narrow-to-region (match-beginning 0) (match-end 0))
+	(delete-region (goto-char (match-end 3)) (match-end 0))
+	(insert \n)
+	(delete-region (goto-char (point-min)) (match-beginning 3))
+	(insert \n)
+	(while (and (re-search-forward
+		 [\t\n ]*pre\\(?:[\t\n ]*\\|[\t\n ]+[^]+\\) nil t)
+		(w3m-end-of-tag pre t))
+	  (delete-region (goto-char (match-end 2)) (match-end 0))
+	  (if (bolp)
+	  (when (looking-at \n+) (replace-match ))
+	(insert \n))
+	  (delete-region (goto-char (match-beginning 0)) (match-beginning 2))
+	  (if (bolp)
+	  (when (looking-at \n+) (replace-match ))
+	(insert \n)))
+	(goto-char (point-min))
+	(mew-w3m-cite-blockquote 'inside-blockquote)
+	(goto-char (point-min))
+	(while (re-search-forward
+		[\t\n ]*br\\(?:[\t\n ]*\\|[\t\n ]+[^]+\\) nil t)
+	  (replace-match \n))
+	(goto-char (point-min))
+	(while (and (re-search-forward
+		 [\t\n ]*div\\(?:[\t\n ]*\\|[\t\n ]+[^]+\\) nil t)
+		(w3m-end-of-tag div))
+	  (goto-char (match-end 0))
+	  (insert \n)
+	  (goto-char (match-beginning 0))
+	  (insert \n))
+	(goto-char (point-min))
+	(while (re-search-forward ^[\t ]+$ nil t)
+	  (replace-match ))
+	(goto-char (point-min))
+	(while (re-search-forward \n\n\n+ nil t)
+	  (replace-match \n\n))
+	(goto-char (point-min))
+	(when mew-w3m-region-cite-mark
+	  (goto-char (point-min))
+	  (while (re-search-forward [^\t\n ] nil t)
+	(beginning-of-line)
+	(if (looking-at [\t ]+)
+		(replace-match mew-w3m-region-cite-mark)
+	  (insert mew-w3m-region-cite-mark))
+	(end-of-line)))
+	(unless inside-blockquote
+	  ; --  
+	  (when (and mew-w3m-region-cite-mark
+		 (string-match nbsp;\\' mew-w3m-region-cite-mark))
+	(let ((base (substring mew-w3m-region-cite-mark
+   0 (match-beginning 0)))
+		  (regexp (regexp-quote mew-w3m-region-cite-mark)))
+	  (setq regexp (concat ^ regexp \\(?: regexp \\)+))
+	  (goto-char (point-min))
+	  (while (re-search-forward regexp nil t)
+		(dotimes (i (prog1
+(/ (- (match-end 0) (match-beginning 0))
+   (length mew-w3m-region-cite-mark))
+			  (delete-region (match-beginning 0)
+	 (match-end 0
+		  (insert base))
+		(insert nbsp;
+	  (goto-char (point-min))
+	  (insert pre)
+	  (goto-char (point-max))
+	  (insert /pre\n))
+
 (defun mew-w3m-region (start end optional url charset)
   w3m-region with inserting the cite mark.
   (if (null mew-w3m-region-cite-mark)
   (w3m-region start end url charset)
 (save-restriction
   (narrow-to-region start end)
-  (let ((case-fold-search t)
-	pos lines tagbeg0 tagend0 tagbeg1 tagend1)
-	(goto-char (point-min))
-	(while (w3m-search-tag blockquote)
-	  (setq tagbeg0 (match-beginning 0))
-	  (setq tagend0 (match-end 0))
-	  (when (w3m-search-tag /blockquote)
-	(setq tagbeg1 (match-beginning 0))
-	(setq tagend1 (match-end 0))
-	(setq lines (buffer-substring tagend0 tagbeg1))
-	(delete-region tagbeg0 tagend1)
-	(insert (with-temp-buffer
-		  (insert lines)
-		  (goto-char (point-min))
-		  (if (and (w3m-search-tag pre)
-			   (setq tagbeg0 (match-beginning 0))
-			   (setq tagend0 (match-end 0))
-			   (w3m-search-tag /pre)
-			   (setq tagbeg1 (match-beginning 0))
-			   (setq tagend1 (match-end 0)))
-			  (progn
-			(delete-region tagbeg1 tagend1)
-			(delete-region tagbeg0 tagend0))
-			;; delete br
-			

Bug#728501: w3m-el: mew-w3m-region multiple blockquote

2013-11-01 Thread Christophe TROESTLER
Package: w3m-el
Version: 1.4.483+0.20120614-3
Severity: normal

Dear Maintainer,

The function `mew-w3m-region` in mew-w3m.el does not work with a
blockquote inside another blockquote (this may happen when citations
are inside other citations in emails).  I guess one must use
`w3m-end-of-tag` instead of `w3m-search-tag` to locate the closing
tag.

Also, div start new lines — which must be quoted — but one has to be
careful that brdiv, br/divdivdiv,... only produce a single
new line.

It will be appreciated that these problems be fixed.

Best,
C.

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (900, 'testing'), (400, 'unstable'), (300, 'stable'), (100, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.10.12 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages w3m-el depends on:
ii  apel  10.8+0.20120427-4
ii  dpkg  1.16.12
ii  emacs23   23.4+1-4.1
ii  emacs24   24.3+1-2
ii  install-info  5.2.0.dfsg.1-1
ii  w3m   0.5.3-12

Versions of packages w3m-el recommends:
ii  apel  10.8+0.20120427-4
ii  flim  1:1.14.9+0.20120428-2

Versions of packages w3m-el suggests:
ii  bzip2   1.0.6-5
ii  imagemagick 8:6.7.7.10-6
pn  libmoe1.5   none
pn  mule-ucsnone
pn  namazu2 none
pn  perl-docnone
ii  poppler-utils [xpdf-utils]  0.18.4-8
ii  ppthtml 0.5.1-6
ii  wv  1.2.9-3
ii  xlhtml  0.5.1-6

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org