🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #303

PLEASE TRY THIS PATCH

#303
From: blueman
Date: Fri, 08 Jan 2010 16:50
175 lines
9146 bytes
Let's start on a clean slate here and hopefully let's avoid any flame
wars or recriminations. I think we are both just trying to improve this
great program.

Here is a patch against your latest *668* revision that cleans things up a
bit more. In particular,

    - It removes the confusing/redundant use of the 2nd argument command
      (since it is available via process-command). 

    - Also, it removes the duplicate and potentially interfering
      functionality created by the unnecessary variable
      vm-message-includes-separators. Instead, this functionality can be
      accessed using 4 prefix arguments which is 100% consistent usage
      with the other flavors of addressing message parts in
      vm-pipe-message-part and vm-pipes-message-to-command.

      Note, I also added code in vm-pipe-messages-to-command that allows
      the 4 prefixes to override the separate start/end separators
      rather than conflicting with them (as is the case in your code)

If I should be submitting patches instead to launchpad please tell me
where and how to do that.

If the patch doesn't work or you have suggestions for improvement,
please let me know.

--- vm-save.el	2010-01-08 10:27:45.742590014 -0500
+++ vm-save.el.new	2010-01-08 11:47:32.797589324 -0500
@@ -556,7 +556,7 @@
 	 (list (vm-headers-of m) (vm-text-of m)))
 	((equal prefix-arg '(64))
 	 (list (vm-vheaders-of m) (vm-text-end-of m)))
-	(vm-message-includes-separators
+	((equal prefix-arg '(256))
 	 (list (vm-start-of m) (vm-end-of m)))
 	(t 
 	 (list (vm-headers-of m) (vm-text-end-of m)))))
@@ -571,6 +571,7 @@
 With two \\[universal-argument]'s the header portion of the message is used.
 With three \\[universal-argument]'s the visible header portion of the message
 plus the text portion is used.
+With four \\[universal-argument]'s the entire message plus separators is used
 
 When invoked on marked messages (via vm-next-command-uses-marks),
 each marked message is successively piped to the shell command,
@@ -642,33 +643,33 @@
 	   current-prefix-arg)))
   (vm-pipe-message-to-command command prefix-arg t))
 
