From e71a68633b17f8ac69fcf33d3d486184e71fcf8d Mon Sep 17 00:00:00 2001 From: Maxi Wolff Date: Tue, 3 Jan 2023 07:54:16 +0100 Subject: [PATCH] [core] Hotfix org version mismatch during startup this is caused by the home buffer loading build-in org which conflicts with elpa org. We actually want to use elpa org exclusively so we have to make sure to redraw the spacemacs buffer only after we have finished loading the layers. In addition latest org version 9.6 and the behaviour on emacs 29 has also changed so that org is autoloaded much earlier than before. This is what actually did make this bug show up. However this behaviour was in place since a long time and could be the cause for a lot of unreproducible bugs as the actual conflicts are dependent on the distribution specific emacs version. Known issues: This is a hotfix it solves the original issue but introduces a new, hopefully less dangerous issue, this is for now the start buffer is not configurable. I will add a follow up PR to remove this issue however I think this is far less annoying than a set of random conflicts caused by loading elisp files from different org sources. --- core/core-configuration-layer.el | 78 ++++++++++++++++---------------- core/core-spacemacs-buffer.el | 34 +++++++------- core/core-spacemacs.el | 21 +++++---- init.el | 1 + layers/+emacs/org/README.org | 2 +- 5 files changed, 70 insertions(+), 66 deletions(-) diff --git a/core/core-configuration-layer.el b/core/core-configuration-layer.el index c37254bcd..8fee1d316 100644 --- a/core/core-configuration-layer.el +++ b/core/core-configuration-layer.el @@ -2197,46 +2197,46 @@ to update." (apply #'nconc (mapcar (lambda (pkg) (when (yes-or-no-p (format "Update package '%s'? " pkg)) (list pkg))) - update-packages)))) + update-packages)))) (setq upgrade-count (length update-packages))))) - (spacemacs-buffer/append - "--> performing backup of package(s) to update...\n" t) - (spacemacs//redisplay) - (dolist (pkg update-packages) - (unless (memq pkg dotspacemacs-frozen-packages) - (let* ((src-dir (configuration-layer//get-package-directory pkg)) - (dest-dir (expand-file-name - (concat rollback-dir - (file-name-as-directory - (file-name-nondirectory src-dir)))))) - (copy-directory src-dir dest-dir 'keeptime 'create 'copy-content) - (push (cons pkg (file-name-nondirectory src-dir)) - update-packages-alist)))) - (spacemacs/dump-vars-to-file - '(update-packages-alist) - (expand-file-name (concat rollback-dir - configuration-layer-rollback-info))) - (dolist (pkg update-packages) - (unless (memq pkg dotspacemacs-frozen-packages) - (setq upgraded-count (1+ upgraded-count)) - (spacemacs-buffer/replace-last-line - (format "--> preparing update of package %s... [%s/%s]" - pkg upgraded-count upgrade-count) t) - (spacemacs//redisplay) - (configuration-layer//package-delete pkg))) - (spacemacs-buffer/append - (format "\n--> %s package(s) to be updated.\n" upgraded-count)) - (spacemacs-buffer/append - (format "\nRestart Emacs to install the updated packages. %s\n" - (if (member 'restart-emacs update-packages) - (concat "\n(SPC q r) won't work this time, because the" - "\nrestart-emacs package is being updated.") - "(SPC q r)"))) - (configuration-layer//cleanup-rollback-directory) - (spacemacs//redisplay)) - (when (eq upgrade-count 0) - (spacemacs-buffer/append "--> All packages are up to date.\n") - (spacemacs//redisplay)))) + (spacemacs-buffer/append + "--> performing backup of package(s) to update...\n" t) + (spacemacs//redisplay) + (dolist (pkg update-packages) + (unless (memq pkg dotspacemacs-frozen-packages) + (let* ((src-dir (configuration-layer//get-package-directory pkg)) + (dest-dir (expand-file-name + (concat rollback-dir + (file-name-as-directory + (file-name-nondirectory src-dir)))))) + (copy-directory src-dir dest-dir 'keeptime 'create 'copy-content) + (push (cons pkg (file-name-nondirectory src-dir)) + update-packages-alist)))) + (spacemacs/dump-vars-to-file + '(update-packages-alist) + (expand-file-name (concat rollback-dir + configuration-layer-rollback-info))) + (dolist (pkg update-packages) + (unless (memq pkg dotspacemacs-frozen-packages) + (setq upgraded-count (1+ upgraded-count)) + (spacemacs-buffer/replace-last-line + (format "--> preparing update of package %s... [%s/%s]" + pkg upgraded-count upgrade-count) t) + (spacemacs//redisplay) + (configuration-layer//package-delete pkg))) + (spacemacs-buffer/append + (format "\n--> %s package(s) to be updated.\n" upgraded-count)) + (spacemacs-buffer/append + (format "\nRestart Emacs to install the updated packages. %s\n" + (if (member 'restart-emacs update-packages) + (concat "\n(SPC q r) won't work this time, because the" + "\nrestart-emacs package is being updated.") + "(SPC q r)"))) + (configuration-layer//cleanup-rollback-directory) + (spacemacs//redisplay)) + (when (eq upgrade-count 0) + (spacemacs-buffer/append "--> All packages are up to date.\n") + (spacemacs//redisplay)))) (defun configuration-layer//ido-candidate-rollback-slot () "Return a list of candidates to select a rollback slot." diff --git a/core/core-spacemacs-buffer.el b/core/core-spacemacs-buffer.el index f2752b7af..1a2264fd5 100644 --- a/core/core-spacemacs-buffer.el +++ b/core/core-spacemacs-buffer.el @@ -274,7 +274,6 @@ Returns height in units of line height with a minimum of 1." (spacemacs-buffer//do-insert-startupify-lists) (recentf-mode -1) (line-number-at-pos))) - ;; (count-lines (point-min) (point-max))) (setq dotspacemacs-startup-buffer-show-icons icons) lines)) ;; We determine the maximum available banner height by subtracting the @@ -366,11 +365,11 @@ Right justified, based on the Spacemacs buffers window width." (spacemacs-buffer//center-line (length build-by)) (insert "\n\n") (widget-create 'url-link - :tag proudly-free - :help-echo "What is free software?" - :mouse-face 'highlight - :follow-link "\C-m" - "https://www.gnu.org/philosophy/free-sw.en.html") + :tag proudly-free + :help-echo "What is free software?" + :mouse-face 'highlight + :follow-link "\C-m" + "https://www.gnu.org/philosophy/free-sw.en.html") (spacemacs-buffer//center-line (+ 2 (length proudly-free))) (when gplv3 (insert "\n\n") @@ -704,8 +703,8 @@ and the trailing whitespace." (defun spacemacs-buffer//widget-text-note-beg-pos () (let (pos) (dolist (w spacemacs-buffer--note-widgets) - (when (eq (car w) 'text) - (setq pos (marker-position (widget-get w :from))))) + (when (eq (car w) 'text) + (setq pos (marker-position (widget-get w :from))))) pos)) (defun spacemacs-buffer//notes-clear-notes-and-widgets () @@ -908,8 +907,8 @@ REAL-WIDTH: the real width of the line. If the line contains an image, the size (line-beginning-position)))) (spacemacs-buffer//center-line) (setq spacemacs-buffer--buttons-position (- (line-end-position) - (line-beginning-position) - len))) + (line-beginning-position) + len))) (insert "\n") (widget-create 'push-button :help-echo "Update all ELPA packages to the latest versions." @@ -1377,7 +1376,8 @@ SEQ, START and END are the same arguments as for `cl-subseq'" (defun spacemacs-buffer//do-insert-startupify-lists () "Insert the startup lists in the current buffer." (setq spacemacs-buffer--startup-list-nr 1) - (let ((dotspacemacs-startup-buffer-show-icons dotspacemacs-startup-buffer-show-icons)) + (let ((dotspacemacs-startup-buffer-show-icons dotspacemacs-startup-buffer-show-icons) + (is-org-loaded (bound-and-true-p spacemacs-initialized))) (if (display-graphic-p) (unless (configuration-layer/package-used-p 'all-the-icons) (message "Package `all-the-icons' isn't installed") @@ -1385,7 +1385,7 @@ SEQ, START and END are the same arguments as for `cl-subseq'" (setq dotspacemacs-startup-buffer-show-icons nil)) (when dotspacemacs-startup-buffer-show-icons (require 'all-the-icons)) - (dolist (els (append '(warnings) dotspacemacs-startup-lists)) + (dolist (els (if is-org-loaded (append '(warnings) dotspacemacs-startup-lists) '(warnings))) (let ((el (or (car-safe els) els)) (list-size (or (cdr-safe els) spacemacs-buffer-startup-lists-length))) @@ -1395,7 +1395,7 @@ SEQ, START and END are the same arguments as for `cl-subseq'" (spacemacs-buffer//insert-warnings)) ((eq el 'recents) (spacemacs-buffer//insert-recent-files list-size)) ((and (eq el 'recents-by-project) - (fboundp 'projectile-mode)) + (fboundp 'projectile-mode)) (spacemacs-buffer//insert-recent-files-by-project list-size)) ((eq el 'todos) (spacemacs-buffer//insert-todos list-size)) ((eq el 'agenda) (spacemacs-buffer//insert-agenda list-size)) @@ -1562,10 +1562,10 @@ If a prefix argument is given, switch to it in an other, possibly new window." (force-mode-line-update) (spacemacs-buffer-mode))) (if save-line - (progn (goto-char (point-min)) - (forward-line (1- save-line)) - (forward-to-indentation 0)) - (spacemacs-buffer/goto-link-line))) + (progn (goto-char (point-min)) + (forward-line (1- save-line)) + (forward-to-indentation 0)) + (spacemacs-buffer/goto-link-line))) (if current-prefix-arg (switch-to-buffer-other-window spacemacs-buffer-name) (switch-to-buffer spacemacs-buffer-name)) diff --git a/core/core-spacemacs.el b/core/core-spacemacs.el index 1d2c09720..731dbe6a9 100644 --- a/core/core-spacemacs.el +++ b/core/core-spacemacs.el @@ -65,6 +65,7 @@ (defvar spacemacs--default-mode-line mode-line-format "Backup of default mode line format.") + (defvar spacemacs-initialized nil "Whether or not spacemacs has finished initializing by completing the final step of executing code in `emacs-startup-hook'.") @@ -157,17 +158,14 @@ the final step of executing code in `emacs-startup-hook'.") (car dotspacemacs-default-font))))) ;; spacemacs init (setq inhibit-startup-screen t) - (spacemacs-buffer/goto-buffer) - (unless (display-graphic-p) - ;; explicitly recreate the home buffer for the first GUI client - ;; in order to correctly display the logo - (spacemacs|do-after-display-system-init - (kill-buffer (get-buffer spacemacs-buffer-name)) - (spacemacs-buffer/goto-buffer))) + + ;; Draw the spacemacs buffer without lists and scalling to avoid having + ;; to load build-in org which will conflict with elpa org + (spacemacs-buffer/goto-buffer t) + ;; This is set to nil during startup to allow Spacemacs to show buffers opened ;; as command line arguments. (setq initial-buffer-choice nil) - (setq inhibit-startup-screen t) (require 'core-keybindings) ;; for convenience and user support (unless (fboundp 'tool-bar-mode) @@ -261,13 +259,18 @@ Note: the hooked function is not executed when in dumped mode." (setq spacemacs-initialized t) (setq gc-cons-threshold (car dotspacemacs-gc-cons) gc-cons-percentage (cadr dotspacemacs-gc-cons)) - (setq read-process-output-max dotspacemacs-read-process-output-max))) + (setq read-process-output-max dotspacemacs-read-process-output-max) + ;; Redraw the spacemacs buffer with full org support + ;; Before it must be drawn without org related features to + ;; avoid loading build in org in emacs >= 29 + (spacemacs-buffer/goto-buffer t))) (if dotspacemacs-byte-compile (when (> 1 (spacemacs//dir-byte-compile-state (concat spacemacs-core-directory "libs/"))) (byte-recompile-directory (concat spacemacs-core-directory "libs/") 0)) (spacemacs//remove-byte-compiled-files-in-dir spacemacs-core-directory)) + ;; Check if revision has changed. (spacemacs//revision-check)) diff --git a/init.el b/init.el index 7c4de98b7..2ec48bdc4 100644 --- a/init.el +++ b/init.el @@ -26,6 +26,7 @@ ;; Avoid garbage collection during startup. ;; see `SPC h . dotspacemacs-gc-cons' for more info + (defconst emacs-start-time (current-time)) (setq gc-cons-threshold 402653184 gc-cons-percentage 0.6) (load (concat (file-name-directory load-file-name) "core/core-load-paths") diff --git a/layers/+emacs/org/README.org b/layers/+emacs/org/README.org index 001fda692..d5a961bb4 100644 --- a/layers/+emacs/org/README.org +++ b/layers/+emacs/org/README.org @@ -93,7 +93,7 @@ For more extensive support of references through BibTeX files, have a look at the [[https://github.com/syl20bnr/spacemacs/blob/develop/layers/+lang/bibtex/README.org][BibTeX layer]]. * Important Note -Since version 0.300, spacemacs uses the =org= version from the ELPA repository +Spacemacs uses the =org= version from the ELPA repository instead of the one shipped with emacs. Then, any =org= related code should not be loaded before =dotspacemacs/user-config=, otherwise both versions will be loaded and will conflict.