muffinmad / emacs-mini-frame

Show minibuffer in child frame on read-from-minibuffer
GNU General Public License v3.0
314 stars 20 forks source link

Mini-frame & evil eat a single preceding whitespace character in an Org Capture template when using prompts %^{Like_This}, breaking capture templates #85

Open n-hebert opened 4 months ago

n-hebert commented 4 months ago

Mini-frame is great, I love having the mini-buffer floating and centered. However, it has an odd bug where it consumes whitespace preceding prompts for user input.

Background

Issue

Mini-frame actually consumes the space there prior to the %^{Title}. When I have mini-frame-mode on, and I run a capture, it says to me that the Org entry is invalid and it fails to capture.

Steps to Reproduce

  1. Install evil, mini-frame and the capture template using the .emacs below
  2. Run an org-capture and try to complete normally (give input and C-c C-c)

Config

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(package-refresh-contents)

(unless (package-installed-p 'evil)  (package-install 'evil)) ;; impacted version is evil 1.15.0
(require 'evil)
(evil-mode 1)

(unless (package-installed-p 'mini-frame)
  (package-install 'mini-frame))
(mini-frame-mode)

(setq org-capture-templates
      '(("p" "With prompt" entry (file+headline "~/org/test.org" "Test")
         "* %^{Title}\n#+BEGIN_QUOTE\n%?\n#+END_QUOTE")))

Expected Result

Mini-frame lets me type a title and then captures the snippet

Actual Result

Mini-frame interacts with evil and consumes preceding whitespace and results in a bad capture. This does not occur with only evil or only mini-frame.

muffinmad commented 3 months ago

I've setup org-capture-templates like this:

(setq org-capture-templates
      '(("p" "With prompt" entry (file+headline "~/org/test.org" "Test")
         "* %^{Title}\n#+BEGIN_QUOTE\n%?\n#+END_QUOTE")))

Then M-x org-capture and p

Screenshot 2024-03-17 at 10 01 49

After confirming the title I can enter text in quote block

Screenshot 2024-03-17 at 10 02 07

And after C-c C-c the ~/org/test.org looks like this

Screenshot 2024-03-17 at 10 04 36

I don't see what the problem is.

n-hebert commented 3 months ago

Hm! I'll get you a config or provide a video for further analysis; maybe it's like #86 and not a mini-frame problem

n-hebert commented 3 months ago

Got it! It's an interaction with evil. Toss this into your ~/.emacs and try

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(package-refresh-contents)

(unless (package-installed-p 'evil)  (package-install 'evil))
(require 'evil)
(evil-mode 1)

(unless (package-installed-p 'mini-frame)
  (package-install 'mini-frame))
(mini-frame-mode)

(setq org-capture-templates
      '(("p" "With prompt" entry (file+headline "~/org/test.org" "Test")
         "* %^{Title}\n#+BEGIN_QUOTE\n%?\n#+END_QUOTE")))

Any ideas?

muffinmad commented 3 months ago

Hmm. Even with the evil mode enabled I can use capture template with prompt without errors.

n-hebert commented 3 months ago

Hm! Is it somehow operating system related? I'm on Pop!_OS 22.04 LTS and Arch Linux.

I'll record a screen cast of it and post back, maybe there's something in the mix that's slipping my eyeline to pin down in text.

n-hebert commented 3 months ago

:grey_exclamation:

It's only happening on emacs 29 or later -- version check? My version 27 seems ok.

muffinmad commented 3 months ago

Mine is

GNU Emacs 29.1.50 (build 1, aarch64-apple-darwin22.5.0, NS
 appkit-2299.60 Version 13.4.1 (c) (Build 22F770820d)) of 2023-08-23
n-hebert commented 3 months ago

That's lending credence to the OS constraint.

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

Perhaps try 29.2, as well? I'm also near the tip of emacs master (commit: c5de73a95), if that's easier -- GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2024-03-24

Evil version 1.15.0 everywhere.

muffinmad commented 3 months ago

Can reproduce in Emacs 29.2 GTK version. As a workaround, enter space before the variable value :)

n-hebert commented 3 months ago

heh, excellent. yeah I have spaces through-out my variables but then I add new ones and forget :laughing:

Any idea where the fix lies? Mini-frame's codebase or evil or Emacs? It's a real toss-up and I'm not sure where yet.

muffinmad commented 3 months ago

Any idea where the fix lies?

Unfortunately, but I have no idea at the moment.