all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug: org-catch-invisible-edits doesn't actually catch most deletions [9.4 (9.4-41-g9bb930-elpaplus @ /home/omarantolin/.emacs.d/elpa/org-plus-contrib-20201116/)]
@ 2020-11-23  6:33 Omar Antolín Camarena
  2024-02-10 16:11 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Omar Antolín Camarena @ 2020-11-23  6:33 UTC (permalink / raw)
  To: emacs-orgmode


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

Setting org-catch-invisible-edits to 'error does catch org-delete-backward-char (bound to <backspace> by default), but it doesn't catch backward-kill-word (<C-backspace>), or kill-word with argument -1 (M-- M-d), or backward-kill-sexp (ESC <C-backspace>).

Steps to reproduce:

1. Create an org file with the following 3 lines:

* Stop, hammer time!
You can't touch this
* Break it down!

2. Run emacs -Q and visit the file.

3. M-: (setq org-catch-invisible-edits 'error)

4. Make sure the first headline is folded and place point after the ellipsis.

5. Now you can try any of the commands mentioned in the first paragraph.

The org-catch-invisible-edits will successfully block you from using <backspace>, but any of the other command I mentioned will silently delete the word "this". Because of the variable's name, I would expect all these commands to be blocked.

Maybe technically this isn't a bug, since the docstring for org-catch-invisible-edits only says: "Check if in invisible region before inserting or deleting a character." So you can argue it only promises to block deletion if you attempt it one character at a time, and if you try to delete a word, the docstring doesn't promise to stop you.

I'd suggest that naming the variable org-catch-invisible-edits strongly suggests it should catch all deletions in the invisible text and that the current behavior is misleading.

Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2020-10-13, unofficial emacs-snapshot build: http://emacs.ganneff.de/, git commit 8d241e8840fdb02dcfce52425626dd8f2125e51a
Package: Org mode version 9.4 (9.4-41-g9bb930-elpaplus @ /home/omarantolin/.emacs.d/elpa/org-plus-contrib-20201116/)

current state:
==============
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
                     org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-refile-targets '((nil :maxlevel . 2) ("~/Notes/Notes.org" :maxlevel . 2)
                      ("~/Notes/Someday.org" :level . 0)
                      ("~/Notes/Daily.org" :level . 3))
 org-pretty-entities t
 org-capture-bookmark nil
 org-latex-default-packages-alist '(("AUTO" "inputenc" t ("pdflatex"))
                                    ("" "graphicx" t) ("" "grffile" t)
                                    ("" "longtable" nil) ("" "wrapfig" nil)
                                    ("" "rotating" nil) ("normalem" "ulem" t)
                                    ("" "amsmath" t) ("" "amssymb" t)
                                    ("" "capt-of" nil) ("" "hyperref" nil))
 org-special-ctrl-a/e t
 org-agenda-files '("~/Notes/Refile.org" "~/Notes/Daily.org"
                    "~/Notes/Alumnos.org" "~/Notes/Someday.org")
 org-mode-hook '(#[0 "\301\211%10\207"
                   [imenu-create-index-function org-imenu-get-tree] 2]
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-show-all append local]
                   5]
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-babel-show-result-all
                    append local]
                   5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes
                 ediff-with-org-show-all turn-on-org-cdlatex beginend-org-mode
                 org-eldoc-load)
 org-outline-path-complete-in-steps nil
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300%1\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
                      org-babel-header-arg-expand)
 org-hide-leading-stars t
 org-hide-emphasis-markers t
 org-highlight-latex-and-related '(latex script entities)
 org-ellipsis "…"
 org-agenda-loop-over-headlines-in-active-region nil
 org-src-lang-modes '(("latex-macros" . latex) ("inline-js" . javascript)
                      ("redis" . redis) ("php" . php) ("arduino" . arduino)
                      ("C" . c) ("C++" . c++) ("asymptote" . asy)
                      ("bash" . sh) ("beamer" . latex) ("calc" . fundamental)
                      ("cpp" . c++) ("ditaa" . artist) ("dot" . fundamental)
                      ("elisp" . emacs-lisp) ("ocaml" . tuareg)
                      ("screen" . shell-script) ("shell" . sh)
                      ("sqlite" . sql))
 org-occur-hook '(org-first-headline-recenter)
 org-agenda-mode-hook '(beginend-org-agenda-mode)
 org-structure-template-alist '(("a" . "export ascii") ("c" . "center")
                                ("C" . "comment") ("e" . "example")
                                ("E" . "export") ("h" . "export html")
                                ("l" . "export latex") ("q" . "quote")
                                ("s" . "src") ("v" . "verse")
                                ("thm" . "theorem") ("pf" . "proof")
                                ("lem" . "lemma") ("cor" . "corollary")
                                ("def" . "definition") ("rem" . "remark")
                                ("exer" . "exercise") ("prop" . "proposition")
                                ("el" . "src emacs-lisp"))
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
                  org-cycle-show-empty-lines
                  org-optimize-window-after-visibility-change)
 org-todo-keywords '((sequence "TODO" "|" "DONE" "NOPE") (type "WAIT"))
 org-support-shift-select t
 org-speed-command-hook '(org-speed-command-activate
                          org-babel-speed-command-activate)
 org-refile-allow-creating-parent-nodes 'confirm
 org-refile-use-outline-path 'file
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-follow :complete
                        org-attach-complete-link)
                       ("id" :follow org-id-open)
                       ("eww" :follow org-eww-open :store org-eww-store-link)
                       ("rmail" :follow org-rmail-open :store
                        org-rmail-store-link)
                       ("mhe" :follow org-mhe-open :store org-mhe-store-link)
                       ("irc" :follow org-irc-visit :store org-irc-store-link
                        :export org-irc-export)
                       ("info" :follow org-info-open :export org-info-export
                        :store org-info-store-link)
                       ("gnus" :follow org-gnus-open :store
                        org-gnus-store-link)
                       ("docview" :follow org-docview-open :export
                        org-docview-export :store org-docview-store-link)
                       ("bibtex" :follow org-bibtex-open :store
                        org-bibtex-store-link)
                       ("bbdb" :follow org-bbdb-open :export org-bbdb-export
                        :complete org-bbdb-complete-link :store
                        org-bbdb-store-link)
                       ("w3m" :store org-w3m-store-link)
                       ("cite" :follow org-bibtex-goto-citation :export nil)
                       ("org-title" :store store-org-title-link) ("file+sys")
                       ("file+emacs") ("shell" :follow org-link--open-shell)
                       ("news" :follow
                        #[514 "\301\300\302%4Q%2\"\207"
                          ["news" browse-url ":"] 6 "\n\n(fn URL ARG)"]
                        )
                       ("mailto" :follow
                        #[514 "\301\300\302%4Q%2\"\207"
                          ["mailto" browse-url ":"] 6 "\n\n(fn URL ARG)"]
                        )
                       ("https" :follow
                        #[514 "\301\300\302%4Q%2\"\207"
                          ["https" browse-url ":"] 6 "\n\n(fn URL ARG)"]
                        )
                       ("http" :follow
                        #[514 "\301\300\302%4Q%2\"\207"
                          ["http" browse-url ":"] 6 "\n\n(fn URL ARG)"]
                        )
                       ("ftp" :follow
                        #[514 "\301\300\302%4Q%2\"\207" ["ftp" browse-url ":"]
                          6 "\n\n(fn URL ARG)"]
                        )
                       ("help" :follow org-link--open-help)
                       ("file" :complete org-link-complete-file)
                       ("elisp" :follow org-link--open-elisp)
                       ("doi" :follow org-link--open-doi))
 org-capture-templates '(("s" "Someday" entry (file "Someday.org") "* %?\n")
                         ("d" "Daily" entry (file+olp+datetree "Daily.org")
                          "* TODO %?\n")
                         ("r" "Refile" entry (file "Refile.org") "* %?\n")
                         ("j" "Journal entry" plain
                          (file+olp+datetree "Journal.org"))
                         ("e" "Emacs templates")
                         ("ei" "Idea" entry
                          (file+olp "Editors/Emacs.org" "Ideas") "* %?\n")
                         ("et" "Tip" entry
                          (file+olp "Editors/Emacs.org" "Tips") "* %?\n")
                         ("eq" "Question" entry
                          (file+olp "Editors/Emacs.org" "Questions") "* %?\n")
                         ("ep" "Package" entry
                          (file+olp "Editors/Emacs.org" "Packages") "* %?\n")
                         )
 org-link-elisp-confirm-function 'yes-or-no-p
 outline-mode-hook '(beginend-outline-mode)
 org-latex-packages-alist '(("AUTO" "babel" t ("pdflatex")))
 org-confirm-babel-evaluate nil
 org-directory "~/Notes"
 org-preview-latex-image-directory "~/.cache/ltximg/"
 )


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug: org-catch-invisible-edits doesn't actually catch most deletions [9.4 (9.4-41-g9bb930-elpaplus @ /home/omarantolin/.emacs.d/elpa/org-plus-contrib-20201116/)]
  2020-11-23  6:33 Bug: org-catch-invisible-edits doesn't actually catch most deletions [9.4 (9.4-41-g9bb930-elpaplus @ /home/omarantolin/.emacs.d/elpa/org-plus-contrib-20201116/)] Omar Antolín Camarena
