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 17:36:12 +0100 Organization: Emacs Helm Message-ID: <87k3ptbtoj.fsf@gmail.com> References: <87liaam7dh.fsf@gmail.com> <87hakym6il.fsf@gmail.com> <87d2vmm3nh.fsf@gmail.com> <871uc1ese2.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361983075 32276 80.91.229.3 (27 Feb 2013 16:37:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Feb 2013 16:37:55 +0000 (UTC) Cc: 13831@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 27 17:38:16 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 1UAk1G-0006xP-NG for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 17:38:14 +0100 Original-Received: from localhost ([::1]:39417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAk0s-0004iV-Cb for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 11:37:50 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAk0h-0004hi-JR for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 11:37:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAk0K-0002wH-HK for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 11:37:34 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAk0J-0002v7-B6 for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 11:37:16 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UAk22-0000c3-HE for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 11:39:02 -0500 X-Loop: help-debbugs@gnu.org 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 16:39: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 Original-Received: via spool by 13831-submit@debbugs.gnu.org id=B13831.13619831022306 (code B ref 13831); Wed, 27 Feb 2013 16:39:02 +0000 Original-Received: (at 13831) by debbugs.gnu.org; 27 Feb 2013 16:38:22 +0000 Original-Received: from localhost ([127.0.0.1]:53752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAk1M-0000b7-2y for submit@debbugs.gnu.org; Wed, 27 Feb 2013 11:38:20 -0500 Original-Received: from mail-ee0-f46.google.com ([74.125.83.46]:37364) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAk1I-0000ax-0d for 13831@debbugs.gnu.org; Wed, 27 Feb 2013 11:38:17 -0500 Original-Received: by mail-ee0-f46.google.com with SMTP id e49so691256eek.33 for <13831@debbugs.gnu.org>; Wed, 27 Feb 2013 08:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:organization:references:date :in-reply-to:message-id:user-agent:mime-version:content-type; bh=z+WjQKt7se8Y0UnzMFan8AAbnjwjePZ88QBAyHMmn+o=; b=yZNyASAoLtWuA2yhahRaaxhpDelaQBuajuicDQc2y9f3GjmJzbcgfuJL14tM+M/XE4 cQtOzJ2YvP0SABYUzaHkYUmQJbt3bmhnkYzUji8p0vYqbAWaeAbBb1wFLgo88tGjRo1O qwoC97mDgGbknj4mGpdCP+WugV9Jl/yTF9M5vCde/1cTruiogBd5uyjgUru4O0agTRm9 K0+ZP2RO3BB7S9yf3rkSCfwnmTLjMDDK6/tdgZIHTJ3mAJOxIsRx60zUOl4LOWRuIw7E cCCzeAY/4RKhGxI6sAJzUzL+4il2wtICuBakVzy0kAojoA1DahP2s9tIIoT0fnNgGeqj WxAA== X-Received: by 10.14.193.134 with SMTP id k6mr7561485een.37.1361982983898; Wed, 27 Feb 2013 08:36:23 -0800 (PST) Original-Received: from dell-14z (lbe83-2-78-243-104-167.fbx.proxad.net. [78.243.104.167]) by mx.google.com with ESMTPS id 3sm7304155eej.6.2013.02.27.08.36.20 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 27 Feb 2013 08:36:22 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Wed, 27 Feb 2013 10:25:42 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) 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:71917 Archived-At: Stefan Monnier writes: >> Thanks Stefan, it is what I understood and it was fixed. > > Good. Do you still need help installing it (if so, please resend the > patch because I haven't seen the updated version)? Yes please, I only have a git repo of Emacs now. Here the patch modified again, tested with netstat. Let me know if you find something wrong. You will find a (format "%s" program-name), it was here I don't know why, I leave it, but it can probably be removed. Also `net-utils-run-simple' was interactive with no arguments provided interactively, which was wrong, I removed it. Many functions are actually using `net-utils-run-program' and will not have `revert-buffer' enabled, I corrected only `trace-route', but others could be modified, that can be done later, it will be easy. Thanks. diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el index 28fd5c6..db5637b 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,21 +357,56 @@ This variable is only used if the variable ;; General network utilities (diagnostic) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defvar net-utils-program-name nil) +(defvar net-utils-program-args nil) +(defvar net-utils-mode-process 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-process-filter - (apply 'start-process (format "%s" program-name) - buffer-name program-name args) - 'net-utils-remove-ctrl-m-filter) + (set (make-local-variable 'net-utils-program-name) program-name) + (set (make-local-variable 'net-utils-program-args) args) + (set (make-local-variable 'net-utils-mode-process) + (apply 'start-process (format "%s" program-name) + buffer-name program-name args)) + (set-process-filter net-utils-mode-process + 'net-utils-remove-ctrl-m-filter) (goto-char (point-min))) (display-buffer buffer-name)) +(defun net-utils-revert-function (&optional ignore-auto noconfirm) + (message "Reverting `%s'..." (buffer-name)) + (when net-utils-mode-process + (set-process-filter net-utils-mode-process t) + (delete-process net-utils-mode-process)) + (let ((inhibit-read-only t)) + (erase-buffer) + (setq net-utils-mode-process (apply 'start-process net-utils-program-name + (buffer-name) net-utils-program-name + net-utils-program-args)) + (set-process-filter + net-utils-mode-process + #'(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 + net-utils-mode-process + #'(lambda (process event) + (when (string= event "finished\n") + (message "Reverting `%s' done" (process-buffer process)))))))) + ;;;###autoload (defun ifconfig () "Run ifconfig and display diagnostic output." @@ -428,9 +466,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