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 10:48:50 +0100 Organization: Emacs Helm Message-ID: <87hakym6il.fsf@gmail.com> References: <87liaam7dh.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 1361958558 13596 80.91.229.3 (27 Feb 2013 09:49:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Feb 2013 09:49:18 +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 10:49:40 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 1UAddr-0002LJ-1E for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 10:49:39 +0100 Original-Received: from localhost ([::1]:39534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAddW-0004nA-7u for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 04:49:18 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAddS-0004mo-Do for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 04:49:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAddQ-0000Ug-Nv for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 04:49:14 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47162) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAddQ-0000Ua-KQ for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 04:49:12 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UAdfB-00079r-RL for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 04:51:01 -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 09:51:01 +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.136195866027507 (code B ref -1); Wed, 27 Feb 2013 09:51:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Feb 2013 09:51:00 +0000 Original-Received: from localhost ([127.0.0.1]:52626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAdfA-00079b-Au for submit@debbugs.gnu.org; Wed, 27 Feb 2013 04:51:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:38427) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAdf7-00079U-Ur for submit@debbugs.gnu.org; Wed, 27 Feb 2013 04:50:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAddH-0000Tx-7x for submit@debbugs.gnu.org; Wed, 27 Feb 2013 04:49:08 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:49107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAddH-0000Tt-4a for submit@debbugs.gnu.org; Wed, 27 Feb 2013 04:49:03 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAddF-0004kx-IZ for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 04:49:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAddE-0000Te-Ac for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 04:49:01 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:35341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAddE-0000Sl-3g for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 04:49:00 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UAddX-0002CM-OW for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 10:49:19 +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 10:49:19 +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 10:49:19 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 95 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:rgEVVaP920Kco+rd4kzEkQL9+f0= 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:71898 Archived-At: Thierry Volpiatto writes: > Hello, > net-utils-mode have no revert-buffer function. > This patch allow using "g" in e.g "*netstat*" buffer. 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Ă© ;;; net-utils.el --- network functions ;; Copyright (C) 1998-2013 Free Software Foundation, Inc. @@ -285,7 +287,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 +359,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 +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) + (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