GNU bug report logs -
#13831
24.3.50; [PATCH] net-utils-mode have no revert-buffer function
Previous Next
Full log
Message #32 received at 13831 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> IRO.UMontreal.CA> 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
This bug report was last modified 12 years and 69 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.