4

Using the menu Options-Customize Emacs-Browse Customization Themes, I've modified initial-scratch-message. I saved my customizations; and exited Emacs.

When I re-start Emacs, the initial-scratch-message displays as before; but, if I open my init.el file, I see the changes that I'd saved. I've tried all manner of options over the past couple of hours to no avail.

Original question: Is there something that is preventing my customization from taking effect?

Modified question: More specifically, how can I tell ErgoEmacs to stop overriding my preference?

p.s. Since originally posting my question, I'm beginning to think that my recent addition of the ErgoEmacs package may be influencing the behavior. When I start Emacs, I see the "scratch-message" which is originally set in the /etc/emacs*/* libraries. Since I've included the code in my init.el to always recreate a scratch whenever one is killed, I kill the first Scratch buffer and, upon inspecting the scratch buffer, I have a separate message in my scratch buffer alerting me to using "Control-O" to open a new file (rather than Emacs classical way of C-x C-f). And each successive generation of scratch has that 2nd message.

5
  • 1
    Just to be sure, you're looking at the contents of the *scratch* buffer, after Emacs starts up?
    – zck
    Commented Jan 30, 2018 at 6:12
  • Precisely, @zck. It seems as though ErgoEmacs has redefined "initial-scratch-message" and, somehow, is preventing my customization from my init.el file from taking affect.
    – TheGeeko61
    Commented Jan 30, 2018 at 8:04
  • Found at github.com/ergoemacs/ergoemacs-mode/issues/389: Add (setq ergoemacs-theme-options (quote ((save-options-on-exit off)))) line to your ergoemacs configuration/init.el
    – Tobias
    Commented Jan 30, 2018 at 10:48
  • 1
    @Tobias, thanks for the tip... I've been investigating that trail... it seems to be a bit more complex than simply adding that line into my .emacs.d/init.el configuration. Once I've resolved this, I'll post a complete discussion from my lessons learned.
    – TheGeeko61
    Commented Jan 30, 2018 at 17:36
  • Note that initial-scratch-message is overwritten in the ergoemacs theme standard. You find that at the definition of the ergomacs-component standard-vars in file ergoemacs-themes.el and standard-vars is part of theme standard. Pityingly I had to delete my answer since it solved your problem only partially. initial-scratch-message was reset after start-up but I was able to define an ergoemacs-theme overriding standard stably setting initial-scratch-message
    – Tobias
    Commented Feb 5, 2018 at 14:03

1 Answer 1

4
+50

In step 23 of the startup sequence emacs inserts initial-scratch-message into the *scratch* buffer.

That step is after loading the init file, after running after-init-hook, and before emacs-startup-hook.

Ergoemacs uses its own themes defined with ergoemacs-theme. The standard theme is defined in library ergoemacs-themes.el.

The value of initial-scratch-message is overwritten in the ergoemacs theme standard. You find that at the definition of the ergomacs-component standard-vars in file ergoemacs-themes.el and standard-vars is a component of theme standard.

The themes are loaded by ergoemacs-component-struct--apply-inits when ergoemacs-mode is started as part of emacs-startup-hook. That is too late for the initial-scratch-message in the initial *scratch* buffer. So you need to set initial-scratch-message for the initial scratch buffer separately from that one for later generated scratch buffers.

The most simple way to override the initial-scratch-message is to copy the following lisp snippet to your init file and adapt it for your purposes:

(package-initialize) ;; if not already done in your init file
(defun my-scratch-message ()
  "Set `initial-scratch-message' to what I want!"
  (setq initial-scratch-message ";; my scratch message"))

(add-hook 'after-init-hook #'my-scratch-message t) ;; for the message in the first *scratch* buffer
;; `initial-scratch-message' is modified by ergoemacs at the beginning of `emacs-startup-hook'
(add-hook 'emacs-startup-hook #'my-scratch-message t) ;; overriding the ergomacs settings for the message in future *scratch* buffers

At first, I also thought that defining a new ergoemacs theme my-theme overriding the initial-scratch-message setting would be the simplest way. But that proved wrong (that is also the reason why I deleted my first answer).

One cannot use :based-on standard in the definition of my-theme as in the following elisp code segment.

(ergoemacs-theme my-theme ()
    "My theme."
    :based-on standard
    (setq initial-scratch-message ";; My initial scratch message."))

Ergoemacs evaluates the body of my-theme before the standard theme. So the standard theme overrides the settings of the derived theme. I consider that a bug in ergomacs and a bug-report would be in order.

