From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#13831: 24.3.50; [PATCH] net-utils-mode have no revert-buffer function Date: Wed, 27 Feb 2013 11:50:42 +0100 Organization: Emacs Helm Message-ID: <87d2vmm3nh.fsf@gmail.com> References: <87liaam7dh.fsf@gmail.com> <87hakym6il.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1361962280 16332 80.91.229.3 (27 Feb 2013 10:51:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Feb 2013 10:51:20 +0000 (UTC) To: 13831@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 27 11:51:42 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UAebt-0008I7-6f for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 11:51:41 +0100 Original-Received: from localhost ([::1]:39363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAebY-00036d-Cz for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 05:51:20 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAebU-000321-M4 for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 05:51:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAebR-0007Wr-4C for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 05:51:14 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAebQ-0007Wb-Tn for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 05:51:13 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UAedC-00006v-9A for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 05:53:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87liaam7dh.fsf@gmail.com> Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Feb 2013 10:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13831 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1361962381417 (code B ref -1); Wed, 27 Feb 2013 10:53:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Feb 2013 10:53:01 +0000 Original-Received: from localhost ([127.0.0.1]:52693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAedA-00006d-9R for submit@debbugs.gnu.org; Wed, 27 Feb 2013 05:53:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57984) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAed8-00006X-BB for submit@debbugs.gnu.org; Wed, 27 Feb 2013 05:52:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAebI-0007NS-Lw for submit@debbugs.gnu.org; Wed, 27 Feb 2013 05:51:08 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:48205) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAebI-0007N7-IR for submit@debbugs.gnu.org; Wed, 27 Feb 2013 05:51:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAebE-0002Wv-H4 for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 05:51:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAebA-0007Em-92 for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 05:51:00 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:59220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAeb9-0007EL-U2 for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 05:50:56 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UAebQ-0007wN-EM for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 11:51:12 +0100 Original-Received: from lbe83-2-78-243-104-167.fbx.proxad.net ([78.243.104.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Feb 2013 11:51:12 +0100 Original-Received: from thierry.volpiatto by lbe83-2-78-243-104-167.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Feb 2013 11:51:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 150 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lbe83-2-78-243-104-167.fbx.proxad.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:shGvn33Bx0uC8/JtdP7AcIbBrd0= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:71902 Archived-At: Andreas Schwab writes: > Thierry Volpiatto writes: > >> diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el >> index 28fd5c6..3a20add 100644 >> --- a/lisp/net/net-utils.el >> +++ b/lisp/net/net-utils.el >> @@ -1,3 +1,5 @@ >> + >> +Process nil processus arrĂȘtĂ© > > error: (void-variable Process) Yes sorry, fixed. >> @@ -369,6 +377,31 @@ This variable is only used if the variable >> (goto-char (point-min))) >> (display-buffer buffer-name)) >> >> +(defun net-utils-revert-function (&optional ignore-auto noconfirm) >> + (message "Reverting `%s'..." (buffer-name)) >> + (let ((inhibit-read-only t)) >> + (erase-buffer) >> + (set-process-filter >> + (apply 'start-process (format "%s" net-utils-program-name) > ^^^^^^^^^^^^ > > That's a no-op. Fixed. >> + (buffer-name) net-utils-program-name net-utils-program-args) >> + #'(lambda (process output-string) >> + (let ((filtered-string output-string)) >> + (set-buffer (process-buffer process)) >> + (let ((inhibit-read-only t)) >> + (while (string-match "\r" filtered-string) >> + (setq filtered-string >> + (replace-match "" nil nil filtered-string))) >> + (save-excursion >> + ;; Insert the text, moving the process-marker. >> + (goto-char (process-mark process)) >> + (insert filtered-string) >> + (set-marker (process-mark process) (point))))))) >> + (set-process-sentinel >> + (get-process net-utils-program-name) > > There is no guarantee that a process with this name exists. Where ? in the sentinel ? The process take this name in `net-utils-run-simple': --8<---------------cut here---------------start------------->8--- (set (make-local-variable 'net-utils-program-name) program-name) (set (make-local-variable 'net-utils-program-args) args) (set-process-filter (apply 'start-process (format "%s" program-name) --8<---------------cut here---------------end--------------->8--- I have also removed (interactive) in this same function which was wrong IMO. Here the corrected patch: diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el index 28fd5c6..83b3268 100644 --- a/lisp/net/net-utils.el +++ b/lisp/net/net-utils.el @@ -285,7 +285,10 @@ This variable is only used if the variable (define-derived-mode net-utils-mode special-mode "NetworkUtil" "Major mode for interacting with an external network utility." (set (make-local-variable 'font-lock-defaults) - '((net-utils-font-lock-keywords)))) + '((net-utils-font-lock-keywords))) + (set (make-local-variable 'revert-buffer-function) + 'net-utils-revert-function) + (define-key net-utils-mode-map (kbd "g") 'revert-buffer)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Utility functions @@ -354,14 +357,17 @@ This variable is only used if the variable ;; General network utilities (diagnostic) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defvar net-utils-program-name nil) +(defvar net-utils-program-args nil) (defun net-utils-run-simple (buffer-name program-name args) "Run a network utility for diagnostic output only." - (interactive) (when (get-buffer buffer-name) (kill-buffer buffer-name)) (get-buffer-create buffer-name) (with-current-buffer buffer-name (net-utils-mode) + (set (make-local-variable 'net-utils-program-name) program-name) + (set (make-local-variable 'net-utils-program-args) args) (set-process-filter (apply 'start-process (format "%s" program-name) buffer-name program-name args) @@ -369,6 +375,33 @@ This variable is only used if the variable (goto-char (point-min))) (display-buffer buffer-name)) +(defun net-utils-revert-function (&optional ignore-auto noconfirm) + (message "Reverting `%s'..." (buffer-name)) + (let ((proc (get-process net-utils-program-name))) + (when proc (set-process-filter proc t) (delete-process proc))) + (let ((inhibit-read-only t)) + (erase-buffer) + (set-process-filter + (apply 'start-process net-utils-program-name + (buffer-name) net-utils-program-name net-utils-program-args) + #'(lambda (process output-string) + (let ((filtered-string output-string)) + (set-buffer (process-buffer process)) + (let ((inhibit-read-only t)) + (while (string-match "\r" filtered-string) + (setq filtered-string + (replace-match "" nil nil filtered-string))) + (save-excursion + ;; Insert the text, moving the process-marker. + (goto-char (process-mark process)) + (insert filtered-string) + (set-marker (process-mark process) (point))))))) + (set-process-sentinel + (get-process net-utils-program-name) + #'(lambda (process event) + (when (string= event "finished\n") + (message "reverting `%s' done" (buffer-name))))))) + ;;;###autoload (defun ifconfig () "Run ifconfig and display diagnostic output." @@ -428,9 +461,8 @@ This variable is only used if the variable (if traceroute-program-options (append traceroute-program-options (list target)) (list target)))) - (net-utils-run-program + (net-utils-run-simple (concat "Traceroute" " " target) - (concat "** Traceroute ** " traceroute-program " ** " target) traceroute-program options))) -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997