@ 2024-02-10 16:11 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-02-10 16:11 UTC (permalink / raw)
  To: Omar Antolín Camarena; +Cc: emacs-orgmode

Omar Antolín Camarena <omar@matem.unam.mx> writes:

> Setting org-catch-invisible-edits to 'error does catch org-delete-backward-char (bound to <backspace> by default), but it doesn't catch backward-kill-word (<C-backspace>), or kill-word with argument -1 (M-- M-d), or backward-kill-sexp (ESC <C-backspace>).
> ...
> I'd suggest that naming the variable org-catch-invisible-edits strongly suggests it should catch all deletions in the invisible text and that the current behavior is misleading.

Catching all commands is impossible because we cannot know in advance
which command (including user-defined) is going to perform editing and
which does not.

And throwing an error /while/ a command is performing edits can easily
break command logic and cause unpredictable bugs. Not to mention that
some commands are OK to edit inside folded text.

Org mode now has `org-fold-catch-invisible-edits-commands' where you can
manually specify the commands you want Org to abort before they are
executed.

Handled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-10 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-23  6:33 Bug: org-catch-invisible-edits doesn't actually catch most deletions [9.4 (9.4-41-g9bb930-elpaplus @ /home/omarantolin/.emacs.d/elpa/org-plus-contrib-20201116/)] Omar Antolín Camarena
2024-02-10 16:11 ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.