Klojer / obsidian-emacs-text-editor

GNU General Public License v3.0
21 stars 4 forks source link

Added kill ring buffer support #4

Closed mlwelles closed 8 months ago

mlwelles commented 9 months ago

Added kill ring buffer support

Logging changes

Makefile changes

Klojer commented 8 months ago

Hi, thank you for cool PR!

Possibility to have clipboard history can really improve usability of Obsidian, but I'm not sure that embedding this functionality into the plugin can be the best solution for this case.

I want to propose an option with the plugin: https://github.com/Karakaz/obsidian-paste-from-history/tree/master

It doesn't work out of the box, and need a small patch of emacs-text-editor:

diff --git a/main.ts b/main.ts
index 13264a2..5cd8657 100644
--- a/main.ts
+++ b/main.ts
@@ -178,6 +178,7 @@ export default class EmacsTextEditorPlugin extends Plugin {
                                }

                                navigator.clipboard.writeText(editor.getSelection())
+                               document.dispatchEvent(new ClipboardEvent('copy'));

                                this.disableSelection(editor)
                        }
@@ -193,6 +194,7 @@ export default class EmacsTextEditorPlugin extends Plugin {

                                navigator.clipboard.writeText(editor.getSelection())
                                editor.replaceSelection("")
+                               document.dispatchEvent(new ClipboardEvent('cut'));

                                this.disableSelection(editor)
                        }

From my side it's better option, because:

  1. By design, emacs-text-editor should stay as small as possible to avoid overlapping functionality (and potential conflicts) with Obsidian runtime (and other plugins)
  2. Plugin Karakaz/obsidian-paste-from-history has native UI

Does it make sense?

Klojer commented 8 months ago

Solution from my previous comment added to Version 0.4.0.

mlwelles commented 8 months ago

Does it make sense?

Yes, but I think it means the plugin is misnamed.

It simply doesn't provide "emacs text editing" . I believe what's most important is that if you call it "emacs text support" it work like emacs. Kill and yank is not copy and paste. It's fundamentally different.

This is how it works in emacs.
And how it works in readline -- open a terminal and run bash or zsh, kill and yank works just like it does in in emacs -- not tied to the UI clipboard.
And how it works in macOS in every native text input widget since the NeXT step days. Integrated kill ring / yank support that is entirely independent of the application "cut and paste" clipboard.

One of the most furstrating things for me about using electron apps is that they don't use native widgets, and baseline text editing keystrokes that work everywhere else in the OS are broken.

I certainly don't begrudge your desire to create something different that you think would be better. Go for it!

But "emacs like" text editing isn't just keybindings. There's very specific (and long established) set of functionality that come with it. And folks like me who install it expecting that it provides these are going provided to be frustrated.

Again -- yank and kill is not copy and paste.

I'll probably go ahead and fork and publish my fork under a different name.

There's two different peers of mine I've recommended Obsidian to that abandoned it because, as they put it "editing is broken", and went back to using org-mode. I'd like to give them (and me) a reason to keep using it.

Klojer commented 7 months ago

I completely agree that yank and kill is much more than just copy and paste.

Maybe this plugin (I've not tried it yet) can provide a more complete emacs-like experience.

Thank you again for your involvement.