Hello again, Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:
> Hello, > > It doesn't work the way `LaTeX-narrow-to-environment' works. In > particular, AUCTeX's function /does not modify the buffer/. This is > a big no-no, really. I see your point, and I understand why it would be strange for narrowing commands to modify the buffer. I’d built this patch under three assumptions: 1. We should only change the interactive behaviour of `org-narrow-to-subtree' so as to not disturb other commands/functions. 2. When called interactively, as long as our wrapper for `widen' cancels out what's been added by `org-narrow-to-subtree', changing the buffer is acceptable. 3. If the buffer were to be closed between `org-narrow-to-subtree' and our wrapper for `widen', the only thing you'd have is a spurious newline. This wouldn't be a big deal because some commands in org already do that in a narrowed context [1]. That said, I completely understand your reticence and you've made me understand that my solution was more 'hackish' than I intended it to be. > I suggest to not use narrowing, then. Maybe try editing remotely > a subtree, similar to what is done for footnotes. I have the feeling > this would have its own set of issues, too. I thought about other options before heading into this. One of them was to yank the subtrees to a temporary buffer to edit them and hook onto the saving commands to update the corresponding buffer accordingly. In retrospect, that seems a lot more 'hackish'. Maybe we could salvage some of the patch for `org-capture' since it's different from narrowing, but I've got a better idea. > It is not about my workflow. I don't use 1-line subtrees. But anything > related to narrowing or widening should not alter the buffer, per > design. I may sound stubborn, but I don't think this is a way to handle > the problem. I'd like to suggest a middle ground which I think would be more acceptable. You've asked me in a previous exchange to make a list of the commands which didn't work as expected when the buffer was narrowed to a 1-line subtree [2]. Would it be possible to patch those commands so that they conditionally refresh the narrowing of the buffer if the information they add would be spawned *outside* of the restriction? The rationale behind it is that, in Emacs, commands trying to act on regions outside the current restriction throw an error. Therefore, in the context of 1-line subtrees, we could justify that conditional behaviour by saying that it prevents your command from working outside of the current restriction. I was pleased to see that property-adding functions didn't behave badly with 1-line subtrees. Maybe we could investigate those commands and patch their behaviour onto the problematic ones? If that sounds good to you, I could work on it and submit another patch. Thank you. HTH. Footnotes: [1] As a quick aside, here's an example for 3. where X represents `point': --------------------------------[START]-------------------------------- \| * Tree \| |X1|2| ---------------------------------[END]--------------------------------- When narrowed (or at the end of a buffer), if you press <TAB>: - `point' moves to '2'. - Table is realigned. - Newline is added at the end of the table. [2] We've already addressed `org-clock-out-when-done', but I've found another one. Although adding scheduling/deadline information works within a 1-line subtree (the information isn't visible, but it's there in the widened buffer), you cannot remove them from within that environment. Best, -- Leo Vivier English Studies & General Linguistics Master Student, English Department Université Rennes 2