Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Hook minemacs-first-file-hook doesn't seem to run #142

Closed
hmanhng opened this issue Dec 19, 2023 · 34 comments
Closed

[BUG] Hook minemacs-first-file-hook doesn't seem to run #142

hmanhng opened this issue Dec 19, 2023 · 34 comments

Comments

@hmanhng
Copy link
Contributor

hmanhng commented Dec 19, 2023

Describe the bug
save-place-mode is enabled but inactive

Emacs version

GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0)

To Reproduce
Steps to reproduce the behavior:

  1. Open emacs
  2. The position is not the same as when exiting

Screenshots
image

Additional context
minemacs-first-file-hook don't run when opening any file
I tried running the hook (run-hooks 'minemacs-first-file-hook) in config.el and it worked.

@abougouffa
Copy link
Owner

abougouffa commented Dec 19, 2023

Weird, in my config, save-place-mode is working correctly.

Can you try to run Emacs in debug mode: MINEMACS_DEBUG=1 emacs and share the content of the *Messages* buffer

The position is not the same as when exiting

Can you test if this is valid for the first opened file or for all files?

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

Here is it

Loading /home/hmanhng/.minemacs.d/early-config.el (source)...done
Loading /nix/store/9mms3z06anpjpvwzd49n8gzrcayzpm2p-emacs-pgtk-29.1/share/emacs/site-lisp/site-start...done
Loading /home/hmanhng/.emacs.d/core/me-loaddefs.el (source)...done
Loading /home/hmanhng/.emacs.d/local/system-env.el (source)...done
[MinEmacs:Log] Setting up hook ‘minemacs-first-org-file-hook’ -- function ‘+first-file--org-h’ -- feature ‘minemacs-first-org-file’.
[MinEmacs:Log] Setting up hook ‘minemacs-first-elisp-file-hook’ -- function ‘+first-file--elisp-h’ -- feature ‘minemacs-first-elisp-file’.
[MinEmacs:Log] Setting up hook ‘minemacs-first-file-hook’ -- function ‘+first-file--h’ -- feature ‘minemacs-first-file’.
Loading /home/hmanhng/.emacs.d/core/me-modules.el (source)...done
Loading /home/hmanhng/.minemacs.d/modules.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-splash.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-bootstrap.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-builtin.el (source)...
Configuring package emacs...done
Configuring package tab-bar...done
Configuring package electric...done
Power AC, battery Not charging (97.9% load, remaining time N/A)
Loading /home/hmanhng/.emacs.d/core/me-builtin.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-gc.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-fonts.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-keybindings.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-evil.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-core-ui.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-completion.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-ui.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-editor.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-undo.el (source)...
Loading package undo-fu-session...done
Loading /home/hmanhng/.emacs.d/modules/me-undo.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-vc.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-project.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-prog.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-checkers.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-emacs-lisp.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-data.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-org.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-tools.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-tty.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-window.el (source)...done
Loading /home/hmanhng/.minemacs.d/config.el (source)...done
[MinEmacs:Log] Loaded init.el
[MinEmacs:Log] =============== Loaded Emacs ===============
[MinEmacs:Info] Loaded Emacs in 1.510869 seconds.
[MinEmacs:Log] Applying ‘minemacs-fonts’.
[MinEmacs:Log] Loading user theme: catppuccin
[MinEmacs:Log] Running 27 ‘minemacs-after-startup-hook’ hooks.
Configuring package which-key...done
Loading package general...
Configuring package general...done
Loading package general...done
Configuring package evil...done
Configuring package anzu...done
Configuring package nerd-icons...done
Configuring package doom-modeline...done
Configuring package solaire-mode...done
Configuring package corfu...done
Loading package nerd-icons-corfu...
Configuring package nerd-icons-corfu...done
Loading package nerd-icons-corfu...done
Configuring package corfu-history...done
Loading package vertico-directory...done
Configuring package pulsar...done
Configuring package treesit-auto...done
[MinEmacs:Log] Providing ‘minemacs-loaded’.
Loading package project...done
Loading package recentf...
Configuring package recentf...
Loading /home/hmanhng/.emacs.d/local/recentf-save.el (source)...done
Cleaning up the recentf list...done (0 removed)
Configuring package recentf...done
Loading package recentf...done
Loading package pixel-scroll...
Configuring package pixel-scroll...done
Loading package pixel-scroll...done
Loading package windmove...
Configuring package windmove...done
Loading package windmove...done
Loading package evil-collection...
Configuring package evil-collection...done
Loading package evil-collection...done
Loading package cape...
Configuring package cape...done
Loading package cape...done
Loading package orderless...done
Loading package elisp-demos...done
Loading package eros...
Configuring package eros...done
Loading package eros...done
[MinEmacs:Log] Loading the default persistent scratch buffer.
[MinEmacs:Log] Reading persistent scratch from /home/hmanhng/.emacs.d/local/pscratch/__default.el
[MinEmacs:Log] Settinng face ‘default’ to ‘(:family IBM Plex Mono :height 170)’
[MinEmacs:Log] Settinng face ‘fixed-pitch’ to ‘(:inherit default)’
[MinEmacs:Log] Settinng face ‘fixed-pitch-serif’ to ‘(:inherit default)’
[MinEmacs:Log] Settinng face ‘variable-pitch’ to ‘(:family Roboto)’
[MinEmacs:Log] Settinng script ‘emoji’ to ‘(:family Noto Color Emoji)’
[MinEmacs:Log] Running task 1, calling function ‘(closure (t) nil (require 'minemacs-laz…’
[MinEmacs:Log] Loading 1 lazy packages incrementally.
[MinEmacs:Log] Providing ‘minemacs-lazy’.
[MinEmacs:Log] Running task 4, calling function ‘(closure (t) nil (if (featurep 'native-…’
[MinEmacs:Info] Trying to clean outdated native compile cache
Cache cleared
[MinEmacs:Info] Trying to clean outdated straight build cache
[MinEmacs:Info] Trying to clean MinEmacs’ root directory
[MinEmacs:Log] Running task 3, calling function ‘(closure (t) nil (if (server-running-p)…’
[MinEmacs:Log] Running task 2, calling function ‘gcmh-mode’
Configuring package consult...done

@abougouffa
Copy link
Owner

Thanks @hmanhng

Can you redo it again but open a file after Emacs gets loaded! Otherwise I can't see if the hook is executed or not.

Please, can you try also if only the first opened file which doesn't restore its position or if it is valid for all opened files?

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

Can you test if this is valid for the first opened file or for all files?

oh it seems it only errors with the first file I open, with other files it works

Loading /home/hmanhng/.minemacs.d/early-config.el (source)...done
Loading /nix/store/9mms3z06anpjpvwzd49n8gzrcayzpm2p-emacs-pgtk-29.1/share/emacs/site-lisp/site-start...done
Loading /home/hmanhng/.emacs.d/core/me-loaddefs.el (source)...done
Loading /home/hmanhng/.emacs.d/local/system-env.el (source)...done
[MinEmacs:Log] Setting up hook ‘minemacs-first-org-file-hook’ -- function ‘+first-file--org-h’ -- feature ‘minemacs-first-org-file’.
[MinEmacs:Log] Setting up hook ‘minemacs-first-elisp-file-hook’ -- function ‘+first-file--elisp-h’ -- feature ‘minemacs-first-elisp-file’.
[MinEmacs:Log] Setting up hook ‘minemacs-first-file-hook’ -- function ‘+first-file--h’ -- feature ‘minemacs-first-file’.
Loading /home/hmanhng/.emacs.d/core/me-modules.el (source)...done
Loading /home/hmanhng/.minemacs.d/modules.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-splash.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-bootstrap.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-builtin.el (source)...
Configuring package emacs...done
Configuring package tab-bar...done
Configuring package electric...done
Power AC, battery Not charging (97.9% load, remaining time N/A)
Loading /home/hmanhng/.emacs.d/core/me-builtin.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-gc.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-fonts.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-keybindings.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-evil.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-core-ui.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-completion.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-ui.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-editor.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-undo.el (source)...
Loading package undo-fu-session...done
Loading /home/hmanhng/.emacs.d/modules/me-undo.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-vc.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-project.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-prog.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-checkers.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-emacs-lisp.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-data.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-org.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-tools.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-tty.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-window.el (source)...done
Loading /home/hmanhng/.minemacs.d/config.el (source)...done
[MinEmacs:Log] Loaded init.el
[MinEmacs:Log] =============== Loaded Emacs ===============
[MinEmacs:Info] Loaded Emacs in 1.684089 seconds.
[MinEmacs:Log] Applying ‘minemacs-fonts’.
[MinEmacs:Log] Loading user theme: catppuccin
[MinEmacs:Log] Running 27 ‘minemacs-after-startup-hook’ hooks.
Configuring package which-key...done
Loading package general...
Configuring package general...done
Loading package general...done
Configuring package evil...done
Configuring package anzu...done
Configuring package nerd-icons...done
Configuring package doom-modeline...done
Configuring package solaire-mode...done
Configuring package corfu...done
Loading package nerd-icons-corfu...
Configuring package nerd-icons-corfu...done
Loading package nerd-icons-corfu...done
Configuring package corfu-history...done
Loading package vertico-directory...done
Configuring package pulsar...done
Configuring package treesit-auto...done
[MinEmacs:Log] Providing ‘minemacs-loaded’.
Loading package project...done
Loading package recentf...
Configuring package recentf...
Loading /home/hmanhng/.emacs.d/local/recentf-save.el (source)...done
Cleaning up the recentf list...done (0 removed)
Configuring package recentf...done
Loading package recentf...done
Loading package pixel-scroll...
Configuring package pixel-scroll...done
Loading package pixel-scroll...done
Loading package windmove...
Configuring package windmove...done
Loading package windmove...done
Loading package evil-collection...
Configuring package evil-collection...done
Loading package evil-collection...done
Loading package cape...
Configuring package cape...done
Loading package cape...done
Loading package orderless...done
Loading package elisp-demos...done
Loading package eros...
Configuring package eros...done
Loading package eros...done
[MinEmacs:Log] Loading the default persistent scratch buffer.
[MinEmacs:Log] Reading persistent scratch from /home/hmanhng/.emacs.d/local/pscratch/__default.el
[MinEmacs:Log] Settinng face ‘default’ to ‘(:family IBM Plex Mono :height 180)’
[MinEmacs:Log] Settinng face ‘fixed-pitch’ to ‘(:inherit default)’
[MinEmacs:Log] Settinng face ‘fixed-pitch-serif’ to ‘(:inherit default)’
[MinEmacs:Log] Settinng face ‘variable-pitch’ to ‘(:family Roboto)’
[MinEmacs:Log] Settinng script ‘emoji’ to ‘(:family Noto Color Emoji)’
Quit
[MinEmacs:Log] Running 5 ‘minemacs-first-file-hook’ hooks.
Loading package epa-file...
Configuring package epa-file...
‘epa-file’ already enabled
Configuring package epa-file...done
Loading package epa-file...done (0.120s)
Configuring package super-save...done
[MinEmacs:Log] Running 0 ‘minemacs-first-org-file-hook’ hooks.
Loading package oc-csl...
Configuring package bibtex...done
Loading package oc-csl...done (0.132s)
Loading package oc-natbib...done
Loading package oc-biblatex...done
Loading package ob-mermaid...
Configuring package ob-mermaid...done
Loading package ob-mermaid...done
Loading package ob-d2...
Configuring package ob-d2...done
Loading package ob-d2...done
Configuring package org...done (0.543s)
Loading package org-indent...done
Loading package oc...
Configuring package oc...done
Loading package oc...done
Loading package me-org-extras...
Configuring package me-org-extras...
LaTeX numbering enabled.
Configuring package me-org-extras...done
Loading package me-org-extras...done
Loading package org-contrib...done
Configuring package tempel...done
Loading package tempel-collection...done
Loading package evil-org-agenda...
Configuring package evil-org-agenda...done
Loading package evil-org-agenda...done
Configuring package org-appear...done
Configuring package ssh-deploy...done
Configuring package hl-todo...done
Configuring package highlight-numbers...done
Configuring package compile...done
Configuring package flymake...done
Configuring package parinfer-rust-mode...done
[MinEmacs:Log] Running task 1, calling function ‘(closure (t) nil (require 'minemacs-laz…’
[MinEmacs:Log] Loading 1 lazy packages incrementally.
[MinEmacs:Log] Providing ‘minemacs-lazy’.
[MinEmacs:Log] Running task 4, calling function ‘(closure (t) nil (if (featurep 'native-…’
[MinEmacs:Info] Trying to clean outdated native compile cache
Cache cleared
[MinEmacs:Info] Trying to clean outdated straight build cache
[MinEmacs:Info] Trying to clean MinEmacs’ root directory
[MinEmacs:Log] Running task 3, calling function ‘(closure (t) nil (if (server-running-p)…’
[MinEmacs:Info] Started Emacs daemon in background.
[MinEmacs:Log] Running task 2, calling function ‘gcmh-mode’
Configuring package consult...done
Error in post-command-hook (selection-highlight-mode-post-command-hook): (args-out-of-range #<buffer *Messages*> 1 7208)

@abougouffa
Copy link
Owner

Thank you for your responsiveness.

Well, as I see, the hooks are running correctly after opening the first file:

[MinEmacs:Log] Running 5 ‘minemacs-first-file-hook’ hooks.

I will push a small fix so it enables save-place-mode before that.

@abougouffa
Copy link
Owner

Can you try it now please ? @hmanhng

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

Well, as I see, the hooks are running correctly after opening the first file:

That's after I opened up emacs and find-find and open a new file
if I just MINEMACS_DEBUG=1 emacs readme.org it won't be loaded. Here

Loading /home/hmanhng/.minemacs.d/early-config.el (source)...done
Loading /nix/store/9mms3z06anpjpvwzd49n8gzrcayzpm2p-emacs-pgtk-29.1/share/emacs/site-lisp/site-start...done
Loading /home/hmanhng/.emacs.d/core/me-loaddefs.el (source)...done
Loading /home/hmanhng/.emacs.d/local/system-env.el (source)...done
[MinEmacs:Log] Setting up hook ‘minemacs-first-org-file-hook’ -- function ‘+first-file--org-h’ -- feature ‘minemacs-first-org-file’.
[MinEmacs:Log] Setting up hook ‘minemacs-first-elisp-file-hook’ -- function ‘+first-file--elisp-h’ -- feature ‘minemacs-first-elisp-file’.
[MinEmacs:Log] Setting up hook ‘minemacs-first-file-hook’ -- function ‘+first-file--h’ -- feature ‘minemacs-first-file’.
Loading /home/hmanhng/.emacs.d/core/me-modules.el (source)...done
Loading /home/hmanhng/.minemacs.d/modules.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-splash.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-bootstrap.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-builtin.el (source)...
Configuring package emacs...done
Configuring package tab-bar...done
Configuring package electric...done
Power AC, battery Not charging (97.9% load, remaining time N/A)
Loading /home/hmanhng/.emacs.d/core/me-builtin.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-gc.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-fonts.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-keybindings.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-evil.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-core-ui.el (source)...done
Loading /home/hmanhng/.emacs.d/core/me-completion.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-ui.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-editor.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-undo.el (source)...
Loading package undo-fu-session...done
Loading /home/hmanhng/.emacs.d/modules/me-undo.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-vc.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-project.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-prog.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-checkers.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-emacs-lisp.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-data.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-org.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-tools.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-tty.el (source)...done
Loading /home/hmanhng/.emacs.d/modules/me-window.el (source)...done
Loading /home/hmanhng/.minemacs.d/config.el (source)...done
[MinEmacs:Log] Loaded init.el
Loading package oc-csl...
Configuring package bibtex...done
Loading package oc-csl...done (0.129s)
Loading package oc-natbib...done
Loading package oc-biblatex...done
Configuring package org...done (0.881s)
Loading package org-indent...done
Loading package oc...
Configuring package oc...done
Loading package oc...done
Loading package me-org-extras...
Configuring package me-org-extras...
LaTeX numbering enabled.
Configuring package me-org-extras...done
Loading package me-org-extras...done
Loading package org-contrib...done
Configuring package tempel...done
Loading package tempel-collection...done
Loading package general...
Configuring package general...done
Loading package general...done
Configuring package evil...done
Loading package evil-org-agenda...
Configuring package evil-org-agenda...done
Loading package evil-org-agenda...done
Configuring package org-appear...done
Configuring package ssh-deploy...done
[MinEmacs:Log] =============== Loaded Emacs ===============
[MinEmacs:Info] Loaded Emacs in 2.253214 seconds.
[MinEmacs:Log] Applying ‘minemacs-fonts’.
[MinEmacs:Log] Loading user theme: catppuccin
[MinEmacs:Log] Running 27 ‘minemacs-after-startup-hook’ hooks.
Configuring package which-key...done
Configuring package anzu...done
Configuring package nerd-icons...done
Configuring package doom-modeline...done
Configuring package solaire-mode...done
Configuring package corfu...done
Loading package nerd-icons-corfu...
Configuring package nerd-icons-corfu...done
Loading package nerd-icons-corfu...done
Configuring package corfu-history...done
Loading package vertico-directory...done
Configuring package pulsar...done
Configuring package treesit-auto...done
[MinEmacs:Log] Providing ‘minemacs-loaded’.
Loading package project...done
Loading package recentf...
Configuring package recentf...
Loading /home/hmanhng/.emacs.d/local/recentf-save.el (source)...done
Cleaning up the recentf list...done (0 removed)
Configuring package recentf...done
Loading package recentf...done
Loading package pixel-scroll...
Configuring package pixel-scroll...done
Loading package pixel-scroll...done
Loading package windmove...
Configuring package windmove...done
Loading package windmove...done
Loading package evil-collection...
Configuring package evil-collection...done (0.131s)
Loading package evil-collection...done (0.170s)
Loading package cape...
Configuring package cape...done
Loading package cape...done
Loading package orderless...done
Loading package elisp-demos...done
Loading package eros...
Configuring package eros...done
Loading package eros...done
[MinEmacs:Log] Loading the default persistent scratch buffer.
[MinEmacs:Log] Reading persistent scratch from /home/hmanhng/.emacs.d/local/pscratch/__default.el
[MinEmacs:Log] Settinng face ‘default’ to ‘(:family IBM Plex Mono :height 180)’
[MinEmacs:Log] Settinng face ‘fixed-pitch’ to ‘(:inherit default)’
[MinEmacs:Log] Settinng face ‘fixed-pitch-serif’ to ‘(:inherit default)’
[MinEmacs:Log] Settinng face ‘variable-pitch’ to ‘(:family Roboto)’
[MinEmacs:Log] Settinng script ‘emoji’ to ‘(:family Noto Color Emoji)’
Configuring package hl-todo...done
Configuring package highlight-numbers...done
Configuring package compile...done
Configuring package flymake...done
Configuring package parinfer-rust-mode...done
Configuring package consult...done
[MinEmacs:Log] Running task 1, calling function ‘(closure (t) nil (require 'minemacs-laz…’
[MinEmacs:Log] Loading 1 lazy packages incrementally.
[MinEmacs:Log] Providing ‘minemacs-lazy’.
[MinEmacs:Log] Running task 4, calling function ‘(closure (t) nil (if (featurep 'native-…’
[MinEmacs:Info] Trying to clean outdated native compile cache
Cache cleared
[MinEmacs:Info] Trying to clean outdated straight build cache
[MinEmacs:Info] Trying to clean MinEmacs’ root directory
[MinEmacs:Log] Running task 3, calling function ‘(closure (t) nil (if (server-running-p)…’
[MinEmacs:Info] Started Emacs daemon in background.
[MinEmacs:Log] Running task 2, calling function ‘gcmh-mode’
Mark saved where search started [2 times]
or: Beginning of buffer [2 times]
or: Beginning of buffer

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

Can you try it now please ? @hmanhng

i will try now

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

Looks like it's not working yet.

@abougouffa
Copy link
Owner

if I just MINEMACS_DEBUG=1 emacs readme.org it won't be loaded. Here

Yep, the current implementation doesn't run the hook on the first file if passed as an argument. I will try to fix it later, but for the moment, this doesn't bother me that much.

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

I think that can fix with :init (save-place-mode)
It seems that sava-place-mode needs to be loaded before loading the package, this issue is similar to undo-fu-session, if you put it in a hook after loading emacs it won't work properly, undo history doesn't work -> vundo doesn't work.

Also minemacs-first-file-hook is not loaded the first time the file is opened which is quite annoying when the *-modes you put in are not loaded like evcrc, selection-hightlight, ...

@abougouffa
Copy link
Owner

Yep, you're right, @hmanhng.

In my workflow, I never open a file with Emacs from GUI ("double-clicking" a file or "open with Emacs", ...), so I didn't notice these issues.

I will push a fix for this later. Thank you for bringing it to my attention.

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

I think that can fix with :init (save-place-mode) It seems that sava-place-mode needs to be loaded before loading the package, this issue is similar to undo-fu-session, if you put it in a hook after loading emacs it won't work properly, undo history doesn't work -> vundo doesn't work.

I created a pull request for save-place and undo-fu-session that fixes this

@abougouffa
Copy link
Owner

I've pushed fixes for both of them. There is no need to enable undo-fu-session in :init. This isn't working because undo-fu-session global mode has bee renamed and I didn't notice it. Now it should be fixed.

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 19, 2023

I've pushed fixes for both of them. There is no need to enable undo-fu-session in :init. This isn't working because undo-fu-session global mode has bee renamed and I didn't notice it. Now it should be fixed.

hmm, undo-fu-session may work but only if you are keep running emacs, after exiting emacs and reopening the file, it cannot be undo history.

@abougouffa
Copy link
Owner

Yep, you're right, I've just tested it. I've pushed a fix for it, thanks again!

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 20, 2023

@abougouffa I think this issue is still not fixed, minemacs-first-file-hook still cannot start the first time

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 20, 2023

Additionally, I got an issue similar to the following:

Steps to reproduce the behavior:

  1. Put in config.el
(+deferred!
 (+eglot-register '(java-mode java-ts-mode) `("jdt-language-server" "-data" ,(expand-file-name "java-workspace" minemacs-cache-dir)))

 (+eglot-auto-enable)
 ;; Auto enable eglot
 (with-eval-after-load 'eglot
   ;; You can use this to fill `+eglot-auto-enable-modes' with all supported
   ;; modes from `eglot-server-programs'
   (+eglot-use-on-all-supported-modes eglot-server-programs)))
  1. Open any .java file
    -> eglot is not started

If I replace the following it works

(add-hook 'java-mode-hook #'eglot-ensure)

(+deferred!
 (+eglot-register '(java-mode java-ts-mode) `("jdt-language-server" "-data" ,(expand-file-name "java-workspace" minemacs-cache-dir)))

 ;; (+eglot-auto-enable)
 ;; Auto enable eglot
 (with-eval-after-load 'eglot
   ;; You can use this to fill `+eglot-auto-enable-modes' with all supported
   ;; modes from `eglot-server-programs'
   (+eglot-use-on-all-supported-modes eglot-server-programs)))

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 20, 2023

If I add (add-hook 'java-mode-hook #'eglot-ensure) in (+deferred!...) as follows also doesn't work

(+deferred!
  (+eglot-register '(java-mode java-ts-mode) `("jdt-language-server" "-data" ,(expand-file-name "java-workspace" minemacs-cache-dir)))
  (add-hook 'java-mode-hook #'eglot-ensure)
 ;; (+eglot-auto-enable)
 ;; Auto enable eglot
  (with-eval-after-load 'eglot
    (+eglot-use-on-all-supported-modes eglot-server-programs)))

Both minemacs-first-file-hook and the above example have the same problem, when you add a language hook like java-mode-hook after minemacs-loaded it doesn't work

@abougouffa
Copy link
Owner

Thank you for the feedback @hmanhng

I'm reopening the issue and I will take a look at it later. Thanks again!

@abougouffa abougouffa reopened this Dec 21, 2023
@abougouffa
Copy link
Owner

abougouffa commented Dec 21, 2023

@hmanhng

The Eglot issue isn't related to minemacs-first-file-hook.

The documentation for the +eglot-auto-enable says:

Signature

(+eglot-auto-enable)

Documentation

Auto-enable Eglot in configured modes in +eglot-auto-enable-modes.

So you need to add java-mode to +eglot-auto-enable-modes, the default value doesn't include Java.

Documentation for +eglot-auto-enable-modes is:

Value

(c++-mode c++-ts-mode c-mode c-ts-mode python-mode python-ts-mode rust-mode rust-ts-mode cmake-mode js-mode js-ts-mode typescript-mode typescript-ts-mode json-mode json-ts-mode js-json-mode)

Documentation

Modes for which Eglot can be automatically enabled by +eglot-auto-enable.


I've pushed a fix for better invocation of minemacs-first-file-hook, testing is appreciated!

@abougouffa
Copy link
Owner

It seems that (+eglot-use-on-all-supported-modes eglot-server-programs) isn't working correctly, I will take a look at it later.

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 21, 2023

I've pushed a fix for better invocation of minemacs-first-file-hook, testing is appreciated!

Now minemacs-first-file-hook work perfect

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 21, 2023

It seems that (+eglot-use-on-all-supported-modes eglot-server-programs) isn't working correctly, I will take a look at it later.

Even if I added the following

(+deferred!
 (+eglot-register '(java-mode java-ts-mode) `("jdt-language-server" "-data" ,(expand-file-name "java-workspace" minemacs-cache-dir)))
 (add-to-list '+eglot-auto-enable-modes 'java-mode)
 (+eglot-auto-enable))

or

(+deferred!
 (+eglot-register '(java-mode java-ts-mode) `("jdt-language-server" "-data" ,(expand-file-name "java-workspace" minemacs-cache-dir)))
 (add-to-list '+eglot-auto-enable-modes 'java-mode))
(+eglot-auto-enable)

+eglot-auto-enable-modes got java-mode but eglot still doesn't work, the problem probably lies (+eglot-auto-enable).

not only with java-mode, I tried with built-in cpp, ..., neither worked.

@abougouffa
Copy link
Owner

Thank you again @hmanhng , I really appreciate your help!

I will take a look at Eglot auto enable (I'm not using it in my config, hence, I didn't notice that it is not working).

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 22, 2023

@abougouffa I tried again 1 time with (add-to-list '+eglot-auto-enable-modes 'java-mode) (+eglot-auto-enable) outside `(+deferred! ...) , it works normally.

(add-to-list '+eglot-auto-enable-modes 'java-mode)
(+eglot-auto-enable)
(+deferred!
 (+eglot-register
  '(java-mode java-ts-mode) `("jdt-language-server" "-data" ,(expand-file-name "java-workspace" minemacs-cache-dir))))

If you include (+eglot-auto-enable) or (add-hook 'java-mode-hook #'eglot-ensure) in (+deferred!..) it will not work.

Is the problem that language-mode-hook is loaded before minemacs-loaded so injecting the hook after it has been loaded has no effect, even though Ch o still shows java- mode-hook has eglot-ensure ?

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 22, 2023

Also I checked (+eglot-use-on-all-supported-modes eglot-server-programs) is not wrong but eglot-server-programs is only created when eglot is enabled, does that mean:

+eglot-use-on-all-supported-modes  ----> eglot-server-programs -----> eglot -----> +eglot-auto-enable
                   ^                                                                     |
                   |                                                                     |
                   |  ----------------------<<---------------<<------------------------  v

test with:

(with-eval-after-load 'eglot
  (+eglot-register
   '(java-mode java-ts-mode) `("jdt-language-server" "-data" ,(expand-file-name "java-workspace" minemacs-cache-dir)))
  (+eglot-use-on-all-supported-modes eglot-server-programs))

(nconc +eglot-auto-enable-modes '(java-mode java-ts-mode))
(+eglot-auto-enable)

and enable in java-mode
image

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 23, 2023

It seems like just running emacs with the client will fix everything
I will close the issue, thank for your help!

@hmanhng hmanhng closed this as completed Dec 23, 2023
@abougouffa
Copy link
Owner

In order for this to work, you would need to call +eglot-auto-enable after calling (+eglot-use-on-all-supported-modes eglot-server-programs). However, if you add additional modes to eglot-server-programs with +eglot-register for example, these modes won't be taken into account unless you've called (+eglot-use-on-all-supported-modes eglot-server-programs) after that or add the mode to +eglot-auto-enable-modes manually.

I admit, this is too technical and needs to know the internal implementation details of these functions.

I will try to implement this in a more convenient manner.

@abougouffa
Copy link
Owner

abougouffa commented Dec 23, 2023

@hmanhng
The last commit 26f6784 changes the logic of +eglot-auto-enable, now it should work independently of when you set +eglot-auto-enable-modes or call +eglot-use-on-all-supported-modes

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 23, 2023

Thank you very much for your help, I did (use-packages lang ... ) to make it more convenient for custom language configuration.

I've always been looking for an emacs configuration without deamon, but it seems difficult for emacs due to the number of packages and long loading time compared to neovim. Just for the inconvenience wm hyprland does not swallow emacsclient (works with emacs) when I open a file from terminal (emacsclient -nw -c file).
I will have to get used to that. You should also add to your docs that those using configuration should use emacsclient. Using only emacs will cause problems due to packages being load lazy.

Anyway thank you very much for your help. I don't have the time or good enough knowledge to learn elisp so I will use your minemacs as the core for my configuration instead of doomemacs

@abougouffa
Copy link
Owner

@hmanhng
MinEmacs is not intended to work only on daemon, I use it in both daemon and non-daemon mode and it should work correctly. Please don't hesitate to report any issues caused by Emacs being run in a non daemon mode.

Thank you for the feedback.

@hmanhng
Copy link
Contributor Author

hmanhng commented Dec 24, 2023

I usually open the terminal and open a file with emacs from here emacs file. Unlike others who will open emacs, search and open files in it. It seems that opening emacs with files is quite slow so I used emacsclient.

Also if necessary I will report back the issue I get when using emacs file, which probably only appear with things that need to be loaded early with the language hook.

Thank you for your assistance.

@abougouffa
Copy link
Owner

Also if necessary I will report back the issue I get when using emacs file, which probably only appear with things that need to be loaded early with the language hook.

Yes, please, I'll really appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants