From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brady Trainor Subject: Re: New headline after no content (empty headline) Date: Sun, 23 Mar 2014 02:08:59 +0000 (UTC) Message-ID: References: <874n2xtzrv.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRXqu-00069M-CP for emacs-orgmode@gnu.org; Sat, 22 Mar 2014 22:09:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WRXqp-0006kV-G9 for emacs-orgmode@gnu.org; Sat, 22 Mar 2014 22:09:32 -0400 Received: from plane.gmane.org ([80.91.229.3]:49690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRXqp-0006kQ-9I for emacs-orgmode@gnu.org; Sat, 22 Mar 2014 22:09:27 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WRXql-0007JR-Vy for emacs-orgmode@gnu.org; Sun, 23 Mar 2014 03:09:24 +0100 Received: from 75-149-173-2-Washington.hfc.comcastbusiness.net ([75.149.173.2]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Mar 2014 03:09:23 +0100 Received: from algebrat by 75-149-173-2-Washington.hfc.comcastbusiness.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Mar 2014 03:09:23 +0100 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: emacs-orgmode@gnu.org Bastien gnu.org> writes: > > Hi Brady, > > Brady Trainor uw.edu> writes: > > (when respect-content > > (and (looking-at "[ \t]+") (replace-match "")) > > I thought to try substituting "[ \t]+" with "[\t]+", and byte compiled the > > file. But this did not solve. > What you want is not to remove only tabs, but to prevent removing > whitespaces when the string before the point matches "^\*+" -- so > that's what I did with this patch: > > http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=afffe03d Thank you much for taking the time to fix my fix and add the patch. However, my fix was wrong, I should not have been looking inside the =respect content= case. My original intention was to modify the =insert-org-heading=, not =org-insert-heading-respect-content=. I was that lost. Your help and encouragement pushed me to find the `source` of my problem. For this, I looked for ways to step through the code, ala some type of debugger, and I fell upon Emacs' default, Edebugger. (Simply reading org.el was, um, not efficient by itself.) So, I "instrumented" the =defun=s, in the end both of =org-insert-heading= and =org-N-empty-lines-before-current= (via =C-u C-M-x=) and deleting org.elc. This way, testing =M-RET= in an org file, I could =SPACE= through org.el while watching the org file buffer for changes (and *Messages*, though that was more or less awkward for me). So, here are my changes that give me my desired behavior, modifying in the function =org-N-empty-lines-before-current= which follows right after function =org-insert-heading=. Originally (if (looking-back "\\s-+" nil 'greedy) (replace-match "")) (or (bobp) (insert "\n")) I changed this to (unless (looking-back "\* \n") ; don't damage empty headlines (if (looking-back "\\s-+" nil 'greedy) (replace-match "")) (or (bobp) (insert "\n")) ) This feels a bit ad-hoc, as I don't completely understand all the stuff even in =defun org-insert-heading...=, and likely a fix should be made taking into account all desired functionality (but I'd worry to break something else). Let's call it organic! /Someday/, I'd like to understand the org.el better. I haven't learned how to patch, I've barely started gitting about a month ago for backing up files. I guess I should clone the Org-mode source soon, for starters. Thanks again! Brady