Subject: 28.0.92; rcirc channel-vs-log buffer confusion
From: Ken Raeburn <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Mon, 04 Apr 2022 18:34:37 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

I’m using rcirc, and have logging turned on.   When I started up 
rcirc, I already had one of the log files 
(~/.emacs.d/rcirc-log/[email-masked]) being viewed in a 
buffer. That buffer, sensibly enough, was named 
“[email-masked]”.   Once rcirc connected to irc.gnome.org, 
and joined my channels, it looked for a buffer named 
“[email-masked]”, assumed that that was its own buffer for 
showing channel messages, switched it to rcirc mode, and started 
adding to it. So now, the buffer starts off: 
 
    2022-04-04T18:01:18 *** raeburn JOIN
    2022-04-04T18:01:18 *** ChanServ MODE +v raeburn
    2022-04-04T18:01:18 *** TOPIC Free GPL Personal and Small Business 
Accounting…
    2022-04-04T18:01:18 *** NAMES …
    2021-11-01T13:49:16 *** sbluhm JOIN 
    2021-11-01T13:50:25 *** Mechtilde QUIT Ping timeout: 180 seconds
    2021-11-01T14:10:13 *** jervin QUIT Quit: jervin

There hasn’t been any new message traffic since I joined, but it appears
that if I use a command like C-c C-n, the NAMES output gets appended to
the block at the beginning of the buffer. (I’m wary of trying to send a
message myself, as I’m not sure how much of the buffer will be taken as
my message in this weird state — just the line I type, or everything
after the apparent insertion point?)

I think I got into this state after restarting Emacs a couple of times
today, because I had been looking at the #gnucash log in a buffer, and
am using desktop save mode.  The .emacs.desktop file doesn’t save the
uniquified buffer name, apparently.  (My current .emacs.desktop has two
entries for buffers to be called “workQueue.c” for files by that name in
different directories.)  After the takeover of the buffer for use by
rcirc mode, the buffer-file-name is still set, so that info can be saved
away.

This also resulted in a message logged at startup time — the saved info
on the #gnucash buffer said it was in rcirc-mode, which causes
rcirc-mode to be invoked in the “restored” buffer with no arguments, but
rcirc-mode requires exactly two arguments, unlike normal mode functions.

Load the desktop file the first time, even if rcirc is running, and the
saved desktop will add the file buffer to the buffers to restore. Quit,
restart, and load the desktop file the second time, and the file buffer
will be loaded before rcirc gets started, causing the buffer “takeover”
and resulting in a new desktop save file showing the log file buffer as
being in rcirc-mode. Quit, restart, and load the desktop file a third
time, and a message will be logged about an error trying to set the
buffer mode.

With the issues I’ve described before about not reliably getting back
into channels when quitting and restarting, the simplest fix once I’m in
the situation seems to be quitting Emacs, starting up again, making sure
any “restored” rcirc log buffers are killed, then starting rcirc.

I can probably work around this by tweaking desktop-files-not-to-save so
I don’t accidentally hit this when restarting Emacs, but (1) I do want
to be able to look at a log file and preserve my position in it from
session to session, and (2) manually pulling up a log file before
starting rcirc would still trigger the same lossage.

In GNU Emacs 28.0.92 (build 1, x86_64-redhat-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars)
 of 2022-03-20 built on 5bed50ec23174a34b43f6166b598ee0b
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Fedora Linux 35 (Workstation Edition)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=lucid
 --with-gpm=no --with-modules --with-harfbuzz --with-cairo --with-json
 --with-native-compilation build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2
 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: rcirc

Minor modes in effect:
  buffer-face-mode: t
  rcirc-track-minor-mode: t
  display-time-mode: t
  desktop-save-mode: t
  global-edit-server-edit-mode: t
  smart-quotes-mode: t
  which-function-mode: t
  icomplete-mode: t
  shell-dirtrack-mode: t
  global-hi-lock-mode: t
  hi-lock-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  use-hard-newlines: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  visual-line-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/raeburn/.emacs.d/elpa/systemtap-mode-20151122.1940/systemtap-mode hides /usr/share/emacs/site-lisp/systemtap-mode
/home/raeburn/.emacs.d/elpa/p4-20150721.1937/p4 hides /usr/share/emacs/site-lisp/perforce/p4
/home/raeburn/.emacs.d/elpa/transient-20211101.2251/transient hides /usr/share/emacs/28.0.92/lisp/transient

Features:
(shadow sort mail-extr emacsbug sendmail shortdoc help-fns radix-tree
gnutls network-stream nsm misearch multi-isearch cl-print ielm pp
add-log markdown-mode reveal face-remap dired-aux python tramp-sh
mule-util dockerfile-mode mhtml-mode css-mode color js sgml-mode
facemenu ruby-mode texinfo texinfo-loaddefs rst compile perl-mode
sh-script smie executable bug-reference conf-mode vc-git diff-mode
vc-dispatcher cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs org-element avl-tree generator ol-eww
eww xdg url-queue thingatpt mm-url ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe
ol-docview doc-view jka-compr image-mode exif ol-bibtex ol-bbdb ol-w3m
ol-doi org-link-doi yaml-mode ob-shell comp comp-cstr warnings cl-extra
help-mode rcirc gnus-art mm-uu mml2015 mm-view mml-smime smime dig
gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus
dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec
gnus-int gnus-range message rmc puny dired dired-loaddefs rfc822 mml
mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus
nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums
text-property-search mail-utils mm-util mail-prsvr wid-edit time desktop
frameset cus-load kr-init docker-tramp tramp-cache vagrant-tramp dash
tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat
parse-time ls-lisp org-protocol org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-footnote org-src ob-comint org-pcomplete org-list
org-faces org-entities noutline outline org-version ob-emacs-lisp
ob-core ob-eval org-table oc-basic bibtex iso8601 time-date ol org-keys
oc org-compat org-macs org-loaddefs format-spec find-func cal-menu
calendar cal-loaddefs edit-server advice smart-quotes easy-mmode
which-func imenu icomplete server term disp-table shell pcomplete ehelp
comint ansi-color ring hi-lock finder-inf rx info package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
x-toolkit x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 601460 80132)
 (symbols 48 34155 0)
 (strings 32 136844 6717)
 (string-bytes 1 4343776)
 (vectors 16 66007)
 (vector-slots 8 1241450 56375)
 (floats 8 520 450)
 (intervals 56 11548 4504)
 (buffers 992 197))