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, 13 Mar 2013 21:12:54 +0100 Organization: Emacs Helm Message-ID: <87ehfjxdmh.fsf@gmail.com> References: <87liaam7dh.fsf@gmail.com> <87hakym6il.fsf@gmail.com> <87d2vmm3nh.fsf@gmail.com> <871uc1ese2.fsf@gmail.com> <87k3ptbtoj.fsf@gmail.com> <877gltm05y.fsf@gmail.com> <87vc9cgr2i.fsf@gmail.com> <87zjyny54l.fsf@gmail.com> <87ppzjj5va.fsf@gmail.com> <87d2v39x7f.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363205646 31113 80.91.229.3 (13 Mar 2013 20:14:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Mar 2013 20:14:06 +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 Mar 13 21:14:28 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 1UFs46-0000E3-Vu for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Mar 2013 21:14:23 +0100 Original-Received: from localhost ([::1]:54194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFs3k-00057L-9S for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Mar 2013 16:14:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFs3g-00057D-NY for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 16:13:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFs3f-0002LE-8H for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 16:13:56 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFs3f-0002L5-4a for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 16:13:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UFs4j-0000hO-U2 for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2013 16:15:01 -0400 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, 13 Mar 2013 20:15: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 Original-Received: via spool by 13831-submit@debbugs.gnu.org id=B13831.13632056562620 (code B ref 13831); Wed, 13 Mar 2013 20:15:01 +0000 Original-Received: (at 13831) by debbugs.gnu.org; 13 Mar 2013 20:14:16 +0000 Original-Received: from localhost ([127.0.0.1]:51914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFs40-0000gD-30 for submit@debbugs.gnu.org; Wed, 13 Mar 2013 16:14:16 -0400 Original-Received: from mail-ea0-f178.google.com ([209.85.215.178]:63609) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFs3y-0000fu-21 for 13831@debbugs.gnu.org; Wed, 13 Mar 2013 16:14:15 -0400 Original-Received: by mail-ea0-f178.google.com with SMTP id g14so649989eak.23 for <13831@debbugs.gnu.org>; Wed, 13 Mar 2013 13:13:01 -0700 (PDT) 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=qzBeGb/EZqXuLm7BvH6D8Oud24ynigHD8x0bj2Qok0c=; b=DnPT1haEpuMwNpi+c5Xxy7J5WU/LYrnzAzOOoSebMzCXQSq9gaX9xmEPgXGlDj7m9u zUPaqsG7cMhv80J9Eoqz6/7szqyoBaHd3JrP65iV3/cvfSzNO3gBU0zlBNUfWtVBbNHh yqugr7jC1V+yShOxSClyHp74FhUv3wiVAwUuZPqpIaJaqicnDuaSbtQjStOkOK30mwYP YRz457kc0QP7PBkivgiJb8jxGFFAitLriOp0/K48kuWMP/+fSh88FbIEJngEW0MTquGk ZHmIwx8MJBXOKM0hynPFjtORTIZ5eGw1IbhkT8aOkdhrxlW4DL9kaGUhH3eIhfnxodCN I7yg== X-Received: by 10.14.184.68 with SMTP id r44mr29203963eem.40.1363205581105; Wed, 13 Mar 2013 13:13:01 -0700 (PDT) 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 44sm38118058eek.5.2013.03.13.13.12.58 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 13 Mar 2013 13:13:00 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Wed, 13 Mar 2013 13:52:23 -0400") 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:72431 Archived-At: Stefan Monnier writes: >> I think actually it is not a problem loading ffap when needed: >> --8<---------------cut here---------------start------------->8--- >> (defun net-utils-machine-at-point () >> (require 'ffap) >> (ffap-machine-at-point)) >> (defun net-utils-url-at-point () >> (require 'ffap) >> (ffap-url-at-point)) >> --8<---------------cut here---------------end--------------->8--- >> This reduce code and do the right thing. > > We can even (require 'ffap) at top-level. It's not that big of a deal. Ok. >> I can send a patch if ok. > > Please do, I didn't use `ffap-machine-at-point' because it is hanging forever when called on e.g www.google.fr. Don't know if it is a bug or the expected behavior (I doubt of this according to its docstring). --8<---------------cut here---------------start------------->8--- (net-utils-machine-at-point, net-utils-url-at-point): Use `ffap-string-at-point'. (ping): Use localhost as default input if no machine at point. Use `net-utils-run-simple'. (run-dig): Use `net-utils-run-simple'. --8<---------------cut here---------------end--------------->8--- diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el index 9a6c7b1..6155f5b 100644 --- a/lisp/net/net-utils.el +++ b/lisp/net/net-utils.el @@ -44,6 +44,8 @@ ;;; Code: +(require 'ffap) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Customization Variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -287,30 +289,15 @@ This variable is only used if the variable ;; Utility functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Simplified versions of some at-point functions from ffap.el. -;; It's not worth loading all of ffap just for these. (defun net-utils-machine-at-point () - (let ((pt (point))) - (buffer-substring-no-properties - (save-excursion - (skip-chars-backward "-a-zA-Z0-9.") - (point)) - (save-excursion - (skip-chars-forward "-a-zA-Z0-9.") - (skip-chars-backward "." pt) - (point))))) + "Return a string of characters from around point. +Same as `ffap-string-at-point' called with 'machine as arg." + (ffap-string-at-point 'machine)) (defun net-utils-url-at-point () - (let ((pt (point))) - (buffer-substring-no-properties - (save-excursion - (skip-chars-backward "--:=&?$+@-Z_a-z~#,%") - (skip-chars-forward "^A-Za-z0-9" pt) - (point)) - (save-excursion - (skip-chars-forward "--:=&?$+@-Z_a-z~#,%") - (skip-chars-backward ":;.,!?" pt) - (point))))) + "Return a string of characters from around point. +Same as `ffap-string-at-point' called with 'url as arg." + (ffap-string-at-point 'url)) (defun net-utils-remove-ctrl-m-filter (process output-string) "Remove trailing control Ms." @@ -445,14 +432,14 @@ This variable is only used if the variable If your system's ping continues until interrupted, you can try setting `ping-program-options'." (interactive - (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point)))) + (list (read-from-minibuffer "Ping host: " (or (net-utils-machine-at-point) + "localhost")))) (let ((options - (if ping-program-options - (append ping-program-options (list host)) - (list host)))) - (net-utils-run-program + (if ping-program-options + (append ping-program-options (list host)) + (list host)))) + (net-utils-run-simple (concat "Ping" " " host) - (concat "** Ping ** " ping-program " ** " host) ping-program options))) @@ -535,13 +522,12 @@ If your system's ping continues until interrupted, you can try setting (interactive (list (read-from-minibuffer "Lookup host: " - (or (ffap-string-at-point 'machine) "")))) - (net-utils-run-program - "Dig" + (net-utils-machine-at-point)))) + (net-utils-run-simple (concat "** " - (mapconcat 'identity - (list "Dig" host dig-program) - " ** ")) + (mapconcat 'identity + (list "Dig" host dig-program) + " ** ")) dig-program (list host))) -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997