From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: New headline after no content (empty headline) Date: Mon, 17 Mar 2014 01:49:40 +0100 Message-ID: <874n2xtzrv.fsf@bzg.ath.cx> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPLkZ-0001pu-Dc for emacs-orgmode@gnu.org; Sun, 16 Mar 2014 20:50:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPLkS-0000Oh-Vr for emacs-orgmode@gnu.org; Sun, 16 Mar 2014 20:49:55 -0400 Received: from rs249.mailgun.us ([209.61.151.249]:47223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPLkS-0000OI-QV for emacs-orgmode@gnu.org; Sun, 16 Mar 2014 20:49:48 -0400 In-Reply-To: (Brady Trainor's message of "Sat, 15 Mar 2014 21:24:57 +0000 (UTC)") 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: Brady Trainor Cc: emacs-orgmode@gnu.org Hi Brady, Brady Trainor writes: > So, I started trying to read the org.el file. I thought I had found > the "offending" line, (my L7614,) finding > > ;; If we insert after content, move there and clean up whitespace > (when respect-content > (org-end-of-subtree nil t) > (skip-chars-backward " \r\n") > (and (looking-at "[ \t]+") (replace-match "")) > (unless (eobp) (forward-char 1)) > (when (looking-at "^\\*") > (unless (bobp) (backward-char 1)) > (insert "\n"))) > > I thought to try substituting "[ \t]+" with "[\t]+", and byte compiled the > file. But this did not solve. The idea behind (and (looking-at "[ \t]+") (replace-match "")) is to remove whitespaces after the entry. It generally happens with non-empty headlines, so it's the correct move here. 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 > So, I never like to ask a question without having an answer myself, so I > learned a little more enough about keyboard macros to generate the > following somewhat simple and natural solution (natural in that it uses a > similar unused key chord): > > (fset 'new-starred-line > [return ?* ? ]) > (global-set-key (kbd "C-M-") 'new-starred-line) > > > So, what is my question? What am I lacking in my .el package reading > skills? Why did my first fix not work? As a newb program hacker, am I > approaching this right? Maybe best case is to understand more of the entire > org.el file, but was trying to hack just enough. What would you have done? I don't have a general rule, but what I found out over time is this: when struggling to find a solution, it is very easy to forget about the problem. I try to discipline myself (1) stating the problem by writing it (when the OP did not find the problem itself or didn't write it in a way I can understand) and (2) limiting the solution to the problem. It sounds like simple common sense, but experience shows common sense in this area is not that common. Getting familiar with the code is also the only to understand what the program does by reading the code, and to make sure your solution does not have side-effects. HTH, -- Bastien