Re: [O] [PATCH] org-capture, removing whitespace from new captures

2012-02-18 Thread David Maus
At Sat, 18 Feb 2012 18:19:49 +0100,
Bastien wrote:
>
> Hi David and Paul,
>
> David Maus  writes:
>
> > Instead of adding the :whitespace-cleanup property to the template
> > definition (what requires you to specify e.g. whitespace-cleanup in
> > every single template) why not define a new hook that is run before
> > the finalization starts? I.e. with capture buffer current and still
> > narrowed.
>
> Yes, I think this is more general, feel free to commit this.
>
> Thanks to you and to Paul for his neat suggestion!

And... done.

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber dmj...@jabber.org
Email. dm...@ictsoc.de

pgpEgAWNlmHwq.pgp
Description: PGP signature


Re: [O] [PATCH] org-capture, removing whitespace from new captures

2012-02-18 Thread Bastien
Hi David and Paul,

David Maus  writes:

> Instead of adding the :whitespace-cleanup property to the template
> definition (what requires you to specify e.g. whitespace-cleanup in
> every single template) why not define a new hook that is run before
> the finalization starts? I.e. with capture buffer current and still
> narrowed.

Yes, I think this is more general, feel free to commit this.

Thanks to you and to Paul for his neat suggestion!

Best,

-- 
 Bastien



Re: [O] [PATCH] org-capture, removing whitespace from new captures

2012-02-18 Thread David Maus
Hi Bastien,
Hi Paul,

At Sat, 29 Oct 2011 14:08:52 +0200,
Bastien wrote:
>
> Hi Paul,
>
> Paul  writes:
>
> > In fact adding whitespace-cleanup to org-capture-before-finalize-hook
> > was what I tried first, but it didn't do what I wanted.  This hook is
> > called _after_ the buffer is widened - making whitespace-cleanup
> > operate on the _entire_ buffer, not just the newly added capture.
> >
> > I believe the patch is still required - I should have explained
> > org-capture-before-finalize-hook's behaviour more explicitly in my
> > original submission.
>
> I'm willing to apply this patch -- could you provide it with a
> well-formatted ChangeLog entry?

Instead of adding the :whitespace-cleanup property to the template
definition (what requires you to specify e.g. whitespace-cleanup in
every single template) why not define a new hook that is run before
the finalization starts? I.e. with capture buffer current and still
narrowed.