-(defun vm-pipe-command-exit-handler (process command discard-output 
+(defun vm-pipe-command-exit-handler (process discard-output 
 					     &optional exit-handler)
-"Switch to output buffer of PROCESS that ran COMMAND, if
-DISCARD-OUTPUT non-nil.  
-If non-nil call EXIT-HANDLER with the two arguments COMMAND and OUTPUT-BUFFER." 
+  "Switch to output buffer of PROCESS if DISCARD-OUTPUT non-nil.
+If non-nil call EXIT-HANDLER with the command associated with the process
+ as the first argument and OUTPUT-BUFFER as the second argument." 
   (let ((exit-code (process-exit-status process))
 	(buffer (process-buffer process))
-	(process-command (process-command process)))
+	(command (process-command process)))
   (if (not (zerop exit-code))
       (message "Command '%s' exit code is %d." command exit-code))
   (vm-display nil nil '(vm-pipe-message-to-command)
 	      '(vm-pipe-message-to-command))
   (vm-switch-to-command-output-buffer command buffer discard-output)
   (if exit-handler
-      (funcall exit-handler process-command buffer))))
+      (funcall exit-handler command buffer))))
 
 (defvar vm-pipe-messages-to-command-start t
   "*The string to be used as the leading message separator by
 `vm-pipe-messages-to-command' at the beginning of each message.
 If set to 't', then use the leading message separator stored in the VM
-folder.")
+folder. If nil then skip insertion.")
 
 (defvar vm-pipe-messages-to-command-end t
   "*The string to be used as the trailing message separator by
 `vm-pipe-messages-to-command' at the end of each message.
 If set to 't', then use the trailing message separator stored in the VM
-folder.")
+folder. If nil then skip insertion")
 
 ;;;###autoload
 (defun vm-pipe-messages-to-command (command &optional prefix-arg 
@@ -680,8 +681,14 @@
 is much faster than calling the command on each message.  This is
 more like saving to a pipe.
 
-Before a message it will insert `vm-pipe-messages-to-command-start'
-and after a message `vm-pipe-messages-to-command-end'.
+Note that the interpretation of \\[universal-argument]'s is the same as for
+`vm-pipe-message-to-command'
+
+Before and after piping each message, it will add separators based on 
+the value of the variables `vm-pipe-messages-to-command-start'
+and `vm-pipe-messages-to-command-end', respectively. 
+\(These variables are ignored if four \\[universal-argument]'s are used so as
+to avoid duplication of separators.\)
 
 Output, if any, is displayed unless DISCARD-OUTPUT is t.
 
@@ -721,7 +728,7 @@
 	(if (eq 'exit status)
 	    (if ,no-wait
 		(vm-pipe-command-exit-handler 
-		 process ,command ,discard-output 
+		 process ,discard-output 
 		 (if (and ,no-wait (functionp ,no-wait))
 		     ,no-wait)))
 	  (message "Command '%s' changed state to %s."
@@ -731,17 +738,23 @@
       (set-buffer (vm-buffer-of m))
       (save-restriction
 	(widen)
-	(if (equal vm-pipe-messages-to-command-start t)
-	    (process-send-region process 
-				 (vm-start-of m) (vm-headers-of m))
-	  (process-send-string process vm-pipe-messages-to-command-start))
+	(cond
+	 ((or (null vm-pipe-messages-to-command-start) ; No start separator
+		  (equal current-prefix-arg '(256)))); Initial separator already inserted
+	 ((equal vm-pipe-messages-to-command-start t)
+	  (process-send-region process  ; Insert content before header
+				 (vm-start-of m) (vm-headers-of m)))
+	 (t (process-send-string process vm-pipe-messages-to-command-start)))
 	(let ((region (vm-pipe-message-part m prefix-arg)))
 	  (process-send-region process (nth 0 region) (nth 1 region)))
-	(if (equal vm-pipe-messages-to-command-end t)
-	    (process-send-region process 
-				 (vm-text-end-of m) (vm-end-of m))
-	  (process-send-string process vm-pipe-messages-to-command-end)))
-      (setq mlist (cdr mlist)))
+	(cond
+	 ((or (null vm-pipe-messages-to-command-end) ; No end separator
+		  (equal current-prefix-arg '(256)))) ; End separator already inserted
+	 ((equal vm-pipe-messages-to-command-end t)
+	  (process-send-region process  ; Insert content after end of body
+				 (vm-text-end-of m) (vm-end-of m)))
+	 ( t (process-send-string process vm-pipe-messages-to-command-end)))
+      (setq mlist (cdr mlist))))
 
     (process-send-eof process)
 
@@ -749,7 +762,7 @@
       (while (and (eq 'run (process-status process)))
 	(accept-process-output process)
 	(sit-for 0))
-      (vm-pipe-command-exit-handler process command discard-output))
+      (vm-pipe-command-exit-handler process discard-output))
     buffer))
 
 (defun vm-pipe-messages-to-command-to-string (command &optional prefix-arg)



--- vm-vars.el	2010-01-08 11:38:10.332588869 -0500
+++ vm-vars.el.new	2010-01-08 11:39:05.017589566 -0500
@@ -775,13 +775,6 @@
 
 (make-variable-buffer-local 'vm-sync-thunderbird-status)
 
-(defcustom vm-message-includes-separators
-  nil
-"*Non-nil value means that VM should include the leading and
-separator lines when it passes a message to external programs."
-  :group 'vm
-  :type 'boolean)
-
 (defcustom vm-visible-headers
   '("Resent-"
     "From:" "Sender:"
Technical Details
Message-ID: <m2aawownfr.fsf_-_@consult.pretender>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!weretis.net!feeder2.news.weretis.net!feeder.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
References: <m2d41p7sho.fsf@consult.pretender> <hhti24$9ua$1@scotsman.ed.ac.uk> <m2tyv15eaz.fsf@consult.pretender> <hhv7u9$bf4$1@scotsman.ed.ac.uk> <m2iqbg5zjg.fsf@consult.pretender> <hi0018$1gk$1@north.jnrs.ja.net> <m21vi45kxy.fsf@consult.pretender> <hi0e67$5b2$1@north.jnrs.ja.net> <m2tyv03yq9.fsf@consult.pretender> <m2pr5o3ycq.fsf@consult.pretender> <m2ljgc3xd3.fsf@consult.pretender> <hi2c72$l5i$1@north.jnrs.ja.net> <m2ocl7yvsr.fsf@consult.pretender> <hi4d25$81f$1@north.jnrs.ja.net> <m24omxzybc.fsf@consult.pretender> <hi54kr$euu$1@north.jnrs.ja.net> <m2r5q1ybz4.fsf@consult.pretender> <m2my0pybcx.fsf@consult.pretender> <hi5peg$kmp$1@north.jnrs.ja.net> <m2iqbdxbuj.fsf@consult.pretender> <hi73bg$1cs$1@north.jnrs.ja.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: a16957f451,747cd7667796b3e3
X-Google-Attributes: gida16957f451,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!weretis.net!feeder2.news.weretis.net!feeder.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: blueman <NOSPAM@nospam.com>
Newsgroups: gnu.emacs.vm.bug
Subject: PLEASE TRY THIS PATCH
Date: Fri, 08 Jan 2010 11:50:32 -0500
Organization: A noiseless patient Spider
Lines: 175
Message-ID: <m2aawownfr.fsf_-_@consult.pretender>
References: <m2d41p7sho.fsf@consult.pretender>
 <hhti24$9ua$1@scotsman.ed.ac.uk> <m2tyv15eaz.fsf@consult.pretender>
 <hhv7u9$bf4$1@scotsman.ed.ac.uk> <m2iqbg5zjg.fsf@consult.pretender>
 <hi0018$1gk$1@north.jnrs.ja.net> <m21vi45kxy.fsf@consult.pretender>
 <hi0e67$5b2$1@north.jnrs.ja.net> <m2tyv03yq9.fsf@consult.pretender>
 <m2pr5o3ycq.fsf@consult.pretender> <m2ljgc3xd3.fsf@consult.pretender>
 <hi2c72$l5i$1@north.jnrs.ja.net> <m2ocl7yvsr.fsf@consult.pretender>
 <hi4d25$81f$1@north.jnrs.ja.net> <m24omxzybc.fsf@consult.pretender>
 <hi54kr$euu$1@north.jnrs.ja.net> <m2r5q1ybz4.fsf@consult.pretender>
 <m2my0pybcx.fsf@consult.pretender> <hi5peg$kmp$1@north.jnrs.ja.net>
 <m2iqbdxbuj.fsf@consult.pretender> <hi73bg$1cs$1@north.jnrs.ja.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Fri, 8 Jan 2010 16:50:34 +0000 (UTC)
Injection-Info: feeder.eternal-september.org; posting-host="o0xooYC/dlyFpPxuXQpbEw";
 logging-data="1330"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Wjczx5TYEe9Ctx4LK7aFez4lvJKyJ9AM="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock: sha1:a2YcSvbDu8DKhy0IR5rNWCVuFVk=
 sha1:V9dEOLYLtKHt5OpWa+UE2JHuZL8=