all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 13831@debbugs.gnu.org
Subject: bug#13831: 24.3.50; [PATCH] net-utils-mode have no revert-buffer function
Date: Wed, 13 Mar 2013 21:12:54 +0100	[thread overview]
Message-ID: <87ehfjxdmh.fsf@gmail.com> (raw)
In-Reply-To: <jwvr4jj193r.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 13 Mar 2013 13:52:23 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> 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 





  reply	other threads:[~2013-03-13 20:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27  9:30 bug#13831: 24.3.50; [PATCH] net-utils-mode have no revert-buffer function Thierry Volpiatto
2013-02-27  9:48 ` Thierry Volpiatto
2013-02-27 10:11   ` Andreas Schwab
2013-02-27 10:50     ` Thierry Volpiatto
2013-02-27 11:57       ` Andreas Schwab
2013-02-27 12:03         ` Thierry Volpiatto
2013-02-27 14:08       ` Stefan Monnier
2013-02-27 14:35         ` Thierry Volpiatto
2013-02-27 15:25           ` Stefan Monnier
2013-02-27 16:36             ` Thierry Volpiatto
2013-02-28  4:51               ` Stefan Monnier
2013-02-28  6:18                 ` Thierry Volpiatto
2013-02-28 14:04                   ` Stefan Monnier
2013-02-28 19:45                     ` Thierry Volpiatto
2013-03-01  3:05                       ` Stefan Monnier
2013-03-01  7:02                         ` Thierry Volpiatto
2013-03-01 14:29                           ` Stefan Monnier
2013-03-01 15:22                             ` Thierry Volpiatto
2013-03-01 17:28                               ` Stefan Monnier
2013-03-01 19:07                             ` Thierry Volpiatto
2013-03-11 18:31                               ` Stefan Monnier
2013-03-13 14:43                                 ` Thierry Volpiatto
2013-03-13 17:52                                   ` Stefan Monnier
2013-03-13 20:12                                     ` Thierry Volpiatto [this message]
2013-03-03  6:16                             ` Thierry Volpiatto
2013-03-01 14:30                           ` Thierry Volpiatto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ehfjxdmh.fsf@gmail.com \
    --to=thierry.volpiatto@gmail.com \
    --cc=13831@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.