emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] New headline after no content (empty headline)


From: Brady Trainor
Subject: Re: [O] New headline after no content (empty headline)
Date: Sun, 23 Mar 2014 02:08:59 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Bastien <bzg <at> gnu.org> writes:

> 
> Hi Brady,
> 
> Brady Trainor <algebrat <at> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]