Re: How to make emacs display the warning messages which appear on tty1

Madhu via Users list for the GNU Emacs text editor <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
* BP25 <[email protected]> :
Wrote on Mon, 30 Mar 2026 10:12:10 +0000:

> One thing at a time: how about channeling all such messages (the ones
> in tty12) into the *Messages* buffer. And  after, the ones in tty1
> (urgent messages) into the echo area.

This is how I'd do it if I had to clobber something up quickly

You ask your syslog daemon to send the syslog messages to some pipe
traditionally I prefer /dev/xconsole.

my /etc/rsyslog.d/15-xconsole.conf (in the sysklogd syntax) to send
all messages to /dev/xconsole in addition to tty8

*.* |/dev/xconsole
*.* |/dev/tty8

ls -l /dev/xconsole
prw-rw-rw- 1 root root 0 Apr  7 21:49 /dev/xconsole

you may have to use opentmpfiles to create it:

mknod -m 0666 /dev/xconsole p
chown root:tty /dev/xconsole

Then if rsyslog is sending messages to /dev/xconsole you can read it
on stdout with
socat PIPE:/dev/xconsole -

I'd run socat as a subprocess of emacs (instead of reading it directly)

;;  -*- lexical-binding: t -*-

(defvar-local xconsole-process-output nil "Partial output")

(defvar xconsole-buffer-name "*xconsole*")

(defun xconsole-process-filter (proc string) ;adapted from elisp.info
  (when (buffer-live-p (process-buffer proc))
    (with-current-buffer (process-buffer proc)
      (let ((moving (= (point) (process-mark proc))))
	(save-excursion
	  ;; Insert the text, advancing the process marker.
	  (goto-char (process-mark proc))
	  (insert string)
	  (set-marker (process-mark proc) (point)))
	(if moving (goto-char (process-mark proc))))
      (setq xconsole-process-output
	    (concat xconsole-process-output string))
      (when (= ?\n (aref xconsole-process-output
			 (1- (length xconsole-process-output))))
	(let ((lines (split-string xconsole-process-output "[\n\r]" t)))
	  (setq xoncole-process-output nil)
	  (dolist (line lines)
	    (message "On Xconsole: %s" line)))))))

(defun xconsole-process-sentiel(proc string)
  (with-current-buffer (process-buffer proc)
    (goto-char (process-mark proc))
    (insert "\nXconsole process ended at " (current-time-string) "\n\n")
    (message "Xconsole exited")))

(defun open-xconsole ()
  (interactive)
  (let* ((xconsole-buffer (get-buffer-create xconsole-buffer-name))
	 (proc (get-buffer-process xconsole-buffer)))
    (pop-to-buffer xconsole-buffer)
    (cond ((and proc (memq (process-status process) '(open run))) t)
	  (t ;; (syslog-mode)
	   (or (setq proc (start-process "xconsole" "*xconsole*"
					 "socat" "PIPE:/dev/xconsole" "-"))
	       (error "xconsole: couldn't open xconsole"))
	   (set-process-sentinel proc #'xconsole-process-sentiel)
	   (set-process-filter proc #'xconsole-process-filter)
	   (insert "XConsole Started at " (current-time-string) "\n")))))


M-x open-xconsole will run the socat process, all syslog output goes to
the "*xconsole*" buffer, in addition, each line is echoed in the message
area with (message).  This may get too chatty..
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.