2

I have org-mode files about 50K lines long, which I can edit and save file; but once in a while accidentally marked a large region by typing C-x C-x or C-x h, and copied too much data into clipboard, so Emacs hangs until killed by oom.

Is there a mode or customization helping to limit mark/kill size to avoid this pain?

gb2312
  • 21
  • 2
  • Maybe I can simply disable transient mark minor mode for the big file --- might be a good compromise. – gb2312 Feb 16 '21 at 20:32
  • 1
    For org-mode specifically, you might find https://github.com/yantar92/org is helpful to experiment with; and for (certain aspects of) performance more generally, there's https://www.emacswiki.org/emacs/GccEmacs . I'm only guessing, but I suspect the former could make a significant difference in your case. – phils Feb 16 '21 at 22:51
  • 1
    Alternatively, do you have the same problem with this file if you use `emacs -Q` ? If not, then the main culprit is probably not org-mode itself, but something else in your config. – phils Feb 16 '21 at 22:53

1 Answers1

1

It's not clear to me why Emacs hangs in what you describe, or what you mean by that.

But I think you're talking about accidentally defining a large region of text, and then killing or copying that, and that it is that killing or copying that you want to avoid.

If that's the case, then this may help: wimpy-del.el. It's what I bind to C-w, in place of kill-region. It's a silly little thing I picked up somewhere eons ago, but I've become used to it and like it.

Here's the doc string:

Kill the text between BEG and END, putting it in the kill ring.

(Interactively, uses the region.)

If the previous command was a completion, just remove the completion. Else, if the region is > wimpy-delete-size, you must confirm the kill.

Pretty simple, really. Mostly it just asks you to confirm killing if the region size is greater than the value of variable wimpy-delete-size.

(The part about previous command being a "completion" isn't very relevant nowadays. That refers to the use of standard Emacs library completion.el, which is useful but which hardly anyone is even aware of anymore, even though it's still part of Emacs.)

Drew
  • 75,699
  • 9
  • 109
  • 225
  • Thanks, that would be a great help. But there are other cases that is causing same oom problem: simply marking a large region & etc. – gb2312 Feb 16 '21 at 20:28
  • You can apply the same logic/code to those situations. The heart of the code just compares the size of some text (e.g. region size) with some predefined threshold that you set, and queries the user to confirm something when the threshold is exceeded. – Drew Feb 16 '21 at 23:28