emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@gnu.org>
To: Brady Trainor <algebrat@uw.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: New headline after no content (empty headline)
Date: Mon, 17 Mar 2014 01:49:40 +0100	[thread overview]
Message-ID: <874n2xtzrv.fsf@bzg.ath.cx> (raw)
In-Reply-To: <loom.20140315T215440-545@post.gmane.org> (Brady Trainor's	message of "Sat, 15 Mar 2014 21:24:57 +0000 (UTC)")

Hi Brady,

Brady Trainor <algebrat@uw.edu> 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-<return>") '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

  reply	other threads:[~2014-03-17  0:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-15 21:24 New headline after no content (empty headline) Brady Trainor
2014-03-17  0:49 ` Bastien [this message]
2014-03-23  2:08   ` Brady Trainor
2014-03-23  8:33     ` Bastien
2014-03-28  5:57       ` Brady Trainor
2014-03-31  5:55         ` Bastien
2014-03-31  6:26           ` Brady Trainor

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=874n2xtzrv.fsf@bzg.ath.cx \
    --to=bzg@gnu.org \
    --cc=algebrat@uw.edu \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).