[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

prepend time stamp for every line in telnet-mode

From: stianse
Subject: prepend time stamp for every line in telnet-mode
Date: Thu, 24 Jan 2008 13:30:19 -0800 (PST)
User-agent: G2/1.0

Hi, I'm trying to figure out how to prepend each line that is printed
in a telnet session with a time stamp (with at least millisecond
precision). I figured out a function to format such a time stamp,
although it may not be the most elegant solution.

(defun prepend-current-time-to-string (str)
  (interactive "s")
  (concat "[" (int-to-string (car  (current-time)))
          (int-to-string (car (cdr (current-time))))
          ":" (int-to-string (nth 2 (current-time)))
          "] " str))

After looking in telnet.el and comint.el I get the impression that
telnet-mode uses comint-mode, and that it would be possible to use
comint-preoutput-filter-functions to preprocess the string that is
displayed in the buffer. However, it does not work as expected. The
following line does nothing for M-x telnet, but works for M-x shell
(although I don't want it to, but first things first).

(add-hook 'comint-preoutput-filter-functions
            'prepend-current-time-to-string nil t)

Any suggestions?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]