From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: Bug: heading visibility cycling and org-narrow-to-subtree Date: Fri, 30 Aug 2013 11:41:08 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFTdA-0008N9-MV for emacs-orgmode@gnu.org; Fri, 30 Aug 2013 14:41:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VFTd8-0000aI-Qb for emacs-orgmode@gnu.org; Fri, 30 Aug 2013 14:41:12 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:48312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFTd8-0000a1-Jt for emacs-orgmode@gnu.org; Fri, 30 Aug 2013 14:41:10 -0400 Received: by mail-wi0-f175.google.com with SMTP id hi5so4375317wib.2 for ; Fri, 30 Aug 2013 11:41:09 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: Mailinglist emacs-orgmode , Ali Tofigh Hmm, I have found and reported several bugs of this nature also. For example, sorting in a narrowed region usually corrupted the buffer by joining lines. This bug went unnoticed for possibly years becuase it was tricky to correlate the sorting operation with the buffer corruption [because diff is often unreadable in such cases]. Here's my take: I don't know if it is relevant in this case, but I found that the cause of most of these bugs is Outline mode, not Org or Emacs. Outline does not include the final newline. In most of Emacs, you typically mark bol, then move down a few lines, then perform the operation. This marks lines including their newlines. But in Outline, you have to guard against the special case of the narrowed region not doing this. That is, all code that uses outline subtree marking has to code defensively and work around what amounts to a special case. A lot of code in Emacs subtly assumes a newline at the end of a narrowed region, and does not consider this special case. A philosopher would say that it's a matter of whether newlines are line separators or line terminators, but much of line-operating and region-operating functionality in Emacs has made the pragmatic decision that they are line terminators. While I acknowledge the other point of view, and I am aware of the potential religious war that might ensue, I agree with that decision and don't think it's best to try to change all of Emacs to accommodate Outline mode's view in this case.[1] In summary, while this decision is up to Org developers, IMO Outline's peculiar way of marking a subtree will continue to cause subtle bugs and require defensive coding and workarounds until, somehow, a subtree in Org is defined to include the final newline, at least everywhere except eob. Dunno if that helps or is relevant, but I hope it provides a little context, even if tangential. Samuel [1] The first line does not include the newline before it. The last line does include its own newline. Thus, lines at buffer boundaries do not have to be treated specially. If you don't use a final newline in the file, such bugs become apparent quickly and can be fixed with require-final-newline. Furthermore, point and mark are both at bol in all cases when you are performing such operations. As a user, I find it disconcerting to do end-of-buffer and have point not be at bol. Finally, applications like cron often require final newlines. Did you know that if you don't do that, and run certain crons, the final line will be silently skipped? Surprise :). === On 8/30/13, Carsten Dominik wrote: > Hi Ali, > > hmmm, this is clearly a bug. But one that is hard to fix. I remember that > it was problematic to extend the narrowing region to include the newline > directly before the next heading. I do not exactly remember why this caused > problems, but it did. > > I suggest to just live with it. > > Thank you for the report none the less! > > - Carsten > > On 22.8.2013, at 22:30, Ali Tofigh wrote: > >> After narrowing to a subtree, folding the top level heading hides all >> text except for the last letter in the last paragraph. An example: >> >> ----- 8< ----- >> * one >> ** two >> hello world >> * three >> ---------- >> >> with cursor on heading "one", do M-x org-narrow-to-subtree (C-x n s), >> then press tab, and you get: >> >> ----- 8< ----- >> * one...d >> ---------- >> >> with the "d" of "hello world" being visible. >> >> emacs version: 24.3.1 >> Org-mode version: 8.0.7 (8.0.7-6-g13cb28-elpa) >> OS: Mac OSX >> emacs was started with the -Q flag >> >> /ali >> > > > -- The Kafka Pandemic: http://thekafkapandemic.blogspot.com The disease DOES progress. MANY people have died from it. ANYBODY can get it. Denmark: free Karina Hansen NOW.