Subject: bug#14637: closed (Re: bug#14637: recent viper-mode regression)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 18 Jun 2013 20:31:02 +0000

Your bug report

#14637: recent viper-mode regression

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
14637: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14637
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#14637: recent viper-mode regression
From: Juri Linkov <[email-masked]>
To: Jim Meyering <[email-masked]>
Cc: [email-masked]
Date: Tue, 18 Jun 2013 23:25:20 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Now, however, it merely appends the result, instead of replacing the
> source lines.

I know nothing about viper-mode, but apparently this regression is
caused by revno:112695 that now requires for the callers of
`shell-command-on-region' to explicitly specify its argument REPLACE
as documented in its docstring for a long time.  However, this fix
breaks such callers that don't care about providing the correct
non-nil REPLACE argument to behave according to the documentation.
Grepping for `shell-command-on-region' revealed the exhaustive list
of the callers that are fixed now with this patch to set both args
OUTPUT-BUFFER and REPLACE to the same value in unison:

=== modified file 'lisp/emulation/vi.el'
--- lisp/emulation/vi.el	2012-09-17 05:41:04 +0000
+++ lisp/emulation/vi.el	2013-06-18 20:17:20 +0000
@@ -1148,7 +1148,8 @@ (defun vi-shell-op (motion-command arg &
       (cond ((null shell-command)
 	     (setq shell-command (read-string "!" nil))
 	     (setq vi-last-shell-command shell-command)))
-      (shell-command-on-region begin end shell-command (not (vi-prefix-char-value arg)))
+      (shell-command-on-region begin end shell-command (not (vi-prefix-char-value arg))
+			                               (not (vi-prefix-char-value arg)))
       t)))
 
 (defun vi-shift-op (motion-command arg amount)

=== modified file 'lisp/emulation/vip.el'
--- lisp/emulation/vip.el	2013-03-12 02:08:21 +0000
+++ lisp/emulation/vip.el	2013-06-18 20:17:24 +0000
@@ -775,7 +775,7 @@ (defun vip-execute-com (m-com val com)
 		  (if (= com ?!)
 		      (setq vip-last-shell-com (vip-read-string "!"))
 		    vip-last-shell-com)
-		  t)))
+		  t t)))
 	      ((= com ?=)
 	       (save-excursion
 		 (set-mark vip-com-point)
@@ -3042,7 +3042,7 @@ (defun ex-command ()
 	  (goto-char beg)
 	  (set-mark end)
 	  (vip-enlarge-region (point) (mark))
-	  (shell-command-on-region (point) (mark) command t))
+	  (shell-command-on-region (point) (mark) command t t))
 	(goto-char beg)))))
 
 (defun ex-line-no ()

=== modified file 'lisp/emulation/viper-cmd.el'
--- lisp/emulation/viper-cmd.el	2013-05-22 03:21:30 +0000
+++ lisp/emulation/viper-cmd.el	2013-06-18 20:17:31 +0000
@@ -1548,7 +1548,7 @@ (defun viper-exec-bang (m-com com)
 		(car viper-shell-history)
 		))
        viper-last-shell-com)
-     t)))
+     t t)))
 
 (defun viper-exec-equals (m-com com)
   (save-excursion

=== modified file 'lisp/emulation/viper-ex.el'
--- lisp/emulation/viper-ex.el	2013-05-22 03:21:30 +0000
+++ lisp/emulation/viper-ex.el	2013-06-18 20:17:34 +0000
@@ -2176,7 +2176,7 @@ (defun ex-command ()
 	  (goto-char beg)
 	  (set-mark end)
 	  (viper-enlarge-region (point) (mark t))
-	  (shell-command-on-region (point) (mark t) command t))
+	  (shell-command-on-region (point) (mark t) command t t))
 	(goto-char beg)))))
 
 (defun ex-compile ()

=== modified file 'lisp/mh-e/mh-alias.el'
--- lisp/mh-e/mh-alias.el	2013-01-01 09:11:05 +0000
+++ lisp/mh-e/mh-alias.el	2013-06-18 20:17:37 +0000
@@ -141,7 +141,7 @@ (defun mh-alias-local-users ()
             (insert-file-contents "/etc/passwd")))
        ((stringp mh-alias-local-users)
         (insert mh-alias-local-users "\n")
-        (shell-command-on-region (point-min) (point-max) mh-alias-local-users t)
+        (shell-command-on-region (point-min) (point-max) mh-alias-local-users t t)
         (goto-char (point-min))))
       (while  (< (point) (point-max))
         (cond

Subject: recent viper-mode regression
From: Jim Meyering <[email-masked]>
To: [email-masked]
Date: Mon, 17 Jun 2013 00:59:55 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,
I periodically use built-from-git emacs and noticed that in the
last couple of weeks a common command in viper-mode, "!Ggrep ..."
had begun to malfunction.  Normally, !G<cmd> runs CMD on the contents
of the buffer (from the line with point to EOF) and replaces those
lines with the output of the command.

Now, however, it merely appends the result, instead of replacing the
source lines.

E.g., if you run this,

  seq 10 > k; emacs -q -nw -f viper-mode k

then type "!Ggrep 3", you'll end up with this in your buffer:
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  3

Instead, the buffer should (and used to) contain this single line:

  3