* [PATCH] org-capture, removing whitespace from new captures
@ 2011-09-13 21:19 paulusm
2011-09-14 8:44 ` Olaf Dietsche
0 siblings, 1 reply; 8+ messages in thread
From: paulusm @ 2011-09-13 21:19 UTC (permalink / raw)
To: emacs-orgmode
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))
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] org-capture, removing whitespace from new captures
2011-09-13 21:19 [PATCH] org-capture, removing whitespace from new captures paulusm
@ 2011-09-14 8:44 ` Olaf Dietsche
2011-09-14 11:14 ` Paul
0 siblings, 1 reply; 8+ messages in thread
From: Olaf Dietsche @ 2011-09-14 8:44 UTC (permalink / raw)
To: paulusm; +Cc: emacs-orgmode
paulusm@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] org-capture, removing whitespace from new captures
2011-09-14 8:44 ` Olaf Dietsche
@ 2011-09-14 11:14 ` Paul
2011-09-14 12:59 ` Olaf Dietsche
2011-10-29 12:08 ` Bastien
0 siblings, 2 replies; 8+ messages in thread
From: Paul @ 2011-09-14 11:14 UTC (permalink / raw)
To: Olaf Dietsche; +Cc: emacs-orgmode
# olaf+list.orgmode@olafdietsche.de, Wed, 14 Sep 2011 18:44:07 +1000:
> paulusm@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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] org-capture, removing whitespace from new captures
2011-09-14 11:14 ` Paul
@ 2011-09-14 12:59 ` Olaf Dietsche
2011-10-29 12:08 ` Bastien
1 sibling, 0 replies; 8+ messages in thread
From: Olaf Dietsche @ 2011-09-14 12:59 UTC (permalink / raw)
To: Paul; +Cc: emacs-orgmode
Paul <emacs-orgmode@lookmumnohands.net> writes:
> # olaf+list.orgmode@olafdietsche.de, Wed, 14 Sep 2011 18:44:07 +1000:
>> paulusm@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] org-capture, removing whitespace from new captures
2011-09-14 11:14 ` Paul
2011-09-14 12:59 ` Olaf Dietsche
@ 2011-10-29 12:08 ` Bastien
2012-02-18 15:50 ` David Maus
1 sibling, 1 reply; 8+ messages in thread
From: Bastien @ 2011-10-29 12:08 UTC (permalink / raw)
To: Paul; +Cc: emacs-orgmode
Hi Paul,
Paul <emacs-orgmode@lookmumnohands.net> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] org-capture, removing whitespace from new captures
2011-10-29 12:08 ` Bastien
@ 2012-02-18 15:50 ` David Maus
2012-02-18 17:19 ` Bastien
0 siblings, 1 reply; 8+ messages in thread
From: David Maus @ 2012-02-18 15:50 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode, Paul
[-- Attachment #1.1: Type: text/plain, Size: 1166 bytes --]
Hi Bastien,
Hi Paul,
At Sat, 29 Oct 2011 14:08:52 +0200,
Bastien wrote:
>
> Hi Paul,
>
> Paul <emacs-orgmode@lookmumnohands.net> 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.... dmjena@jabber.org
Email..... dmaus@ictsoc.de
[-- Attachment #1.2: 0001-New-hook-Run-before-the-finalization-process-starts.patch --]
[-- Type: text/plain, Size: 1394 bytes --]
From f737fbdc6ed1d45d8629eb1347e8c8d828f77e32 Mon Sep 17 00:00:00 2001
From: David Maus <dmaus@ictsoc.de>
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
[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] org-capture, removing whitespace from new captures
2012-02-18 15:50 ` David Maus
@ 2012-02-18 17:19 ` Bastien
2012-02-18 17:33 ` David Maus
0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2012-02-18 17:19 UTC (permalink / raw)
To: David Maus; +Cc: emacs-orgmode, Paul
Hi David and Paul,
David Maus <dmaus@ictsoc.de> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] org-capture, removing whitespace from new captures
2012-02-18 17:19 ` Bastien
@ 2012-02-18 17:33 ` David Maus
0 siblings, 0 replies; 8+ messages in thread
From: David Maus @ 2012-02-18 17:33 UTC (permalink / raw)
To: Bastien; +Cc: David Maus, emacs-orgmode, Paul
[-- Attachment #1: Type: text/plain, Size: 658 bytes --]
At Sat, 18 Feb 2012 18:19:49 +0100,
Bastien wrote:
>
> Hi David and Paul,
>
> David Maus <dmaus@ictsoc.de> 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.... dmjena@jabber.org
Email..... dmaus@ictsoc.de
[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-02-18 17:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-13 21:19 [PATCH] org-capture, removing whitespace from new captures paulusm
2011-09-14 8:44 ` Olaf Dietsche
2011-09-14 11:14 ` Paul
2011-09-14 12:59 ` Olaf Dietsche
2011-10-29 12:08 ` Bastien
2012-02-18 15:50 ` David Maus
2012-02-18 17:19 ` Bastien
2012-02-18 17:33 ` David Maus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).