The only way employing ergoemacs themes for the settings would be to define a theme from scratch replacing the component standard-vars by an own component my-vars where initial-scratch-message is set to the wanted value. If one really wants to enforce that one ends up witht he following elisp snippet for the init file.

Most of the text for my-vars and my-theme is copied from standard-vars and theme standard in ergomacs-themes.el.

I indicated my changes there by the string Tobias.

(require 'find-func)
(package-initialize) ;; if not already done in your init file
(require 'ergoemacs-mode)
(require 'ergoemacs-lib)
(require 'ergoemacs-map)

(defvar my-initial-scratch-message ";; My initial scratch message."
  "My setting of `initial-scratch-message'.")
(setq initial-scratch-message (substitute-command-keys my-initial-scratch-message))

(ergoemacs-component my-vars ()
  "Enabled/changed variables/modes"
  (setq org-CUA-compatible t
        org-support-shift-select t
        set-mark-command-repeat-pop t
        org-special-ctrl-a/e t
        ido-vertical-define-keys 'C-n-C-p-up-down-left-right
        scroll-error-top-bottom t
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;; Tobias: Modification of initial-scratch-message:
        initial-scratch-message (substitute-command-keys my-initial-scratch-message)
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;; Remove tutorial and guided tour, since the keys don't apply...
        fancy-startup-text
        `((:face (variable-pitch font-lock-comment-face)
                 "Welcome to "
                 :link ("GNU Emacs"
                        ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
                        "Browse http://www.gnu.org/software/emacs/")
                 ", one component of the "
                 :link
                 ,(lambda ()
                    (if (eq system-type 'gnu/linux)
                        `("GNU/Linux"
                          ,(lambda (_button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
                          "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
                      `("GNU" ,(lambda (_button) (describe-gnu-project))
                        "Display info on the GNU project")))
                 " operating system.\n\n"
                 "\n"
                 ;; :link ("Emacs Guided Tour"
                 ;;        ,(lambda (_button)
                 ;;           (browse-url "http://www.gnu.org/software/emacs/tour/"))
                 ;;        "Browse http://www.gnu.org/software/emacs/tour/")
                 ;; "\tOverview of Emacs features at gnu.org\n"
                 :link ("View Emacs Manual" ,(lambda (_button) (info-emacs-manual)))
                 "\tView the Emacs manual using Info\n"
                 :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
                 "\tGNU Emacs comes with "
                 :face (variable-pitch (:slant oblique))
                 "ABSOLUTELY NO WARRANTY\n"
                 :face variable-pitch
                 :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
                 "\tConditions for redistributing and changing Emacs\n"
                 :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
                 "\tPurchasing printed copies of manuals\n"
                 "\n"))
        ;;
        fancy-about-text
        `((:face (variable-pitch font-lock-comment-face)
                 "This is "
                 :link ("GNU Emacs"
                        ,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
                        "Browse http://www.gnu.org/software/emacs/")
                 ", one component of the "
                 :link
                 ,(lambda ()
                    (if (eq system-type 'gnu/linux)
                        `("GNU/Linux"
                          ,(lambda (_button)
                             (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
                          "Browse http://www.gnu.org/gnu/linux-and-gnu.html")
                      `("GNU" ,(lambda (_button) (describe-gnu-project))
                        "Display info on the GNU project.")))
                 " operating system.\n"
                 :face (variable-pitch font-lock-builtin-face)
                 "\n"
                 ,(lambda () (emacs-version))
                 "\n"
                 :face (variable-pitch (:height 0.8))
                 ,(lambda () emacs-copyright)
                 "\n\n"
                 :face variable-pitch
                 :link ("Authors"
                        ,(lambda (_button)
                           (view-file (expand-file-name "AUTHORS" data-directory))
                           (goto-char (point-min))))
                 "\tMany people have contributed code included in GNU Emacs\n"
                 :link ("Contributing"
                        ,(lambda (_button)
                           (view-file (expand-file-name "CONTRIBUTE" data-directory))
                           (goto-char (point-min))))
                 "\tHow to contribute improvements to Emacs\n"
                 "\n"
                 :link ("GNU and Freedom" ,(lambda (_button) (describe-gnu-project)))
                 "\tWhy we developed GNU Emacs, and the GNU operating system\n"
                 :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
                 "\tGNU Emacs comes with "
                 :face (variable-pitch (:slant oblique))
                 "ABSOLUTELY NO WARRANTY\n"
                 :face variable-pitch
                 :link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
                 "\tConditions for redistributing and changing Emacs\n"
                 :link ("Getting New Versions" ,(lambda (_button) (describe-distribution)))
                 "\tHow to obtain the latest version of Emacs\n"
                 :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
                 "\tBuying printed manuals from the FSF\n"
                 "\n"
                 ;; :link ("Emacs Guided Tour"
                 ;;        ,(lambda (_button)
                 ;;           (browse-url "http://www.gnu.org/software/emacs/tour/"))
                 ;;        "Browse http://www.gnu.org/software/emacs/tour/")
                 ;; "\tSee an overview of Emacs features at gnu.org"
         )))
  (add-hook 'dirtrack-directory-change-hook 'ergoemacs-shell-here-directory-change-hook)
  (add-hook 'kill-buffer-hook 'ergoemacs-save-buffer-to-recently-closed)
  (add-hook 'shell-mode-hook 'ergoemacs-shell-here-hook)
  (add-hook 'eshell-post-command-hook 'ergoemacs-shell-here-directory-change-hook)
  ;; (dolist (hook '(dired-after-readin-hook after-change-major-mode-hook))
  ;;   (add-hook hook 'ergoemacs-setup-local-prefixes))
  (shift-select-mode t)
  (delete-selection-mode 1)
  (setq recentf-menu-before "Close"
        recentf-menu-items-for-commands
        (list
         ["Open Last Closed"
          ergoemacs-open-last-closed
          :help "Remove duplicates, and obsoletes files from the recent list"
          :active t]
         ["Cleanup list"
          recentf-cleanup
          :help "Remove duplicates, and obsoletes files from the recent list"
          :active t]
         ["Edit list..."
          recentf-edit-list
          :help "Manually remove files from the recent list"
          :active t]
         ["Save list now"
          recentf-save-list
          :help "Save the list of recently opened files now"
          :active t]
         ["Options..."
          (customize-group "recentf")
          :help "Customize recently opened files menu and options"
          :active t]))
  (recentf-mode (if noninteractive -1 1)))

(ergoemacs-theme my-theme ()
  "My Ergoemacs Theme"
  :components '(copy
                dired-tab
                dired-to-wdired
                execute
                fixed-newline
                help
                kill-line
                misc
                move-bracket
                move-buffer
                move-char
                move-line
                move-page
                move-paragraph
                move-word
                search
                select-items
                switch
                text-transform
                ergoemacs-remaps
                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                ;; Tobias: standard-vars replaced by my-vars:
                my-vars
                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                )
  :optional-on '(apps-punctuation
                 tab-indents-region
                 icy-reclaim
                 apps-apps
                 apps-toggle
                 apps
                 backspace-del-seq
                 backspace-is-back
                 fn-keys
                 f2-edit
                 fixed-bold-italic
                 standard-fixed
                 ido-remaps
                 helm-remaps
                 helm-find-files
                 multiple-cursors-remaps
                 quit
                 apps-swap
                 ;;save-options-on-exit
                 ;; Reverse menu-bar order
                 menu-bar-help
                 menu-bar-languages
                 menu-bar-view
                 menu-bar-search
                 menu-bar-edit
                 menu-bar-file
         mode-line-major-mode-switch
                 )
  :optional-off '(guru
                  alt-backspace-is-undo
                  search-reg
                  no-backspace
                  helm-switch-sources
                  ergoemacs-banish-shift
                  move-and-transpose-lines
                  move-sexp
                  ido-prev-next-instead-of-left-right
                  join-line
          save-options-on-exit
                  isearch-arrows
          ergoemacs-swiper)
  :options-menu '(("Menu/Apps Key" (apps apps-apps apps-punctuation apps-toggle))
                  ("Function Keys" (fn-keys f2-edit))
                  ("Helm Options" (helm-switch-sources helm-find-files))
                  ("Remaps" (ido-remaps helm-remaps multiple-cursors-remaps icy-reclaim ergoemacs-swiper))
                  ("Extreme ErgoEmacs" (guru no-backspace ergoemacs-banish-shift))
                  ("Standard Keys" (standard-fixed fixed-bold-italic quit move-and-transpose-lines alt-backspace-is-undo))
                  ("Keys during Key Sequence" (f2-edit apps-swap backspace-del-seq))
                  ("Disputed Keys" (ido-prev-next-instead-of-left-right move-sexp))
                  ("Extra Functionality" (join-line isearch-arrows))
                  ("Packages" (avy multiple-cursors expand-region))
          ("Mode Line" (mode-line-major-mode-switch))
                  ("Ergoemacs global menus" (menu-bar-file menu-bar-edit menu-bar-search menu-bar-view menu-bar-languages menu-bar-help))))
(ergoemacs-set-default 'ergoemacs-theme 'my-theme)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.