Jambunathan K <kjambunat...@gmail.com> writes: >> Good idea. There is `post-self-insert-hook' but there is no >> `pre-self-insert-hook' that would check whether the point is in >> an invisible area of the buffer, and send a warning about this. > > In org-self-insert-command check for visibility at point and take the > required action.
That's it. Thanks! Here is a dummy patch that prevents the user from editing invisible parts of the buffer. It doesn't prevent query-and-replace commands. Can people test it and comment it? Maybe throwing an error is a bit too much. Maybe preventing all kind of edition in invisible parts of the buffer is too much as well -- looking forward reading comments on this. Thanks,
>From 442f30b74f3f4eb888b63cb5d2cd04542952f84a Mon Sep 17 00:00:00 2001 From: Bastien Guerry <b...@altern.org> Date: Sat, 22 Oct 2011 15:50:52 +0200 Subject: [PATCH] Prevent `self-insert-command' in invisible regions. * org.el (org-self-insert-command): Throw an error when the user is trying to use self-insert-command in invisible regions. --- lisp/org.el | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d82ae0c..627faa3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -17328,6 +17328,9 @@ If the cursor is in a table looking at whitespace, the whitespace is overwritten, and the table is not marked as requiring realignment." (interactive "p") (cond + ((eq (car (get-char-property-and-overlay + (point) 'invisible)) 'outline) + (error "Attempt to edit an invisible part of the buffer")) ((and org-use-speed-commands (setq org-speed-command (run-hook-with-args-until-success -- 1.7.6.1
-- Bastien