* Bug: capture with PROPERTIES [7.3 commit-972b0a58...]
@ 2010-12-10 12:10 Giovanni Ridolfi
2010-12-13 15:34 ` Bug: capture with PROPERTIES [7.4 commit-4760c3b94...] Giovanni Ridolfi
2011-01-04 12:57 ` Bug: capture with PROPERTIES [7.3 commit-972b0a58...] Carsten Dominik
0 siblings, 2 replies; 3+ messages in thread
From: Giovanni Ridolfi @ 2010-12-10 12:10 UTC (permalink / raw)
To: emacs-orgmode
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen. You don't know how to make a good report? See
http://orgmode.org/manual/Feedback.html#Feedback
Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------
Emacs : GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600)
of 2010-05-08 on G41R2F1
Package: Org-mode version 7.3 commit-972b0a581eff180bcdc15883d2fe30c4cc24996a
Hello everyone,
I found a bug in the insertion of PROPERTies in capture templates.
------------------------ TEST FILE: ------------------
-*- mode: org; -*-
(setq org-capture-templates
'(
("q" "element" entry (file+headline "test.org" "capture") "*** %^{prompt} \n :PROPERTIES:\n :ID: lab \n %^{Element}p \n %^{Number}p \n %^{Type}p \n :Feeling: %? \n :Comment: \n :END:"
)
))
* capture
:PROPERTIES:
:Element_ALL: H He Li Na Hg
:Number_ALL: 1 2 3 4 80
:Type_ALL: gas solid liquid
:END:
-----------------------------------
1. set my capture template
2. call capture template.
3. Enter headline: "first test", <RET>
so far so good.
4. Now you are requested to insert a PROPERTY
and the buffer appears as:
-------------------- 4th step --------------
*** first test
:PROPERTIES:
:ID: lab
%^{Number}p
%^{Type}p
:Feeling: %?
:Comment:
:END:
----------------------
Value for Element: || cursor is here
--------------------
------------------------------------------------
5. enter He <RET>
BUG: the layout of the buffer is broken:
---------------------------
*** first test
:PROPERTIES:
:ID: lab
-------| a blank line is here
|
%^{Type}p |
:Feeling: %? |
:Comment: |
:Element: He <-------| the property is inserted here!
:END:
----------------------
Value for Number: || (cursor is here)
---------------------------------------------------------
The line of the property is inserted at the end
of the Properties drawer, but before :END:.
Not where the prompt was, and where I expected to find it.
----------------------- A complete test: ----------
** second test
:PROPERTIES:
:ID: lab
. I put the "." to highligh the eol
.
.
:Feeling: mickey mouse[1]
:Comment:
:Element: He
:Number: 2
:Type: gas
:END:
[1] http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1117755/
----------------------------
cheers,
Giovanni
current state:
==============
(setq
org-log-done 'time
org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-vars)
org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook)
org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
org-metaup-hook '(org-babel-load-in-session-maybe)
org-capture-templates '(("q" "element" entry (file+headline "test.org" "capture")
"*** %^{prompt} \n :PROPERTIES:\n :ID: lab \n %^{Element}p \n %^{Number}p \n %^{Type}p \n :Feeling: %? \n :Comment: \n :END:")
)
org-after-todo-state-change-hook '(org-clock-out-if-current)
org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup)
org-export-latex-format-toc-function 'org-export-latex-format-toc-default
org-capture-before-finalize-hook '(org-clock-in)
org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-command-maybe org-babel-hide-result-toggle-maybe)
org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
org-finalize-agenda-hook '(my-org-agenda-to-appt)
org-confirm-shell-link-function 'yes-or-no-p
org-export-first-hook '(org-beamer-initialize-open-trackers)
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-babel-pre-tangle-hook '(save-buffer)
org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-show-empty-lines
org-optimize-window-after-visibility-change)
org-export-preprocess-before-normalizing-links-hook '(org-remove-file-link-modifiers)
org-mode-hook '((lambda nil
(org-add-hook (quote change-major-mode-hook) (quote org-show-block-all) (quote append) (quote local)))
(lambda nil
(org-add-hook (quote change-major-mode-hook) (quote org-babel-show-result-all) (quote append)
(quote local))
)
org-babel-result-hide-spec org-babel-hide-all-hashes)
org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe)
org-confirm-elisp-link-function 'yes-or-no-p
org-export-interblocks '((lob org-babel-exp-lob-one-liners) (src org-babel-exp-inline-src-blocks))
org-enforce-todo-dependencies t
org-occur-hook '(org-first-headline-recenter)
org-export-preprocess-before-selecting-backend-code-hook '(org-beamer-select-beamer-code)
org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-toc org-beamer-auto-fragile-frames
org-beamer-place-default-actions-for-lists)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-export-blocks '((src org-babel-exp-src-blocks nil) (comment org-export-blocks-format-comment t)
(ditaa org-export-blocks-format-ditaa nil) (dot org-export-blocks-format-dot nil))
)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug: capture with PROPERTIES [7.4 commit-4760c3b94...]
2010-12-10 12:10 Bug: capture with PROPERTIES [7.3 commit-972b0a58...] Giovanni Ridolfi
@ 2010-12-13 15:34 ` Giovanni Ridolfi
2011-01-04 12:57 ` Bug: capture with PROPERTIES [7.3 commit-972b0a58...] Carsten Dominik
1 sibling, 0 replies; 3+ messages in thread
From: Giovanni Ridolfi @ 2010-12-13 15:34 UTC (permalink / raw)
To: emacs-orgmode
Giovanni Ridolfi <giovanni.ridolfi@yahoo.it> writes:
- sorry for the double post of Friday -
> Emacs : GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600)
> of 2010-05-08 on G41R2F1
I can confirm the bug in 7.4 commit 4760c3b9482cfeda02d24590e2fb7c70a9c1d0cd
As the debug-on-error gave me not error :-(
I put some (debug) calls in org-capture.el:
--- org-capture.el 2010-12-13 16:14:39.086099200 +0100
+++ org-capture-2.el 2010-12-13 16:14:23.443606400 +0100
@@ -1225,9 +1225,14 @@
(when plist-p
(goto-char (point-min))
+;
+ (debug)
(while (re-search-forward "%\\(:[-a-zA-Z]+\\)" nil t)
(unless (org-capture-escaped-%)
(and (setq x (or (plist-get org-store-link-plist
(intern (match-string 1))) ""))
- (replace-match x t t)))))
+ (replace-match x t t))))
+;
+ (debug)
+)
;; Turn on org-mode in temp buffer, set local variables
@@ -1292,4 +1297,6 @@
((prop (org-substring-no-properties prompt))
(pall (concat prop "_ALL"))
+;
+ (debug)
(allowed
(with-current-buffer
@@ -1311,5 +1318,11 @@
existing nil nil
"" nil ""))))
- (org-set-property prop val)))
+ (org-set-property prop val)
+;
+ (debug)
+)
+;
+ (debug)
+)
(char
;; These are the date/time related ones
--------------------------------
And calling "my capture template", /repetita iuvant/:
------------------------ test.org FILE: ------------------
-*- mode: org; -*-
(setq org-capture-templates
'(
("q" "element" entry (file+headline "test.org" "capture") "*** %^{prompt} \n :PROPERTIES:\n :ID: lab \n %^{Element}p \n %^{Number}p \n %^{Type}p \n :Feeling: %? \n :Comment: \n :END:"
)
))
* capture
:PROPERTIES:
:Element_ALL: H He Li Na Hg
:Number_ALL: 1 2 3 4 80
:Type_ALL: gas solid liquid
:END:
-----------------------------------
The capture process stops
after the insertion of the first PROPERTY
with this *backtrace*:
--------------------------- *backtrace* ---------
Debugger entered: nil
(let* ((prop ...) (pall ...) (debug) (allowed ...) (existing ...) (propprompt ...) (val ...)) (org-set-property prop val) (debug))
(cond ((member char ...) (let* ... ... ...)) ((equal char "C") (cond ... ...)) ((equal char "L") (cond ... ...)) ((equal char "p") (let* ... ... ...) (debug)) (char (setq org-time-was-given ...) (setq time ...) (if ... ...) (org-insert-time-stamp time org-time-was-given ... nil nil ...)) (t (let ... ...)))
(if (org-capture-escaped-%) nil (setq char (if ... ...) prompt (if ... ...)) (goto-char (match-beginning 0)) (replace-match "") (setq completions nil default nil) (when prompt (setq completions ... prompt ... default ... histvar ... completions ...)) (unless (boundp histvar) (set histvar nil)) (cond (... ...) (... ...) (... ...) (... ... ...) (char ... ... ... ...) (t ...)))
(unless (org-capture-escaped-%) (setq char (if ... ...) prompt (if ... ...)) (goto-char (match-beginning 0)) (replace-match "") (setq completions nil default nil) (when prompt (setq completions ... prompt ... default ... histvar ... completions ...)) (unless (boundp histvar) (set histvar nil)) (cond (... ...) (... ...) (... ...) (... ... ...) (char ... ... ... ...) (t ...)))
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t) (unless (org-capture-escaped-%) (setq char ... prompt ...) (goto-char ...) (replace-match "") (setq completions nil default nil) (when prompt ...) (unless ... ...) (cond ... ... ... ... ... ...)))
(save-window-excursion (delete-other-windows) (switch-to-buffer (get-buffer-create "*Capture*")) (erase-buffer) (insert template) (goto-char (point-min)) (org-capture-steal-local-variables buffer) (setq buffer-file-name nil) (goto-char (point-min)) (while (re-search-forward "%\\[\\(.+\\)\\]" nil t) (unless ... ...)) (goto-char (point-min)) (while (re-search-forward "%\\((.+)\\)" nil t) (unless ... ... ...)) (goto-char (point-min)) (while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t) (unless ... ... ...)) (when plist-p (goto-char ...) (debug) (while ... ...) (debug)) (let (...) (org-mode)) (goto-char (point-min)) (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t) (unless ... ... ... ... ... ... ... ...)) (goto-char (point-min)) (while (looking-at "[ ]*\n") (replace-match "")) (if (re-search-forward "[ \n]*\\'" nil t) (replace-match "\n")) (untabify (point-min) (point-max)) (set-buffer-modified-p nil) (prog1 (buffer-string) (kill-buffer ...)))
(let* ((buffer ...) (file ...) (ct ...) (dct ...) (ct1 ...) (plist-p ...) (v-c ...) (v-x ...) (v-t ...) (v-T ...) (v-u ...) (v-U ...) (v-i ...) (v-a ...) (v-a ...) (clipboards ...) (v-A ...) (v-n user-full-name) (v-k ...) (v-K ...) v-I (org-startup-folded nil) (org-inhibit-startup t) org-time-was-given org-end-time-was-given x prompt completions char time pos default histvar) (setq org-store-link-plist (plist-put org-store-link-plist :annotation v-a) org-store-link-plist (plist-put org-store-link-plist :initial v-i)) (setq initial v-i) (unless template (setq template "") (message "No template") (ding) (sit-for 1)) (save-window-excursion (delete-other-windows) (switch-to-buffer ...) (erase-buffer) (insert template) (goto-char ...) (org-capture-steal-local-variables buffer) (setq buffer-file-name nil) (goto-char ...) (while ... ...) (goto-char ...) (while ... ...) (goto-char ...) (while ... ...) (when plist-p ... ... ... ...) (let ... ...) (goto-char ...) (while ... ...) (goto-char ...) (while ... ...) (if ... ...) (untabify ... ...) (set-buffer-modified-p nil) (prog1 ... ...)))
org-capture-fill-template()
--------------------------
(org-capture-put :template (org-capture-fill-template))
----------------
(condition-case error (org-capture-put :template (org-capture-fill-template)) ((error quit) (if ... ...) (error "Capture abort: %s" error)))
(cond ((equal entry "C") (customize-variable ...)) ((equal entry "q") (error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :annotation annotation :initial initial) (org-capture-put :default-time ...) (org-capture-set-target-location) (condition-case error ... ...) (if ... ... ... ...)))
(let* ((orig-buf ...) (annotation ...) (initial ...) (entry ...)) (when (stringp initial) (remove-text-properties 0 ... ... initial)) (when (stringp annotation) (remove-text-properties 0 ... ... annotation)) (cond (... ...) (... ...) (t ... ... ... ... ... ... ...)))
(cond ((equal goto ...) (org-capture-goto-target)) ((equal goto ...) (org-capture-goto-last-stored)) (t (let* ... ... ... ...)))
org-capture(nil)
-----------
call-interactively(org-capture nil nil)
recursive-edit()
byte-code("\306\x10 @\307=\203!\0\310\311\312\"\210\313\311!\211\x1aA@)\242\314=\203!\0\310\315\312\"\210\316\v!\210\317 \210\320 !\210\f\203d\0\321ed\"\rV\203W\0eb\210\322\r\245y\210`\x1e^[db\210\322\r\245\rZy\210\x0e^[`|\210)\323c\210eb\210\324\325\326 \"\210\327\306!\210\324\330!\210\331\312\x1e\x1c\x1e\x1d\324\330!\210\212\332 \210+\331\207" [unread-command-char debugger-args x debugger-buffer noninteractive debugger-batch-max-lines -1 debug backtrace-debug 4 t backtrace-frame lambda 5 pop-to-buffer debugger-mode debugger-setup-buffer count-lines 2 "...\n" message "%s" buffer-string kill-emacs "" nil recursive-edit middlestart buffer-read-only standard-output] 4)
----------------------------------------------------
there are some "Non-printable characters" in the last line
And this is capture buffer:
------------------- *Capture* - buffer-----------------
*** test 4760c3b
:PROPERTIES:
:ID: lab
%^{Number}p
%^{Type}p
:Feeling: %?
:Comment:
:Element: He
:END:
--------------------------------------------------------
hth with debugging
cheers,
Giovanni
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug: capture with PROPERTIES [7.3 commit-972b0a58...]
2010-12-10 12:10 Bug: capture with PROPERTIES [7.3 commit-972b0a58...] Giovanni Ridolfi
2010-12-13 15:34 ` Bug: capture with PROPERTIES [7.4 commit-4760c3b94...] Giovanni Ridolfi
@ 2011-01-04 12:57 ` Carsten Dominik
1 sibling, 0 replies; 3+ messages in thread
From: Carsten Dominik @ 2011-01-04 12:57 UTC (permalink / raw)
To: Giovanni Ridolfi; +Cc: emacs-orgmode
Hi Giovanny,
you are using the property prompt in an incorrect way.
The %^{Element}p can be anywhere in the template. It
will be removed *entirely*, and a corresponding property
will be added in the property drawer. So you are not
supposed to put this on a line by itself inside a
property drawer, because removing the % prompt will
then leave an empty line. In fact, supplying the
drawer is not necessary at all, it will be created
as needed. So if you were to prompt for all
properties, you could write the template it like this:
*** %^{prompt}
%^{ID}p %^{Element}p %^{Number}p %^{Type}p %^{Feeling}p
%^{Comment}p
But since you want to put some properties in later
by hand, your template should probably look like this:
*** %^{prompt}
%^{Element}p %^{Number}p %^{Type}p
:PROPERTIES:
:ID: lab
:Feeling: %?
:Comment:
:END:
But in this case you are not in control of the sequence in
which these properties will end up in the drawer. For maximum
control, you might want to use a normal prompt for the values,
avoiding the property prompt interface entirely:
*** %^{prompt}
:PROPERTIES:
:ID: lab
:Element: %^{Element}
:Number: %^{Number}
:Type: %^{Type}
:Feeling: %?
:Comment:
:END:
Note the missing "p" after the %{...} prompts.
Hope this helps. Maybe you want to suggest a patch
for the manual to make this clearer?
- Carsten
On Dec 10, 2010, at 1:10 PM, Giovanni Ridolfi wrote:
>
> Remember to cover the basics, that is, what you expected to happen and
> what in fact did happen. You don't know how to make a good report?
> See
>
> http://orgmode.org/manual/Feedback.html#Feedback
>
> Your bug report will be posted to the Org-mode mailing list.
> ------------------------------------------------------------------------
>
> Emacs : GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600)
> of 2010-05-08 on G41R2F1
> Package: Org-mode version 7.3
> commit-972b0a581eff180bcdc15883d2fe30c4cc24996a
>
>
> Hello everyone,
>
> I found a bug in the insertion of PROPERTies in capture templates.
>
> ------------------------ TEST FILE: ------------------
> -*- mode: org; -*-
>
> (setq org-capture-templates
> '(
> ("q" "element" entry (file+headline "test.org" "capture") "***
> %^{prompt} \n :PROPERTIES:\n :ID: lab \n %^{Element}p \n
> %^{Number}p \n %^{Type}p \n :Feeling: %? \n :Comment: \n :END:"
> )
> ))
> * capture
> :PROPERTIES:
> :Element_ALL: H He Li Na Hg
> :Number_ALL: 1 2 3 4 80
> :Type_ALL: gas solid liquid
> :END:
>
> -----------------------------------
> 1. set my capture template
> 2. call capture template.
> 3. Enter headline: "first test", <RET>
> so far so good.
> 4. Now you are requested to insert a PROPERTY
> and the buffer appears as:
>
> -------------------- 4th step --------------
> *** first test
> :PROPERTIES:
> :ID: lab
>
> %^{Number}p
> %^{Type}p
> :Feeling: %?
> :Comment:
> :END:
> ----------------------
> Value for Element: || cursor is here
> --------------------
> ------------------------------------------------
>
> 5. enter He <RET>
>
> BUG: the layout of the buffer is broken:
>
> ---------------------------
> *** first test
> :PROPERTIES:
> :ID: lab
> -------| a blank line is here
> |
> %^{Type}p |
> :Feeling: %? |
> :Comment: |
> :Element: He <-------| the property is inserted here!
> :END:
> ----------------------
> Value for Number: || (cursor is here)
> ---------------------------------------------------------
>
> The line of the property is inserted at the end
> of the Properties drawer, but before :END:.
>
> Not where the prompt was, and where I expected to find it.
>
> ----------------------- A complete test: ----------
> ** second test
> :PROPERTIES:
> :ID: lab
> . I put the "." to highligh the eol
> .
> .
> :Feeling: mickey mouse[1]
> :Comment:
> :Element: He
> :Number: 2
> :Type: gas
> :END:
> [1] http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1117755/
> ----------------------------
>
> cheers,
> Giovanni
>
> current state:
> ==============
> (setq
> org-log-done 'time
> org-export-latex-after-initial-vars-hook '(org-beamer-after-initial-
> vars)
> org-speed-command-hook '(org-speed-command-default-hook org-babel-
> speed-command-hook)
> org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
> org-metaup-hook '(org-babel-load-in-session-maybe)
> org-capture-templates '(("q" "element" entry (file+headline
> "test.org" "capture")
> "*** %^{prompt} \n :PROPERTIES:\n :ID: lab \n %^{Element}p \n
> %^{Number}p \n %^{Type}p \n :Feeling: %? \n :Comment: \n :END:")
> )
> org-after-todo-state-change-hook '(org-clock-out-if-current)
> org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup)
> org-export-latex-format-toc-function 'org-export-latex-format-toc-
> default
> org-capture-before-finalize-hook '(org-clock-in)
> org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-
> command-maybe org-babel-hide-result-toggle-maybe)
> org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-
> configure-edit-buffer)
> org-finalize-agenda-hook '(my-org-agenda-to-appt)
> org-confirm-shell-link-function 'yes-or-no-p
> org-export-first-hook '(org-beamer-initialize-open-trackers)
> org-agenda-before-write-hook '(org-agenda-add-entry-text)
> org-babel-pre-tangle-hook '(save-buffer)
> org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-
> drawers org-cycle-show-empty-lines
> org-optimize-window-after-visibility-change)
> org-export-preprocess-before-normalizing-links-hook '(org-remove-
> file-link-modifiers)
> org-mode-hook '((lambda nil
> (org-add-hook (quote change-major-mode-hook) (quote org-show-
> block-all) (quote append) (quote local)))
> (lambda nil
> (org-add-hook (quote change-major-mode-hook) (quote org-babel-
> show-result-all) (quote append)
> (quote local))
> )
> org-babel-result-hide-spec org-babel-hide-all-hashes)
> org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-
> safely-maybe)
> org-confirm-elisp-link-function 'yes-or-no-p
> org-export-interblocks '((lob org-babel-exp-lob-one-liners) (src org-
> babel-exp-inline-src-blocks))
> org-enforce-todo-dependencies t
> org-occur-hook '(org-first-headline-recenter)
> org-export-preprocess-before-selecting-backend-code-hook '(org-
> beamer-select-beamer-code)
> org-export-latex-final-hook '(org-beamer-amend-header org-beamer-fix-
> toc org-beamer-auto-fragile-frames
> org-beamer-place-default-actions-for-lists)
> org-metadown-hook '(org-babel-pop-to-session-maybe)
> org-export-blocks '((src org-babel-exp-src-blocks nil) (comment org-
> export-blocks-format-comment t)
> (ditaa org-export-blocks-format-ditaa nil) (dot org-export-
> blocks-format-dot nil))
> )
>
> _______________________________________________
> 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
- Carsten
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-04 12:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-10 12:10 Bug: capture with PROPERTIES [7.3 commit-972b0a58...] Giovanni Ridolfi
2010-12-13 15:34 ` Bug: capture with PROPERTIES [7.4 commit-4760c3b94...] Giovanni Ridolfi
2011-01-04 12:57 ` Bug: capture with PROPERTIES [7.3 commit-972b0a58...] Carsten Dominik
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).