defining a function: (defun xxx-insert() "anything" (interactive) (insert "# Local Variables:\n") (insert "# mode: org\n") (insert "# End:\n") ) will cause Emacs to disregard the Emacs-lisp-mode after re-opening the file, hence no syntax evaluation anymore Changing (insert "# Local Variables:\n") to (insert "# Local Bariables:\n") will 'solve' the problem. Note: exactly the same behaviour invoking emacs with -Q In GNU Emacs 28.0.50 (build 58, x86_64-pc-linux-gnu, GTK+ Version 3.24.28, cairo version 1.16.0) of 2021-04-26 built on XYZ Repository revision: 50f29f6a282b7426377be5fb54322fc5b5a487fc Repository branch: master Windowing system distributor 'Fedora Project', version 11.0.12011000 System Description: Fedora 33 (Thirty Three) Configured using: 'configure --prefix=/opt/emacs --sysconfdir=/etc --enable-locallisppath=/usr/local/share/emacs/site-lisp --libexecdir=/opt/emacs/lib/ --localstatedir=/usr/local/var --enable-largefile --with-x-toolkit=gtk3 --with-modules --with-xwidgets --without-pop --without-selinux --without-gnutls --with-file-notification=yes --with-json --with-cairo 'CFLAGS=-march=native -Os'' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GPM GSETTINGS HARFBUZZ JPEG JSON LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM XWIDGETS GTK3 ZLIB Important settings: value of $LANG: en_US.utf8 value of $XMODIFIERS: @im=none locale-coding-system: utf-8-unix Major mode: ELisp/d Minor modes in effect: show-paren-mode: t recentf-mode: t desktop-save-mode: 1 global-hl-line-mode: t hl-line-mode: t delete-selection-mode: t cua-mode: t flymake-mode: t savehist-mode: t global-auto-revert-mode: t auto-insert-mode: t tabbar-mwheel-mode: t tabbar-mode: t smooth-scroll-mode: t auto-complete-mode: t global-undo-tree-mode: t undo-tree-mode: t save-place-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-quote-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t global-prettify-symbols-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 size-indication-mode: t column-number-mode: t line-number-mode: t global-visual-line-mode: t visual-line-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug sendmail ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom browse-url gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message rmc puny rfc822 mml mml-sec epa epg 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 mail-utils mm-util mail-prsvr ol-docview doc-view jka-compr image-mode exif dired-sort-menu dired dired-loaddefs ol-bibtex bibtex iso8601 ol-bbdb ol-w3m pp default-daemon server executable cl-extra misearch multi-isearch cursor-sensor ffap checkdoc lisp-mnt help-mode user-profile default-gnus contrib/chartables powerline powerline-separators powerline-themes default-profile default-ui paren man recentf vc-dispatcher vc-svn desktop frameset avoid hl-line default-faces default-keymap delsel cua-base facemenu default-run default-restart default-modes default-platform default-unix default-flymake default-flymake-go default-flymake-csharp default-flymake-ruby default-flymake-js default-flymake-py default-flymake-java default-flymake-shell flymake-proc flymake compile text-property-search warnings default-run-assoc run-assoc default-tempo default-tempo-rexx default-tempo-sh default-tempo-pas default-tempo-js default-tempo-java default-tempo-perl default-tempo-elisp default-tempo-c-cpp default-menu default-help default-options default-tools default-search default-format default-view aquamacs-cmm-menu default-edit default-file default-generic savehist autorevert filenotify autoinsert default-functions default-autoload nf-procmail-mode ox-man ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar ox-html table ox-ascii ox-publish ox org-element org ob ob-tangle ob-ref ob-lob ob-table org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color ring org-list org-faces org-entities time-date org-version ob-emacs-lisp org-table org-keys org-loaddefs find-func cal-menu calendar cal-loaddefs avl-tree generator ol ob-exp ob-core org-compat ob-eval org-macs format-spec markdown-mode rx thingatpt noutline outline easy-mmode jison-mode bison-mode cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs flex-mode derived aquamacs-tabbar cus-load aquamacs-tools tabbar restore-last-frame-size org-bullets syslog-mode hide-lines web-mode disp-table vimrc-mode go-autocomplete go-mode-autoloads neotree advice smooth-scroll aok fill-column-indicator tempbuf auto-complete-config auto-complete edmacro kmacro undo-tree diff multi-shell windata tree-mode tree-widget wid-edit imenu imenu-tree tempo saveplace google-translate google-translate-default-ui google-translate-core-ui color popup ido google-translate-core google-translate-tk google-translate-backend url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache url-vars mailcap cl-loaddefs cl-lib json subr-x map seq byte-opt gv bytecomp byte-compile cconv eol-conversion default-path iso-transl 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 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 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 xwidget-internal dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 327973 299086) (symbols 48 32950 2) (strings 32 117560 25908) (string-bytes 1 4009819) (vectors 16 61069) (vector-slots 8 1342703 309626) (floats 8 464 2216) (intervals 56 813 716) (buffers 992 16))