Subject: bug#34954: 26.1.92; eshell gets loaded twice

From: Mauro Aranda <[email-masked]>
Date: Sat, 23 Mar 2019 12:05:56 -0300

Hello Emacs.
I was messing around with eshell hooks when I encountered this bug.
This behavior is present in a fairly recent build of emacs 26 and in
master as well.

Here's a recipe:
1) Start emacs: emacs -Q.
2) On *scratch* buffer, write the following expressions:
The function can be whatever indicates a duplicate (I keep it simple for
myself):
(defun eshell-loaded-msg () (insert "Eshell was loaded.\n"))
(add-hook 'eshell-load-hook 'eshell-loaded-msg)
3) M-x eval-buffer
4) M-x eshell
5) After Eshell gets loaded, type C-x b RET to go back to *scratch*
buffer.
6) Notice that "Eshell was loaded" appears twice.

My conclusion is that eshell gets loaded twice, becuase eshell.el
requires esh-mode, which requires esh-module, which in turn requires
eshell.  Since this require expression comes before the provide
expresion (provide 'eshell) in eshell.el, eshell gets loaded twice.

In GNU Emacs 26.1.92 (build 1, i686-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2019-03-22 built on the-blackbeard
Repository revision: 24fc1337c169aeb1095dcc58bf8d4bbe48abefc0
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description:	Ubuntu 16.04.6 LTS

Recent messages:
Loading em-basic...done
Loading em-cmpl...done
Loading em-dirs...done
Loading em-glob...done
Loading em-hist...done
Loading em-ls...done
Loading em-prompt...done
Loading em-script...done
Loading em-term...done
Loading em-unix...done

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS LCMS2

Important settings:
  value of $LANG: en_US.utf8
  value of $XMODIFIERS:
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-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
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils em-unix em-term term disp-table easymenu
ehelp em-script em-prompt em-ls cl-loaddefs cl-lib em-hist em-pred
em-glob em-dirs em-cmpl em-basic em-banner em-alias pcomplete comint
ansi-color ring esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg
esh-groups eshell esh-module esh-mode esh-util elec-pair time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type 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 elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame 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 charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 8 111308 10030)
 (symbols 24 22085 1)
 (miscs 20 57 161)
 (strings 16 33578 1765)
 (string-bytes 1 938325)
 (vectors 12 17691)
 (vector-slots 4 564929 12642)
 (floats 8 56 61)
 (intervals 28 231 1)
 (buffers 536 12)
 (heap 1024 32162 939))