From mboxrd@z Thu Jan 1 00:00:00 1970 From: paulusm@telstra.com Subject: [PATCH] org-capture, removing whitespace from new captures Date: Wed, 14 Sep 2011 07:19:26 +1000 Message-ID: <20110913211926.GB15861@shift> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:45516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3akU-0007xv-SR for emacs-orgmode@gnu.org; Tue, 13 Sep 2011 17:42:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3akT-0003l4-Vu for emacs-orgmode@gnu.org; Tue, 13 Sep 2011 17:42:34 -0400 Received: from [64.27.7.55] (port=46385 helo=dreadnought.herstik.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3akT-0003iL-RF for emacs-orgmode@gnu.org; Tue, 13 Sep 2011 17:42:33 -0400 Content-Disposition: inline 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: emacs-orgmode@gnu.org I found myself manually "cleaning" most CAPTURE buffers of whitespace prior to committing them with C-c C-c. The attached patch adds a new property :whitespace-cleanup to the org-capture-templates. -- Paul. diff --git a/lisp/org-capture.el b/lisp/org-capture.el index a7dc92b..ae5af6d 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -205,6 +205,9 @@ properties are: capture was invoked, kill the buffer again after capture is finalized. + :whitespace-cleanup When set, call `whitespace-cleanup' prior to + widening the buffer. + The template defines the text to be inserted. Often this is an org-mode entry (so the first line should start with a star) that will be filed as a child of the target headline. It can also be @@ -329,7 +332,8 @@ calendar | %:type %:date" ((const :format "%v " :clock-keep) (const t)) ((const :format "%v " :clock-resume) (const t)) ((const :format "%v " :unnarrowed) (const t)) - ((const :format "%v " :kill-buffer) (const t)))))))) + ((const :format "%v " :kill-buffer) (const t)) + ((const :format "%v " :whitespace-cleanup) (const t)))))))) (defcustom org-capture-before-finalize-hook nil "Hook that is run right before a capture process is finalized. @@ -544,6 +548,9 @@ captured item after finalizing." (org-clock-in))) (message "Interrupted clock has been resumed"))) + (when (org-capture-get :whitespace-cleanup 'local) + (whitespace-cleanup)) + (let ((beg (point-min)) (end (point-max)) (abort-note nil))