See attached patch that such a hook called
`org-capture-prepare-finalize-hook'.

Best,
  -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber dmj...@jabber.org
Email. dm...@ictsoc.de
From f737fbdc6ed1d45d8629eb1347e8c8d828f77e32 Mon Sep 17 00:00:00 2001
From: David Maus 
Date: Sat, 18 Feb 2012 16:41:30 +0100
Subject: [PATCH] New hook: Run before the finalization process starts

* org-capture.el (org-capture-prepare-finalize-hook): New hook. Run
before the finalization process starts.
(org-capture-finalize): Run new hook.
---
 lisp/org-capture.el |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d77415b..e3bd9f7 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -347,6 +347,13 @@ widened to the entire buffer."
   :version "24.1"
   :type 'hook)
 
+(defcustom org-capture-prepare-finalize-hook nil
+  "Hook that is run before the finalization starts.
+The capture buffer is current and still narrowed."
+  :group 'org-capture
+  :version "24.1"
+  :type 'hook)
+
 ;;; The property list for keeping information about the capture process
 
 (defvar org-capture-plist nil
@@ -530,6 +537,8 @@ captured item after finalizing."
   (buffer-base-buffer (current-buffer)))
 (error "This does not seem to be a capture buffer for Org-mode"))
 
+  (run-hooks 'org-capture-prepare-finalize-hook)
+
   ;; Did we start the clock in this capture buffer?
   (when (and org-capture-clock-was-started
 org-clock-marker (marker-buffer org-clock-marker)
-- 
1.7.2.5



pgpnFSAWSudo2.pgp
Description: PGP signature


Re: [O] [PATCH] org-capture, removing whitespace from new captures

2011-10-29 Thread Bastien
Hi Paul,

Paul  writes:

> In fact adding whitespace-cleanup to org-capture-before-finalize-hook
> was what I tried first, but it didn't do what I wanted.  This hook is
> called _after_ the buffer is widened - making whitespace-cleanup
> operate on the _entire_ buffer, not just the newly added capture.
>
> I believe the patch is still required - I should have explained
> org-capture-before-finalize-hook's behaviour more explicitly in my
> original submission.

I'm willing to apply this patch -- could you provide it with a
well-formatted ChangeLog entry?

Thanks!

> Further to this, can anybody suggest a better documentation string for
> org-capture-before-finalize-hook?  (Preferably in tandem with my
> proposed patch.)  Currently it is:
>
> Hook that is run right before a capture process is finalized.
> The capture buffer is still current when this hook runs.
>
> I feel the "finalized" part is somewhat ambiguous.  What it means is
> "after the capture buffer is widened, and before it is saved".  I
> expected it to mean "BEFORE the capture buffer is widened".
>
> Maybe:
> Hook that is run after the capture buffer is widened and prior to
> being finalized.  The capture buffer is still current when this
> hook runs.

Thanks for the suggestion -- I've updated the docstring like this:

  "Hook that is run right before a capture process is finalized.
   The capture buffer is still current when this hook runs and it is
   widened to the entire buffer."

The convention is that the first sentence should be readable on one
single line.  

Best,

-- 
 Bastien



Re: [O] [PATCH] org-capture, removing whitespace from new captures

2011-09-14 Thread Olaf Dietsche
Paul  writes:

> # olaf+list.orgm...@olafdietsche.de, Wed, 14 Sep 2011 18:44:07 +1000:
>> paul...@telstra.com writes:
>> 
>> > 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.
>> 
>> Thanks for pointing to whitespace-cleanup, I've done this manually
>> cleaning as well.
>
> My pleasure.  I just had it pointed out to me a couple of days ago!
>
>> You could use org-capture-before-finalize-hook for this:
>> 
>> (add-hook 'org-capture-before-finalize-hook 'whitespace-cleanup)
>
> In fact adding whitespace-cleanup to org-capture-before-finalize-hook
> was what I tried first, but it didn't do what I wanted.  This hook is
> called _after_ the buffer is widened - making whitespace-cleanup
> operate on the _entire_ buffer, not just the newly added capture.
>
> I believe the patch is still required - I should have explained
> org-capture-before-finalize-hook's behaviour more explicitly in my
> original submission.
>
> Further to this, can anybody suggest a better documentation string for
> org-capture-before-finalize-hook?  (Preferably in tandem with my
> proposed patch.)  Currently it is:
>
> Hook that is run right before a capture process is finalized.
> The capture buffer is still current when this hook runs.
>
> I feel the "finalized" part is somewhat ambiguous.  What it means is
> "after the capture buffer is widened, and before it is saved".  I
> expected it to mean "BEFORE the capture buffer is widened".
>
> Maybe:
> Hook that is run after the capture buffer is widened and prior to
> being finalized.  The capture buffer is still current when this
> hook runs.

Thanks again for this explanation. I haven't noticed this. For me this
isn't bad though, since I capture everything into an inbox.org.

Regards, Olaf



Re: [O] [PATCH] org-capture, removing whitespace from new captures

2011-09-14 Thread Paul
# olaf+list.orgm...@olafdietsche.de, Wed, 14 Sep 2011 18:44:07 +1000:
> paul...@telstra.com writes:
> 
> > 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.
> 
> Thanks for pointing to whitespace-cleanup, I've done this manually
> cleaning as well.

My pleasure.  I just had it pointed out to me a couple of days ago!


> You could use org-capture-before-finalize-hook for this:
> 
> (add-hook 'org-capture-before-finalize-hook 'whitespace-cleanup)


In fact adding whitespace-cleanup to org-capture-before-finalize-hook
was what I tried first, but it didn't do what I wanted.  This hook is
called _after_ the buffer is widened - making whitespace-cleanup
operate on the _entire_ buffer, not just the newly added capture.

I believe the patch is still required - I should have explained
org-capture-before-finalize-hook's behaviour more explicitly in my
original submission.


Further to this, can anybody suggest a better documentation string for
org-capture-before-finalize-hook?  (Preferably in tandem with my
proposed patch.)  Currently it is:

Hook that is run right before a capture process is finalized.
The capture buffer is still current when this hook runs.

I feel the "finalized" part is somewhat ambiguous.  What it means is
"after the capture buffer is widened, and before it is saved".  I
expected it to mean "BEFORE the capture buffer is widened".

Maybe:
Hook that is run after the capture buffer is widened and prior to
being finalized.  The capture buffer is still current when this
hook runs.


--
Paul.



Re: [O] [PATCH] org-capture, removing whitespace from new captures

2011-09-14 Thread Olaf Dietsche
paul...@telstra.com writes:

> 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.

Thanks for pointing to whitespace-cleanup, I've done this manually
cleaning as well.

You could use org-capture-before-finalize-hook for this:

(add-hook 'org-capture-before-finalize-hook 'whitespace-cleanup)

Regards, Olaf



[O] [PATCH] org-capture, removing whitespace from new captures

2011-09-13 Thread paulusm
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))