[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.
This commit is contained in:
Maxi Wolff 2023-01-03 07:54:16 +01:00
parent 1100ee841a
commit e71a68633b
5 changed files with 70 additions and 66 deletions

View File

@ -2197,46 +2197,46 @@ to update."
(apply #'nconc (mapcar (lambda (pkg) (apply #'nconc (mapcar (lambda (pkg)
(when (yes-or-no-p (format "Update package '%s'? " pkg)) (when (yes-or-no-p (format "Update package '%s'? " pkg))
(list pkg))) (list pkg)))
update-packages)))) update-packages))))
(setq upgrade-count (length update-packages))))) (setq upgrade-count (length update-packages)))))
(spacemacs-buffer/append (spacemacs-buffer/append
"--> performing backup of package(s) to update...\n" t) "--> performing backup of package(s) to update...\n" t)
(spacemacs//redisplay) (spacemacs//redisplay)
(dolist (pkg update-packages) (dolist (pkg update-packages)
(unless (memq pkg dotspacemacs-frozen-packages) (unless (memq pkg dotspacemacs-frozen-packages)
(let* ((src-dir (configuration-layer//get-package-directory pkg)) (let* ((src-dir (configuration-layer//get-package-directory pkg))
(dest-dir (expand-file-name (dest-dir (expand-file-name
(concat rollback-dir (concat rollback-dir
(file-name-as-directory (file-name-as-directory
(file-name-nondirectory src-dir)))))) (file-name-nondirectory src-dir))))))
(copy-directory src-dir dest-dir 'keeptime 'create 'copy-content) (copy-directory src-dir dest-dir 'keeptime 'create 'copy-content)
(push (cons pkg (file-name-nondirectory src-dir)) (push (cons pkg (file-name-nondirectory src-dir))
update-packages-alist)))) update-packages-alist))))
(spacemacs/dump-vars-to-file (spacemacs/dump-vars-to-file
'(update-packages-alist) '(update-packages-alist)
(expand-file-name (concat rollback-dir (expand-file-name (concat rollback-dir
configuration-layer-rollback-info))) configuration-layer-rollback-info)))
(dolist (pkg update-packages) (dolist (pkg update-packages)
(unless (memq pkg dotspacemacs-frozen-packages) (unless (memq pkg dotspacemacs-frozen-packages)
(setq upgraded-count (1+ upgraded-count)) (setq upgraded-count (1+ upgraded-count))
(spacemacs-buffer/replace-last-line (spacemacs-buffer/replace-last-line
(format "--> preparing update of package %s... [%s/%s]" (format "--> preparing update of package %s... [%s/%s]"
pkg upgraded-count upgrade-count) t) pkg upgraded-count upgrade-count) t)
(spacemacs//redisplay) (spacemacs//redisplay)
(configuration-layer//package-delete pkg))) (configuration-layer//package-delete pkg)))
(spacemacs-buffer/append (spacemacs-buffer/append
(format "\n--> %s package(s) to be updated.\n" upgraded-count)) (format "\n--> %s package(s) to be updated.\n" upgraded-count))
(spacemacs-buffer/append (spacemacs-buffer/append
(format "\nRestart Emacs to install the updated packages. %s\n" (format "\nRestart Emacs to install the updated packages. %s\n"
(if (member 'restart-emacs update-packages) (if (member 'restart-emacs update-packages)
(concat "\n(SPC q r) won't work this time, because the" (concat "\n(SPC q r) won't work this time, because the"
"\nrestart-emacs package is being updated.") "\nrestart-emacs package is being updated.")
"(SPC q r)"))) "(SPC q r)")))
(configuration-layer//cleanup-rollback-directory) (configuration-layer//cleanup-rollback-directory)
(spacemacs//redisplay)) (spacemacs//redisplay))
(when (eq upgrade-count 0) (when (eq upgrade-count 0)
(spacemacs-buffer/append "--> All packages are up to date.\n") (spacemacs-buffer/append "--> All packages are up to date.\n")
(spacemacs//redisplay)))) (spacemacs//redisplay))))
(defun configuration-layer//ido-candidate-rollback-slot () (defun configuration-layer//ido-candidate-rollback-slot ()
"Return a list of candidates to select a rollback slot." "Return a list of candidates to select a rollback slot."

View File

@ -274,7 +274,6 @@ Returns height in units of line height with a minimum of 1."
(spacemacs-buffer//do-insert-startupify-lists) (spacemacs-buffer//do-insert-startupify-lists)
(recentf-mode -1) (recentf-mode -1)
(line-number-at-pos))) (line-number-at-pos)))
;; (count-lines (point-min) (point-max)))
(setq dotspacemacs-startup-buffer-show-icons icons) (setq dotspacemacs-startup-buffer-show-icons icons)
lines)) lines))
;; We determine the maximum available banner height by subtracting the ;; 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)) (spacemacs-buffer//center-line (length build-by))
(insert "\n\n") (insert "\n\n")
(widget-create 'url-link (widget-create 'url-link
:tag proudly-free :tag proudly-free
:help-echo "What is free software?" :help-echo "What is free software?"
:mouse-face 'highlight :mouse-face 'highlight
:follow-link "\C-m" :follow-link "\C-m"
"https://www.gnu.org/philosophy/free-sw.en.html") "https://www.gnu.org/philosophy/free-sw.en.html")
(spacemacs-buffer//center-line (+ 2 (length proudly-free))) (spacemacs-buffer//center-line (+ 2 (length proudly-free)))
(when gplv3 (when gplv3
(insert "\n\n") (insert "\n\n")
@ -704,8 +703,8 @@ and the trailing whitespace."
(defun spacemacs-buffer//widget-text-note-beg-pos () (defun spacemacs-buffer//widget-text-note-beg-pos ()
(let (pos) (let (pos)
(dolist (w spacemacs-buffer--note-widgets) (dolist (w spacemacs-buffer--note-widgets)
(when (eq (car w) 'text) (when (eq (car w) 'text)
(setq pos (marker-position (widget-get w :from))))) (setq pos (marker-position (widget-get w :from)))))
pos)) pos))
(defun spacemacs-buffer//notes-clear-notes-and-widgets () (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)))) (line-beginning-position))))
(spacemacs-buffer//center-line) (spacemacs-buffer//center-line)
(setq spacemacs-buffer--buttons-position (- (line-end-position) (setq spacemacs-buffer--buttons-position (- (line-end-position)
(line-beginning-position) (line-beginning-position)
len))) len)))
(insert "\n") (insert "\n")
(widget-create 'push-button (widget-create 'push-button
:help-echo "Update all ELPA packages to the latest versions." :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 () (defun spacemacs-buffer//do-insert-startupify-lists ()
"Insert the startup lists in the current buffer." "Insert the startup lists in the current buffer."
(setq spacemacs-buffer--startup-list-nr 1) (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) (if (display-graphic-p)
(unless (configuration-layer/package-used-p 'all-the-icons) (unless (configuration-layer/package-used-p 'all-the-icons)
(message "Package `all-the-icons' isn't installed") (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)) (setq dotspacemacs-startup-buffer-show-icons nil))
(when dotspacemacs-startup-buffer-show-icons (when dotspacemacs-startup-buffer-show-icons
(require 'all-the-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)) (let ((el (or (car-safe els) els))
(list-size (or (cdr-safe els) (list-size (or (cdr-safe els)
spacemacs-buffer-startup-lists-length))) 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)) (spacemacs-buffer//insert-warnings))
((eq el 'recents) (spacemacs-buffer//insert-recent-files list-size)) ((eq el 'recents) (spacemacs-buffer//insert-recent-files list-size))
((and (eq el 'recents-by-project) ((and (eq el 'recents-by-project)
(fboundp 'projectile-mode)) (fboundp 'projectile-mode))
(spacemacs-buffer//insert-recent-files-by-project list-size)) (spacemacs-buffer//insert-recent-files-by-project list-size))
((eq el 'todos) (spacemacs-buffer//insert-todos list-size)) ((eq el 'todos) (spacemacs-buffer//insert-todos list-size))
((eq el 'agenda) (spacemacs-buffer//insert-agenda 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) (force-mode-line-update)
(spacemacs-buffer-mode))) (spacemacs-buffer-mode)))
(if save-line (if save-line
(progn (goto-char (point-min)) (progn (goto-char (point-min))
(forward-line (1- save-line)) (forward-line (1- save-line))
(forward-to-indentation 0)) (forward-to-indentation 0))
(spacemacs-buffer/goto-link-line))) (spacemacs-buffer/goto-link-line)))
(if current-prefix-arg (if current-prefix-arg
(switch-to-buffer-other-window spacemacs-buffer-name) (switch-to-buffer-other-window spacemacs-buffer-name)
(switch-to-buffer spacemacs-buffer-name)) (switch-to-buffer spacemacs-buffer-name))

View File

@ -65,6 +65,7 @@
(defvar spacemacs--default-mode-line mode-line-format (defvar spacemacs--default-mode-line mode-line-format
"Backup of default mode line format.") "Backup of default mode line format.")
(defvar spacemacs-initialized nil (defvar spacemacs-initialized nil
"Whether or not spacemacs has finished initializing by completing "Whether or not spacemacs has finished initializing by completing
the final step of executing code in `emacs-startup-hook'.") 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))))) (car dotspacemacs-default-font)))))
;; spacemacs init ;; spacemacs init
(setq inhibit-startup-screen t) (setq inhibit-startup-screen t)
(spacemacs-buffer/goto-buffer)
(unless (display-graphic-p) ;; Draw the spacemacs buffer without lists and scalling to avoid having
;; explicitly recreate the home buffer for the first GUI client ;; to load build-in org which will conflict with elpa org
;; in order to correctly display the logo (spacemacs-buffer/goto-buffer t)
(spacemacs|do-after-display-system-init
(kill-buffer (get-buffer spacemacs-buffer-name))
(spacemacs-buffer/goto-buffer)))
;; This is set to nil during startup to allow Spacemacs to show buffers opened ;; This is set to nil during startup to allow Spacemacs to show buffers opened
;; as command line arguments. ;; as command line arguments.
(setq initial-buffer-choice nil) (setq initial-buffer-choice nil)
(setq inhibit-startup-screen t)
(require 'core-keybindings) (require 'core-keybindings)
;; for convenience and user support ;; for convenience and user support
(unless (fboundp 'tool-bar-mode) (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 spacemacs-initialized t)
(setq gc-cons-threshold (car dotspacemacs-gc-cons) (setq gc-cons-threshold (car dotspacemacs-gc-cons)
gc-cons-percentage (cadr 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 (if dotspacemacs-byte-compile
(when (> 1 (spacemacs//dir-byte-compile-state (when (> 1 (spacemacs//dir-byte-compile-state
(concat spacemacs-core-directory "libs/"))) (concat spacemacs-core-directory "libs/")))
(byte-recompile-directory (concat spacemacs-core-directory "libs/") 0)) (byte-recompile-directory (concat spacemacs-core-directory "libs/") 0))
(spacemacs//remove-byte-compiled-files-in-dir spacemacs-core-directory)) (spacemacs//remove-byte-compiled-files-in-dir spacemacs-core-directory))
;; Check if revision has changed. ;; Check if revision has changed.
(spacemacs//revision-check)) (spacemacs//revision-check))

View File

@ -26,6 +26,7 @@
;; Avoid garbage collection during startup. ;; Avoid garbage collection during startup.
;; see `SPC h . dotspacemacs-gc-cons' for more info ;; see `SPC h . dotspacemacs-gc-cons' for more info
(defconst emacs-start-time (current-time)) (defconst emacs-start-time (current-time))
(setq gc-cons-threshold 402653184 gc-cons-percentage 0.6) (setq gc-cons-threshold 402653184 gc-cons-percentage 0.6)
(load (concat (file-name-directory load-file-name) "core/core-load-paths") (load (concat (file-name-directory load-file-name) "core/core-load-paths")

View File

@ -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]]. the [[https://github.com/syl20bnr/spacemacs/blob/develop/layers/+lang/bibtex/README.org][BibTeX layer]].
* Important Note * 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 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 be loaded before =dotspacemacs/user-config=, otherwise both versions will be
loaded and will conflict. loaded and will conflict.