From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] Preserve trailing blank lines Date: Sat, 8 Jan 2011 19:02:44 +0100 Message-ID: <078486EA-3EAD-4E6B-B428-D0DC477DFCB3@gmail.com> References: <87mxngqh1o.fsf@riotblast.dunsmor.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=50237 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pbd85-0000GE-3b for emacs-orgmode@gnu.org; Sat, 08 Jan 2011 13:03:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pbd7o-0002i7-LB for emacs-orgmode@gnu.org; Sat, 08 Jan 2011 13:03:04 -0500 Received: from mail-ey0-f169.google.com ([209.85.215.169]:41229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pbd7o-0002hx-ES for emacs-orgmode@gnu.org; Sat, 08 Jan 2011 13:02:48 -0500 Received: by eyh6 with SMTP id 6so4945532eyh.0 for ; Sat, 08 Jan 2011 10:02:47 -0800 (PST) In-Reply-To: <87mxngqh1o.fsf@riotblast.dunsmor.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jason Dunsmore Cc: emacs-orgmode@gnu.org On Jan 5, 2011, at 2:24 AM, Jason Dunsmore wrote: > I like to leave a blank line at the end of items that have bodies, > but I > found functions like org-metaup, org-metadown, and org-refile were > leaving that blank line behind. These commands treat empty lines as belonging to the entry below the empty line - which is, I think, the right convention here. - Carsten > Here's a patch to fix that: > > --8<---------------cut here---------------start------------->8--- > diff --git a/lisp/org.el b/lisp/org.el > index 5eb0bc8..e3d71b7 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -18448,7 +18448,7 @@ Taken from `count' in cl-seq.el with all > keyword arguments > "Move backwards over whitespace, to the beginning of the first > empty line. > Returns the number of empty lines passed." > (let ((pos (point))) > - (skip-chars-backward " \t\n\r") > + (forward-line -1) > (beginning-of-line 2) > (goto-char (min (point) pos)) > (count-lines (point) pos))) > --8<---------------cut here---------------end--------------->8--- > > I can't think of a reason you would want to leave trailing blank lines > behind, but in case some people rely on that behavior, here's an > alternate patch that creates an option called > org-preserve-trailing-blank-lines: > > --8<---------------cut here---------------start------------->8--- > diff --git a/lisp/org.el b/lisp/org.el > index 5eb0bc8..e90798c 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -1098,6 +1098,11 @@ breaking the list structure." > (const :tag "Always" t) > (const :tag "Auto" auto))))) > > +(defcustom org-preserve-trailing-blank-lines t > + "Non-nil means preserve blank lines at the end of an item." > + :group 'org-edit-structure > + :type 'boolean) > + > (defcustom org-insert-heading-hook nil > "Hook being run after inserting a new heading." > :group 'org-edit-structure > @@ -18448,7 +18453,9 @@ Taken from `count' in cl-seq.el with all > keyword arguments > "Move backwards over whitespace, to the beginning of the first > empty line. > Returns the number of empty lines passed." > (let ((pos (point))) > - (skip-chars-backward " \t\n\r") > + (if org-preserve-trailing-blank-lines > + (forward-line -1) > + (skip-chars-backward " \t\n\r")) > (beginning-of-line 2) > (goto-char (min (point) pos)) > (count-lines (point) pos))) > --8<---------------cut here---------------end--------------->8--- > > If this is accepted, perhaps the function org-back-over-empty-lines > should be renamed to org-back-over-lines. > > Regards, > Jason > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode