From: Brady Trainor <algebrat@uw.edu>
To: emacs-orgmode@gnu.org
Subject: Re: New headline after no content (empty headline)
Date: Sun, 23 Mar 2014 02:08:59 +0000 (UTC) [thread overview]
Message-ID: <loom.20140323T025804-187@post.gmane.org> (raw)
In-Reply-To: 874n2xtzrv.fsf@bzg.ath.cx
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
next prev parent reply other threads:[~2014-03-23 2:09 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
2014-03-23 2:08 ` Brady Trainor [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20140323T025804-187@post.gmane.org \
--to=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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.