From: tony aldon <firstname.lastname@example.org> To: email@example.com Subject: when ellipsis are "removed", org-cycle doesn't work "correctly" on list Date: Thu, 11 Nov 2021 15:24:31 +0100 [thread overview] Message-ID: <CACWitSDqGLb20knQKYt97gaj_xyn_+Di4kgFSUvN2_TzUXUw+A@mail.gmail.com> (raw) [-- Attachment #1.1: Type: text/plain, Size: 3934 bytes --] ** when ellipsis are "removed", org-cycle doesn't work "correctly" on list Hey everyone, This is my first communication on this mailing list and I hope I'll do it well. 1) The "bug" (I'm not sure if it is a bug): When you modify the `buffer-invisibility-spec` replacing `'(outline . t)` by `'outline` (in order to remove the `...` when headlines, list, etc are collapsed) by evaluating the following form: (remove-from-invisibility-spec '(outline . t)) (add-to-invisibility-spec 'outline) `org-cycle` stopped working "correctly" on lists. You still can collapse lists but you can get them to show the list content again. For instance, with the following list (and the ellipsis removed), with the point on the first item (- something), press TAB (`org-cycle`): - something - a - b - c - something else You'll obtain the first item collapsed: - something - something else but if you hit TAB (`org-cycle`) again, you won't see the content (a, b, c), the first item will stay collapsed. note-1: I don't know if it can be considered as a "bug" because I imagine that most org-mode users won't remove the visual feedback offered by the ellipsis. note-2: This "bug" was reported as an issue on github (https://github.com/tonyaldon/org-bars/issues/5) by jonathanmfung, regarding a section on the README where I wrote how to remove the ellipsis, knowing that `org-bars` offers dynamic stars that inform the visibility of subtrees. Maybe it wasn't a good idea. 2) a fix of the "bug" I was really interested in knowing why changing the `buffer-invisibility-spec` in the way previously described has an impact on `org-cycle`. I added a small patch (that modifies `org-list-struct`) to this email that makes `org-cycle` work with `buffer-invisibility-spec` changed in order to remove ellipsis. The outline of the patch is as follow: The command `org-cycle`, when in an item list, calls `org-cycle-internal-local`. And `org-cycle-internal-local` computes the local var `eos` (end of subtree or item) via the call of the function `org-list-struct`. (defun org-cycle-internal-local () ;;... (let ((goal-column 0) eoh eol eos has-children children-skipped struct) (save-excursion (if (org-at-item-p) (progn (beginning-of-line) (setq struct (org-list-struct)) (setq eoh (point-at-eol)) (setq eos (org-list-get-item-end-before-blank (point) struct)) (setq has-children (org-list-has-child-p (point) struct))) ;; ... ) ;;... ))) And the problem comes from the use of the function `current-indentation` in `org-list-struct` that doesn't compute correctly in that context the indentation when ellipsis are removed. The patch replaces this specific call of `current-indentation`. note-3: I don't understand why the function `current-indentation` doesn't compute "correctly" the indentation in that context. note-4: In a default org buffer, with the items either collapsed or not, with the following content and point on the first item, - [X] first item 1. sub-item 1 5. [@5] sub-item 2 some other text belonging to first item - last item + tag :: description evaluating `(org-list-struct)` gives the following structure (as written in the docstring): ((1 0 \"- \" nil \"[X]\" nil 97) (18 2 \"1. \" nil nil nil 34) (34 2 \"5. \" \"5\" nil nil 55) (97 0 \"- \" nil nil nil 131) (109 2 \"+ \" nil nil \"tag\" 131)) But if you removed the ellipsis (as specified previously), and you collapse the first item, evaluating `(org-list-struct)` with point on the first item gives you: ((1 0 "- " nil "[X]" nil 18) (18 0 "1. " nil nil nil 34) (34 0 "5. " "5" nil nil 55)) 3) Thank you for all your work on org-mode, I enjoy using it every day :) Have a nice day, Tony Aldon Done with: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.10) of 2021-06-09 [-- Attachment #1.2: Type: text/html, Size: 4733 bytes --] [-- Attachment #2: 0001-lisp-org-list.el-modify-current-indentation-calculat.patch --] [-- Type: text/x-patch, Size: 1590 bytes --] From 06636f4b14b138a3d6ca5366af3b5744f06d9c55 Mon Sep 17 00:00:00 2001 From: tony <firstname.lastname@example.org> Date: Thu, 11 Nov 2021 12:00:07 +0100 Subject: [PATCH] lisp/org-list.el: modify current indentation calculation in org-list-struct * lisp/org-list.el (org-list-struct): Don't use `current-indentation` to compute the current indentation in the loop that collects the org list informations. This change is necessary only in the case where you modify the `buffer-invisibility-spec` replacing `'(outline . t)` by `'outline` (in order to remove the `...` when headlines, list, etc are collapsed) by evaluating the following form: (remove-from-invisibility-spec '(outline . t)) (add-to-invisibility-spec 'outline) --- lisp/org-list.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/org-list.el b/lisp/org-list.el index b08e72eb2..025ae0086 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -684,7 +684,14 @@ Assume point is at an item." ;; position of items in END-LST-2. (catch 'exit (while t - (let ((ind (current-indentation))) + (let* ((current-indentation + (save-excursion + (save-match-data + (if (bolp) + (re-search-forward "^[[:blank:]]*") + (re-search-backward "^[[:blank:]]*")) + (- (match-end 0) (point-at-bol))))) + (ind current-indentation)) (cond ((>= (point) lim-down) ;; At downward limit: this is de facto the end of the -- 2.17.1
next reply other threads:[~2021-11-11 14:42 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-11 14:24 tony aldon [this message] 2021-11-19 13:42 ` [BUG] " Ihor Radchenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CACWitSDqGLb20knQKYt97gaj_xyn_+Di4kgFSUvN2_TzUXUw+A@mail.gmail.com \ --email@example.com \ --firstname.lastname@example.org \ --subject='Re: when ellipsis are "removed", org-cycle doesn'\''t work "correctly" on list' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).