[gnus git] branch master updated: m0-1-109-g87e2f61 =2= Add more protection ; Output text from external commands in the article buffer

Lars Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  87e2f61d051414fdc3fb4235570411b89785e9cf (commit)
       via  dce35658e5d9aebb1509d691e0de256c1511854b (commit)
      from  d38bed32440e3c3b979152602f37d6d2d5e0fa36 (commit)


- Log -----------------------------------------------------------------
commit 87e2f61d051414fdc3fb4235570411b89785e9cf
Author: Lars Ingebrigtsen <[email protected]>
Date:   Thu Feb 9 22:24:55 2012 +0100

    Add more protection

diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el
index dc29718..6ec226f 100644
--- a/lisp/mm-decode.el
+++ b/lisp/mm-decode.el
@@ -945,6 +945,7 @@ external if displayed external."
 			   (condition-case nil
 			       (delete-directory (file-name-directory file))
 			     (error))
+			   (when (buffer-live-p outbuf)
 			   (with-current-buffer outbuf
 			     (let ((buffer-read-only nil)
 				   (point (point)))
@@ -952,8 +953,9 @@ external if displayed external."
 			       (mm-insert-inline
 				handle (with-current-buffer buffer
 					 (buffer-string)))
-			       (goto-char point)))
-			   (kill-buffer buffer))
+				 (goto-char point))))
+			   (when (buffer-live-p buffer)
+			     (kill-buffer buffer)))
 			 (message "Displaying %s...done" command)))))
 		(mm-handle-set-external-undisplayer
 		 handle (cons file buffer)))

commit dce35658e5d9aebb1509d691e0de256c1511854b
Author: Lars Ingebrigtsen <[email protected]>
Date:   Thu Feb 9 22:24:04 2012 +0100

    Output text from external commands in the article buffer
    
    * gnus-compat.el: Define `timer-set-function'.
    
    * mm-decode.el (mm-display-external): Output the text from the command
    in the buffer after the command finished.  This makes text-based
    commands behave better.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ba99578..6cf2f0c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2012-02-09  Lars Ingebrigtsen  <[email protected]>
+
+	* gnus-compat.el: Define `timer-set-function'.
+
+	* mm-decode.el (mm-display-external): Output the text from the command
+	in the buffer after the command finished.  This makes text-based
+	commands behave better.
+
 2012-02-08  Lars Ingebrigtsen  <[email protected]>
 
 	* gnus-compat.el: Add a compat for the old `url-retrieve'.
diff --git a/lisp/gnus-compat.el b/lisp/gnus-compat.el
index fd41df4..1307488 100644
--- a/lisp/gnus-compat.el
+++ b/lisp/gnus-compat.el
@@ -86,6 +86,17 @@ TRASH is ignored."
     (funcall gnus-compat-original-url-retrieve
 	     url callback cbargs silent)))
 
+;; XEmacs
+(when (and (not (fboundp 'timer-set-function))
+	   (fboundp 'set-itimer-function))
+  (defun timer-set-function (timer function &optional args)
+    "Make TIMER call FUNCTION with optional ARGS when triggering."
+    (lexical-let ((function function)
+		  (args args))
+      (set-itimer-function timer
+			   (lambda (process status)
+			     (apply function process status args))))))
+
 (provide 'gnus-compat)
 
 ;; gnus-compat.el ends here
diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el
index 3b3695b..dc29718 100644
--- a/lisp/mm-decode.el
+++ b/lisp/mm-decode.el
@@ -925,46 +925,36 @@ external if displayed external."
 				   shell-command-switch command)
 		    (set-process-sentinel
 		     (get-buffer-process buffer)
-		     (lexical-let ;; Don't use `let'.
-			 ;; Function used to remove temp file and directory.
-			 ((fn `(lambda nil
-				 ;; Don't use `ignore-errors'.
+		     (lexical-let ((outbuf outbuf)
+				   (file file)
+				   (buffer buffer)
+				   (command command)
+				   (handle handle))
+		       (run-at-time
+			30.0 nil
+			(lambda ()
+			  (ignore-errors
+			    (delete-file file))
+			  (ignore-errors
+			    (delete-directory (file-name-directory file)))))
+		       (lambda (process state)
+			 (when (eq (process-status process) 'exit)
 				 (condition-case nil
-				     (delete-file ,file)
+			       (delete-file file)
 				   (error))
 				 (condition-case nil
-				     (delete-directory
-				      ,(file-name-directory file))
-				   (error))))
-			  ;; Form uses to kill the process buffer and
-			  ;; remove the undisplayer.
-			  (fm `(progn
-				 (kill-buffer ,buffer)
-				 ,(macroexpand
-				   (list 'mm-handle-set-undisplayer
-					 (list 'quote handle)
-					 nil))))
-			  ;; Message to be issued when the process exits.
-			  (done (format "Displaying %s...done" command))
-			  ;; In particular, the timer object (which is
-			  ;; a vector in Emacs but is a list in XEmacs)
-			  ;; requires that it is lexically scoped.
-			  (timer (run-at-time 30.0 nil 'ignore)))
-		       (if (featurep 'xemacs)
-			   (lambda (process state)
-			     (when (eq 'exit (process-status process))
-			       (if (memq timer itimer-list)
-				   (set-itimer-function timer fn)
-				 (funcall fn))
-			       (ignore-errors (eval fm))
-			       (message "%s" done)))
-			 (lambda (process state)
-			   (when (eq 'exit (process-status process))
-			     (if (memq timer timer-list)
-				 (timer-set-function timer fn)
-			       (funcall fn))
-			     (ignore-errors (eval fm))
-			     (message "%s" done)))))))
+			       (delete-directory (file-name-directory file))
+			     (error))
+			   (with-current-buffer outbuf
+			     (let ((buffer-read-only nil)
+				   (point (point)))
+			       (forward-line 2)
+			       (mm-insert-inline
+				handle (with-current-buffer buffer
+					 (buffer-string)))
+			       (goto-char point)))
+			   (kill-buffer buffer))
+			 (message "Displaying %s...done" command)))))
 		(mm-handle-set-external-undisplayer
 		 handle (cons file buffer)))
 	      (message "Displaying %s..." command))

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog      |    8 +++++
 lisp/gnus-compat.el |   11 ++++++++
 lisp/mm-decode.el   |   72 ++++++++++++++++++++++----------------------------
 3 files changed, 51 insertions(+), 40 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.