~bzg/org-mode

4ae5cc0182bc3db5dc96833cee9c4979f4bc0ded — Ihor Radchenko a month ago 6cb0889
org-self-insert-command: Prevent deleting selection for speed commands

* lisp/org.el (org--speed-command-p): New helper function checking
whether current command is a speed command.
(org-self-insert-command): Use the new helper.
* lisp/org.el: In `delete-selection' property of
`org-self-insert-command' symbol, signal that selection must not be
deleted when current command is a speed command.

Reported-by: Joe Gilder <joe@homestudiocorner.com>
Link: https://orgmode.org/list/87il0voeok.fsf@localhost
1 files changed, 14 insertions(+), 8 deletions(-)

M lisp/org.el
M lisp/org.el => lisp/org.el +14 -8
@@ 16499,6 16499,16 @@ either not currently on a tagged headline or on a tag."
	     (< (point) (match-beginning 1)))
    (org-align-tags)))

(defun org--speed-command-p ()
  "Return non-nil when current command is a speed command.
Set `org-speed-command' to the appropriate command as a side effect."
  (and org-use-speed-commands
       (let ((kv (this-command-keys-vector)))
	 (setq org-speed-command
	       (run-hook-with-args-until-success
		'org-speed-command-hook
		(make-string 1 (aref kv (1- (length kv)))))))))

(defun org-self-insert-command (N)
  "Like `self-insert-command', use overwrite-mode for whitespace in tables.
If the cursor is in a table looking at whitespace, the whitespace is


@@ 16506,12 16516,7 @@ overwritten, and the table is not marked as requiring realignment."
  (interactive "p")
  (org-fold-check-before-invisible-edit 'insert)
  (cond
   ((and org-use-speed-commands
	 (let ((kv (this-command-keys-vector)))
	   (setq org-speed-command
		 (run-hook-with-args-until-success
		  'org-speed-command-hook
		  (make-string 1 (aref kv (1- (length kv))))))))
   ((org--speed-command-p)
    (cond
     ((commandp org-speed-command)
      (setq this-command org-speed-command)


@@ 16621,8 16626,9 @@ because, in this case the deletion might narrow the column."
;; Make `delete-selection-mode' work with Org mode and Orgtbl mode
(put 'org-self-insert-command 'delete-selection
     (lambda ()
       (not (run-hook-with-args-until-success
             'self-insert-uses-region-functions))))
       (unless (org--speed-command-p)
         (not (run-hook-with-args-until-success
             'self-insert-uses-region-functions)))))
(put 'orgtbl-self-insert-command 'delete-selection
     (lambda ()
       (not (run-hook-with-args-until-success