emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Capture with org-directory not working?
@ 2016-09-19 13:46 Rainer M Krug
  2016-09-19 15:47 ` Nick Dokos
  0 siblings, 1 reply; 13+ messages in thread
From: Rainer M Krug @ 2016-09-19 13:46 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 17681 bytes --]

Hi

I have the following capture template:

,----
|   ("T"   "TODO to be logged in notes.org"    
|    entry   (file+headline (concat org-directory "/notes.org") "Tasks")        
|    ;; entry   (file+headline "~/org/notes.org" "Tasks")        
|    "* TODO [#D] \n%i \n:PROPERTIES: \n:END: \n%? \n%a")
`----

As it is now, it is not working, but when I use the secont=d entry line,
it is working.

But:

,----
|  (concat org-directory "/notes.org")
| "~/org/notes.org"
`----

So why is the first version (which I prefer as the path is not hard
coded) not working anymore?

,----
| GNU Emacs 25.1.1 (x86_64-apple-darwin15.6.0, Carbon Version 157 AppKit 1404.47) of 2016-09-19
| Org-mode version 8.3.6 (release_8.3.6-1149-g582233 @ /Users/rainerkrug/.emacs.d/org-mode/lisp/)
`----

Backtrace:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (error "Target buffer \".notes\" for file+headline should be in Org mode")
  signal(error ("Target buffer \".notes\" for file+headline should be in Org mode"))
  error("Target buffer \"%s\" for file+headline should be in Org mode" #<buffer .notes>)
  (if (derived-mode-p (quote org-mode)) nil (error "Target buffer \"%s\" for file+headline should be in Org mode" (current-buffer)))
  (let ((hd (nth 2 target))) (goto-char (point-min)) (if (derived-mode-p (quote org-mode)) nil (error "Target buffer \"%s\" for file+headline should be in Org mode" (current-buffer))) (if (re-search-forward (format org-complex-heading-regexp-format (regexp-quote hd)) nil t) (goto-char (point-at-bol)) (goto-char (point-max)) (or (bolp) (insert "\n")) (insert "* " hd "\n") (beginning-of-line 0)))
  (cond ((eq (car target) (quote file)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (setq target-entry-p nil)) ((eq (car target) (quote id)) (let ((loc (org-id-find (nth 1 target)))) (if (not loc) (error "Cannot find target ID \"%s\"" (nth 1 target)) (set-buffer (org-capture-target-buffer (car loc))) (widen) (org-capture-put-target-region-and-position) (goto-char (cdr loc))))) ((eq (car target) (quote file+headline)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (let ((hd (nth 2 target))) (goto-char (point-min)) (if (derived-mode-p (quote org-mode)) nil (error "Target buffer \"%s\" for file+headline should be in Org mode" (current-buffer))) (if (re-search-forward (format org-complex-heading-regexp-format (regexp-quote hd)) nil t) (goto-char (point-at-bol)) (goto-char (point-max)) (or (bolp) (insert "\n")) (insert "* " hd "\n") (beginning-of-line 0)))) ((eq (car target) (quote file+olp)) (let ((m (org-find-olp (cons (org-capture-expand-file ...) (cdr ...))))) (set-buffer (marker-buffer m)) (org-capture-put-target-region-and-position) (widen) (goto-char m))) ((eq (car target) (quote file+regexp)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (goto-char (point-min)) (if (re-search-forward (nth 2 target) nil t) (progn (goto-char (if (org-capture-get :prepend) (match-beginning 0) (match-end 0))) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) (org-at-heading-p)))) (error "No match for target regexp in file %s" (nth 1 target)))) ((memq (car target) (quote (file+datetree file+datetree+prompt file+weektree file+weektree+prompt))) (require (quote org-datetree)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (funcall (cond ((memq (car target) (quote (file+weektree file+weektree+prompt))) (function org-datetree-find-iso-week-create)) (t (function org-datetree-find-date-create))) (calendar-gregorian-from-absolute (cond (org-overriding-default-time (time-to-days org-overriding-default-time)) ((memq (car target) (quote ...)) (let (...) (org-capture-put :default-time ...) (time-to-days prompt-time))) (t (org-today)))))) ((eq (car target) (quote file+function)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (funcall (nth 2 target)) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) (org-at-heading-p)))) ((eq (car target) (quote function)) (funcall (nth 1 target)) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) (org-at-heading-p)))) ((eq (car target) (quote clock)) (if (and (markerp org-clock-hd-marker) (marker-buffer org-clock-hd-marker)) (progn (set-buffer (marker-buffer org-clock-hd-marker)) (org-capture-put-target-region-and-position) (widen) (goto-char org-clock-hd-marker)) (error "No running clock that could be used as capture target"))) (t (error "Invalid capture target specification")))
  (save-excursion (cond ((eq (car target) (quote file)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (setq target-entry-p nil)) ((eq (car target) (quote id)) (let ((loc (org-id-find (nth 1 target)))) (if (not loc) (error "Cannot find target ID \"%s\"" (nth 1 target)) (set-buffer (org-capture-target-buffer (car loc))) (widen) (org-capture-put-target-region-and-position) (goto-char (cdr loc))))) ((eq (car target) (quote file+headline)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (let ((hd (nth 2 target))) (goto-char (point-min)) (if (derived-mode-p (quote org-mode)) nil (error "Target buffer \"%s\" for file+headline should be in Org mode" (current-buffer))) (if (re-search-forward (format org-complex-heading-regexp-format (regexp-quote hd)) nil t) (goto-char (point-at-bol)) (goto-char (point-max)) (or (bolp) (insert "\n")) (insert "* " hd "\n") (beginning-of-line 0)))) ((eq (car target) (quote file+olp)) (let ((m (org-find-olp (cons ... ...)))) (set-buffer (marker-buffer m)) (org-capture-put-target-region-and-position) (widen) (goto-char m))) ((eq (car target) (quote file+regexp)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (goto-char (point-min)) (if (re-search-forward (nth 2 target) nil t) (progn (goto-char (if (org-capture-get :prepend) (match-beginning 0) (match-end 0))) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p ...) (org-at-heading-p)))) (error "No match for target regexp in file %s" (nth 1 target)))) ((memq (car target) (quote (file+datetree file+datetree+prompt file+weektree file+weektree+prompt))) (require (quote org-datetree)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (funcall (cond ((memq (car target) (quote ...)) (function org-datetree-find-iso-week-create)) (t (function org-datetree-find-date-create))) (calendar-gregorian-from-absolute (cond (org-overriding-default-time (time-to-days org-overriding-default-time)) ((memq ... ...) (let ... ... ...)) (t (org-today)))))) ((eq (car target) (quote file+function)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (funcall (nth 2 target)) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) (org-at-heading-p)))) ((eq (car target) (quote function)) (funcall (nth 1 target)) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) (org-at-heading-p)))) ((eq (car target) (quote clock)) (if (and (markerp org-clock-hd-marker) (marker-buffer org-clock-hd-marker)) (progn (set-buffer (marker-buffer org-clock-hd-marker)) (org-capture-put-target-region-and-position) (widen) (goto-char org-clock-hd-marker)) (error "No running clock that could be used as capture target"))) (t (error "Invalid capture target specification"))) (if (and (featurep (quote org-crypt)) (org-at-encrypted-entry-p)) (progn (org-decrypt-entry) (setq decrypted-hl-pos (save-excursion (and (org-back-to-heading t) (point)))))) (org-capture-put :buffer (current-buffer) :pos (point) :target-entry-p target-entry-p :decrypted decrypted-hl-pos))
  (let ((target-entry-p t) decrypted-hl-pos) (setq target (or target (org-capture-get :target))) (save-excursion (cond ((eq (car target) (quote file)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (setq target-entry-p nil)) ((eq (car target) (quote id)) (let ((loc (org-id-find ...))) (if (not loc) (error "Cannot find target ID \"%s\"" (nth 1 target)) (set-buffer (org-capture-target-buffer ...)) (widen) (org-capture-put-target-region-and-position) (goto-char (cdr loc))))) ((eq (car target) (quote file+headline)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (let ((hd (nth 2 target))) (goto-char (point-min)) (if (derived-mode-p (quote org-mode)) nil (error "Target buffer \"%s\" for file+headline should be in Org mode" (current-buffer))) (if (re-search-forward (format org-complex-heading-regexp-format ...) nil t) (goto-char (point-at-bol)) (goto-char (point-max)) (or (bolp) (insert "\n")) (insert "* " hd "\n") (beginning-of-line 0)))) ((eq (car target) (quote file+olp)) (let ((m (org-find-olp ...))) (set-buffer (marker-buffer m)) (org-capture-put-target-region-and-position) (widen) (goto-char m))) ((eq (car target) (quote file+regexp)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (goto-char (point-min)) (if (re-search-forward (nth 2 target) nil t) (progn (goto-char (if ... ... ...)) (org-capture-put :exact-position (point)) (setq target-entry-p (and ... ...))) (error "No match for target regexp in file %s" (nth 1 target)))) ((memq (car target) (quote (file+datetree file+datetree+prompt file+weektree file+weektree+prompt))) (require (quote org-datetree)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (funcall (cond ((memq ... ...) (function org-datetree-find-iso-week-create)) (t (function org-datetree-find-date-create))) (calendar-gregorian-from-absolute (cond (org-overriding-default-time ...) (... ...) (t ...))))) ((eq (car target) (quote file+function)) (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-position) (widen) (funcall (nth 2 target)) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) (org-at-heading-p)))) ((eq (car target) (quote function)) (funcall (nth 1 target)) (org-capture-put :exact-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) (org-at-heading-p)))) ((eq (car target) (quote clock)) (if (and (markerp org-clock-hd-marker) (marker-buffer org-clock-hd-marker)) (progn (set-buffer (marker-buffer org-clock-hd-marker)) (org-capture-put-target-region-and-position) (widen) (goto-char org-clock-hd-marker)) (error "No running clock that could be used as capture target"))) (t (error "Invalid capture target specification"))) (if (and (featurep (quote org-crypt)) (org-at-encrypted-entry-p)) (progn (org-decrypt-entry) (setq decrypted-hl-pos (save-excursion (and (org-back-to-heading t) (point)))))) (org-capture-put :buffer (current-buffer) :pos (point) :target-entry-p target-entry-p :decrypted decrypted-hl-pos)))
  org-capture-set-target-location()
  (cond ((equal entry "C") (customize-variable (quote org-capture-templates))) ((equal entry "q") (user-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :original-file (or (buffer-file-name orig-buf) (and (featurep (quote dired)) (car (rassq orig-buf dired-buffers)))) :original-file-nondirectory (and (buffer-file-name orig-buf) (file-name-nondirectory (buffer-file-name orig-buf))) :annotation annotation :initial initial :return-to-wconf (current-window-configuration) :default-time (or org-overriding-default-time (org-current-time))) (org-capture-set-target-location) (condition-case error (org-capture-put :template (org-capture-fill-template)) ((error quit) (if (get-buffer "*Capture*") (kill-buffer "*Capture*")) (error "Capture abort: %s" error))) (setq org-capture-clock-keep (org-capture-get :clock-keep)) (if (equal goto 0) (org-capture-insert-template-here) (condition-case error (org-capture-place-template (equal (car (org-capture-get :target)) (quote function))) ((error quit) (if (and (buffer-base-buffer ...) (string-prefix-p "CAPTURE-" ...)) (kill-buffer (current-buffer))) (set-window-configuration (org-capture-get :return-to-wconf)) (error "Capture template `%s': %s" (org-capture-get :key) (nth 1 error)))) (if (and (derived-mode-p (quote org-mode)) (org-capture-get :clock-in)) (condition-case nil (progn (if (org-clock-is-active) (org-capture-put :interrupted-clock ...)) (org-clock-in) (set (make-local-variable ...) t)) (error "Could not start the clock in this capture buffer"))) (if (org-capture-get :immediate-finish) (org-capture-finalize)))))
  (let* ((orig-buf (current-buffer)) (annotation (if (and (boundp (quote org-capture-link-is-already-stored)) org-capture-link-is-already-stored) (plist-get org-store-link-plist :annotation) (condition-case nil (progn (org-store-link nil)) (error nil)))) (entry (or org-capture-entry (org-capture-select-template keys))) initial) (setq initial (or org-capture-initial (and (org-region-active-p) (buffer-substring (point) (mark))))) (if (stringp initial) (progn (remove-text-properties 0 (length initial) (quote (read-only t)) initial))) (if (stringp annotation) (progn (remove-text-properties 0 (length annotation) (quote (read-only t)) annotation))) (cond ((equal entry "C") (customize-variable (quote org-capture-templates))) ((equal entry "q") (user-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :original-file (or (buffer-file-name orig-buf) (and (featurep (quote dired)) (car (rassq orig-buf dired-buffers)))) :original-file-nondirectory (and (buffer-file-name orig-buf) (file-name-nondirectory (buffer-file-name orig-buf))) :annotation annotation :initial initial :return-to-wconf (current-window-configuration) :default-time (or org-overriding-default-time (org-current-time))) (org-capture-set-target-location) (condition-case error (org-capture-put :template (org-capture-fill-template)) ((error quit) (if (get-buffer "*Capture*") (kill-buffer "*Capture*")) (error "Capture abort: %s" error))) (setq org-capture-clock-keep (org-capture-get :clock-keep)) (if (equal goto 0) (org-capture-insert-template-here) (condition-case error (org-capture-place-template (equal (car ...) (quote function))) ((error quit) (if (and ... ...) (kill-buffer ...)) (set-window-configuration (org-capture-get :return-to-wconf)) (error "Capture template `%s': %s" (org-capture-get :key) (nth 1 error)))) (if (and (derived-mode-p (quote org-mode)) (org-capture-get :clock-in)) (condition-case nil (progn (if ... ...) (org-clock-in) (set ... t)) (error "Could not start the clock in this capture buffer"))) (if (org-capture-get :immediate-finish) (org-capture-finalize))))))
  (cond ((equal goto (quote (4))) (org-capture-goto-target)) ((equal goto (quote (16))) (org-capture-goto-last-stored)) (t (let* ((orig-buf (current-buffer)) (annotation (if (and (boundp ...) org-capture-link-is-already-stored) (plist-get org-store-link-plist :annotation) (condition-case nil (progn ...) (error nil)))) (entry (or org-capture-entry (org-capture-select-template keys))) initial) (setq initial (or org-capture-initial (and (org-region-active-p) (buffer-substring (point) (mark))))) (if (stringp initial) (progn (remove-text-properties 0 (length initial) (quote (read-only t)) initial))) (if (stringp annotation) (progn (remove-text-properties 0 (length annotation) (quote (read-only t)) annotation))) (cond ((equal entry "C") (customize-variable (quote org-capture-templates))) ((equal entry "q") (user-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :original-file (or (buffer-file-name orig-buf) (and ... ...)) :original-file-nondirectory (and (buffer-file-name orig-buf) (file-name-nondirectory ...)) :annotation annotation :initial initial :return-to-wconf (current-window-configuration) :default-time (or org-overriding-default-time (org-current-time))) (org-capture-set-target-location) (condition-case error (org-capture-put :template (org-capture-fill-template)) ((error quit) (if ... ...) (error "Capture abort: %s" error))) (setq org-capture-clock-keep (org-capture-get :clock-keep)) (if (equal goto 0) (org-capture-insert-template-here) (condition-case error (org-capture-place-template ...) (... ... ... ...)) (if (and ... ...) (condition-case nil ... ...)) (if (org-capture-get :immediate-finish) (org-capture-finalize))))))))
  org-capture(nil)
  funcall-interactively(org-capture nil)
  call-interactively(org-capture nil nil)
  command-execute(org-capture)
--8<---------------cut here---------------end--------------->8---

Rainer

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug

PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-19 13:46 Capture with org-directory not working? Rainer M Krug
@ 2016-09-19 15:47 ` Nick Dokos
  2016-09-20  7:25   ` Rainer M Krug
  0 siblings, 1 reply; 13+ messages in thread
From: Nick Dokos @ 2016-09-19 15:47 UTC (permalink / raw)
  To: emacs-orgmode

Rainer M Krug <Rainer@krugs.de> writes:

> Hi
>
> I have the following capture template:
>
> ,----
> |   ("T"   "TODO to be logged in notes.org"    
> |    entry   (file+headline (concat org-directory "/notes.org") "Tasks")        
> |    ;; entry   (file+headline "~/org/notes.org" "Tasks")        
> |    "* TODO [#D] \n%i \n:PROPERTIES: \n:END: \n%? \n%a")
> `----
>
> As it is now, it is not working, but when I use the secont=d entry line,
> it is working.
>

Try (!!note the backquote at the beginning  and the comma before the concat form!!):

--8<---------------cut here---------------start------------->8---
(setq org-capture-templates
 `(
   ...
   ("T"   "TODO to be logged in notes.org"    
    entry   (file+headline ,(concat org-directory "/notes.org") "Tasks")        
    "* TODO [#D] \n%i \n:PROPERTIES: \n:END: \n%? \n%a")
   ...))
--8<---------------cut here---------------end--------------->8---


See

  (info "(elisp) Backquote")


-- 
Nick

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-19 15:47 ` Nick Dokos
@ 2016-09-20  7:25   ` Rainer M Krug
  2016-09-20 15:00     ` Adam Porter
  0 siblings, 1 reply; 13+ messages in thread
From: Rainer M Krug @ 2016-09-20  7:25 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1787 bytes --]

Nick Dokos <ndokos@gmail.com> writes:

> Rainer M Krug <Rainer@krugs.de> writes:
>
>> Hi
>>
>> I have the following capture template:
>>
>> ,----
>> |   ("T"   "TODO to be logged in notes.org"    
>> |    entry   (file+headline (concat org-directory "/notes.org") "Tasks")        
>> |    ;; entry   (file+headline "~/org/notes.org" "Tasks")        
>> |    "* TODO [#D] \n%i \n:PROPERTIES: \n:END: \n%? \n%a")
>> `----
>>
>> As it is now, it is not working, but when I use the secont=d entry line,
>> it is working.
>>
>
> Try (!!note the backquote at the beginning  and the comma before the concat form!!):
>
> (setq org-capture-templates
>  `(
>    ...
>    ("T"   "TODO to be logged in notes.org"    
>     entry   (file+headline ,(concat org-directory "/notes.org") "Tasks")        
>     "* TODO [#D] \n%i \n:PROPERTIES: \n:END: \n%? \n%a")
>    ...))
>

Thanks! the problem was the missing comma, as I had the backquote
already there. This must have changed some time ago, as I used these
templates before. This is working now.

But now I realized that my other in-file capture templates are giving
the same message. Here is one of my in-file capture templates:

,----
| (setq org-capture-templates
|       `(
|         ;; ;;;;;;;;;;;;;;;;::
|         ;; In File Logging ::
|         ;; ;;;;;;;;;;;;;;;;::
|         ("p"   "Problem to be logged in buffer"    
|          entry   (file+headline (buffer-file-name) "QUESTIONS")  
|         ...
|         ))
`----

I assume it also has to do with the evaluation, but putting a comma in
front of (buffer-file-name) does not change anything. 

Thanks,

Rainer


>
> See
>
>   (info "(elisp) Backquote")

-- 
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-20  7:25   ` Rainer M Krug
@ 2016-09-20 15:00     ` Adam Porter
  2016-09-20 16:03       ` Rainer Krug
  0 siblings, 1 reply; 13+ messages in thread
From: Adam Porter @ 2016-09-20 15:00 UTC (permalink / raw)
  To: emacs-orgmode

Rainer M Krug <Rainer@krugs.de> writes:

> Thanks! the problem was the missing comma, as I had the backquote
> already there. This must have changed some time ago, as I used these
> templates before. This is working now.
>
> But now I realized that my other in-file capture templates are giving
> the same message.

This might be like heresy to some Emacs users, but if you put
org-capture-templates in custom-set-variables, you can skip the
backquoting and comma-quoting.  Makes it a bit simpler.  :)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-20 15:00     ` Adam Porter
@ 2016-09-20 16:03       ` Rainer Krug
  2016-09-20 17:08         ` Adam Porter
  0 siblings, 1 reply; 13+ messages in thread
From: Rainer Krug @ 2016-09-20 16:03 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]


> On 20 Sep 2016, at 17:00, Adam Porter <adam@alphapapa.net> wrote:
> 
> Rainer M Krug <Rainer@krugs.de> writes:
> 
>> Thanks! the problem was the missing comma, as I had the backquote
>> already there. This must have changed some time ago, as I used these
>> templates before. This is working now.
>> 
>> But now I realized that my other in-file capture templates are giving
>> the same message.
> 
> This might be like heresy to some Emacs users, but if you put
> org-capture-templates in custom-set-variables, you can skip the
> backquoting and comma-quoting.  Makes it a bit simpler.  :)
> 

Could you please provide an example? It is not clear to me what you mean - I prefer simpler!

Rainer

--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-20 16:03       ` Rainer Krug
@ 2016-09-20 17:08         ` Adam Porter
  2016-09-21  7:05           ` Rainer Krug
  0 siblings, 1 reply; 13+ messages in thread
From: Adam Porter @ 2016-09-20 17:08 UTC (permalink / raw)
  To: emacs-orgmode

Rainer Krug <r.m.krug@gmail.com> writes:

> Could you please provide an example? It is not clear to me what you mean - I prefer simpler!

Sure, here's an abbreviated example of custom-set-variables from my
init.el:

#+BEGIN_SRC elisp
  (custom-set-variables
   ;; custom-set-variables was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
   '(org-capture-templates
     (quote
      (("a" "Appointment" entry
        (file+datetree+prompt
         (concat org-directory "/calendar.org")
         "Calendar")
        "* %^{Description} %T %^G
  
  %U %?" :clock-in t :clock-resume t)))))
#+END_SRC

The downside is that, if you're editing them in your init file instead
of through the customize interface, you have to eval the entire
custom-set-variables to apply changes, which requires a few extra
keystrokes.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-20 17:08         ` Adam Porter
@ 2016-09-21  7:05           ` Rainer Krug
  2016-09-21 11:51             ` Adam Porter
  0 siblings, 1 reply; 13+ messages in thread
From: Rainer Krug @ 2016-09-21  7:05 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]


> On 20 Sep 2016, at 19:08, Adam Porter <adam@alphapapa.net> wrote:
> 
> Rainer Krug <r.m.krug@gmail.com> writes:
> 
>> Could you please provide an example? It is not clear to me what you mean - I prefer simpler!
> 
> Sure, here's an abbreviated example of custom-set-variables from my
> init.el:
> 
> #+BEGIN_SRC elisp
>  (custom-set-variables
>   ;; custom-set-variables was added by Custom.
>   ;; If you edit it by hand, you could mess it up, so be careful.
>   ;; Your init file should contain only one such instance.
>   ;; If there is more than one, they won't work right.
>   '(org-capture-templates
>     (quote
>      (("a" "Appointment" entry
>        (file+datetree+prompt
>         (concat org-directory "/calendar.org")
>         "Calendar")
>        "* %^{Description} %T %^G
> 
>  %U %?" :clock-in t :clock-resume t)))))
> #+END_SRC
> 
> The downside is that, if you're editing them in your init file instead
> of through the customize interface, you have to eval the entire
> custom-set-variables to apply changes, which requires a few extra
> keystrokes.
> 
> 

Thanks - I see what you mean. But It seems to abusing the basic idea of custom-set-variables as this sounds as if it is used by the customise interface.

So it should be possible to set it using my initial approach?

Rainer


--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-21  7:05           ` Rainer Krug
@ 2016-09-21 11:51             ` Adam Porter
  2016-09-21 12:49               ` Rainer M Krug
  0 siblings, 1 reply; 13+ messages in thread
From: Adam Porter @ 2016-09-21 11:51 UTC (permalink / raw)
  To: emacs-orgmode

Rainer Krug <r.m.krug@gmail.com> writes:

> But It seems to abusing the basic idea of custom-set-variables as this
> sounds as if it is used by the customise interface.

What I mean is, you can use the customize interface to store your
org-capture-templates.  It's already set up for that.  You can either
edit it through the customize interface, or you can edit it directly in
the init file and then evaluate the ~(custom-set-variables~ sexp manually.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-21 11:51             ` Adam Porter
@ 2016-09-21 12:49               ` Rainer M Krug
  2016-11-29 19:23                 ` Alexander Vorobiev
  0 siblings, 1 reply; 13+ messages in thread
From: Rainer M Krug @ 2016-09-21 12:49 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

Adam Porter <adam@alphapapa.net> writes:

> Rainer Krug <r.m.krug@gmail.com> writes:
>
>> But It seems to abusing the basic idea of custom-set-variables as this
>> sounds as if it is used by the customise interface.
>
> What I mean is, you can use the customize interface to store your
> org-capture-templates.  It's already set up for that.  You can either
> edit it through the customize interface, or you can edit it directly in
> the init file and then evaluate the ~(custom-set-variables~ sexp manually.
>

OK - but I prefer to keep my configurations in my .emacs.el file to make
it reproducible.


Thanks,

Rainer

>

-- 
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-09-21 12:49               ` Rainer M Krug
@ 2016-11-29 19:23                 ` Alexander Vorobiev
  2016-11-29 21:05                   ` Nick Dokos
  0 siblings, 1 reply; 13+ messages in thread
From: Alexander Vorobiev @ 2016-11-29 19:23 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: Adam Porter, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]

I have recently started having this issue with my capture templates. In my
case I want to ask the user (me) which file should be used to store the
note, so I have a bunch of templates like this

(setq org-capture-templates
             '(("o" "Project todo" entry (file+headline
(av/choose-agenda-file) "Tasks") ))

where av/choose-agenda-file uses completing-read to ask the user to choose
a file from a list it constructs on the fly. This approach has worked for
years and now it results in the "invalid file location" message. The
backquote does not help because the function needs to be called at run
time, not when the variable is defined.

Thanks,
Alex

On Wed, Sep 21, 2016 at 7:49 AM, Rainer M Krug <Rainer@krugs.de> wrote:

> Adam Porter <adam@alphapapa.net> writes:
>
> > Rainer Krug <r.m.krug@gmail.com> writes:
> >
> >> But It seems to abusing the basic idea of custom-set-variables as this
> >> sounds as if it is used by the customise interface.
> >
> > What I mean is, you can use the customize interface to store your
> > org-capture-templates.  It's already set up for that.  You can either
> > edit it through the customize interface, or you can edit it directly in
> > the init file and then evaluate the ~(custom-set-variables~ sexp
> manually.
> >
>
> OK - but I prefer to keep my configurations in my .emacs.el file to make
> it reproducible.
>
>
> Thanks,
>
> Rainer
>
> >
>
> --
> Rainer M. Krug
> email: Rainer<at>krugs<dot>de
> PGP: 0x0F52F982
>

[-- Attachment #2: Type: text/html, Size: 2245 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-11-29 19:23                 ` Alexander Vorobiev
@ 2016-11-29 21:05                   ` Nick Dokos
  2016-11-30  5:15                     ` Alexander Vorobiev
  0 siblings, 1 reply; 13+ messages in thread
From: Nick Dokos @ 2016-11-29 21:05 UTC (permalink / raw)
  To: emacs-orgmode

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> I have recently started having this issue with my capture templates. In my case I want to ask the user
> (me) which file should be used to store the note, so I have a bunch of templates like this
>
> (setq org-capture-templates
>              '(("o" "Project todo" entry (file+headline (av/choose-agenda-file) "Tasks") ))
>
> where av/choose-agenda-file uses completing-read to ask the user to choose a file from a list it
> constructs on the fly. This approach has worked for years and now it results in the "invalid file
> location" message. The backquote does not help because the function needs to be called at run time, not
> when the variable is defined.
>

IIUC, you cannot use arbitrary sexps, but you *can* use

("o" "Project todo" entry (file+headline (lambda () (av/choose-agenda-file)) "Tasks"))

Other plausible forms (e.g. (function av/choose-agenda-file) or (quote av/choose-agenda-file) )
run afoul of the abritrary sexp exception and do not work AFAICS.

-- 
Nick

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-11-29 21:05                   ` Nick Dokos
@ 2016-11-30  5:15                     ` Alexander Vorobiev
  2016-11-30 16:45                       ` Nick Dokos
  0 siblings, 1 reply; 13+ messages in thread
From: Alexander Vorobiev @ 2016-11-30  5:15 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]

The workaround with lambda worked, thanks a lot! As I mentioned I didn't
have any problems with the templates in years but they stopped working
after a recent update.

Alex

On Tue, Nov 29, 2016 at 3:05 PM, Nick Dokos <ndokos@gmail.com> wrote:

> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>
> > I have recently started having this issue with my capture templates. In
> my case I want to ask the user
> > (me) which file should be used to store the note, so I have a bunch of
> templates like this
> >
> > (setq org-capture-templates
> >              '(("o" "Project todo" entry (file+headline
> (av/choose-agenda-file) "Tasks") ))
> >
> > where av/choose-agenda-file uses completing-read to ask the user to
> choose a file from a list it
> > constructs on the fly. This approach has worked for years and now it
> results in the "invalid file
> > location" message. The backquote does not help because the function
> needs to be called at run time, not
> > when the variable is defined.
> >
>
> IIUC, you cannot use arbitrary sexps, but you *can* use
>
> ("o" "Project todo" entry (file+headline (lambda ()
> (av/choose-agenda-file)) "Tasks"))
>
> Other plausible forms (e.g. (function av/choose-agenda-file) or (quote
> av/choose-agenda-file) )
> run afoul of the abritrary sexp exception and do not work AFAICS.
>
> --
> Nick
>
>
>

[-- Attachment #2: Type: text/html, Size: 1981 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Capture with org-directory not working?
  2016-11-30  5:15                     ` Alexander Vorobiev
@ 2016-11-30 16:45                       ` Nick Dokos
  0 siblings, 0 replies; 13+ messages in thread
From: Nick Dokos @ 2016-11-30 16:45 UTC (permalink / raw)
  To: emacs-orgmode

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> The workaround with lambda worked, thanks a lot! As I mentioned I didn't have any problems with the
> templates in years but they stopped working after a recent update.
>

The change was made last June (I presume it was committed on the master branch, so it
became generally available only when Org 9.0 was released):

,----
| commit 5485170263a46fa17db67b0324c4c4e48bcdfe49
| Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
| Date:   Fri Jun 24 01:11:49 2016 +0200
| 
|     org-capture: Remove forbidden value type from "file" templates
|     
|     * lisp/org-capture.el (org-capture-expand-file): Remove plain S-exps
|       from allowed values.
`----

-- 
Nick

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-11-30 16:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19 13:46 Capture with org-directory not working? Rainer M Krug
2016-09-19 15:47 ` Nick Dokos
2016-09-20  7:25   ` Rainer M Krug
2016-09-20 15:00     ` Adam Porter
2016-09-20 16:03       ` Rainer Krug
2016-09-20 17:08         ` Adam Porter
2016-09-21  7:05           ` Rainer Krug
2016-09-21 11:51             ` Adam Porter
2016-09-21 12:49               ` Rainer M Krug
2016-11-29 19:23                 ` Alexander Vorobiev
2016-11-29 21:05                   ` Nick Dokos
2016-11-30  5:15                     ` Alexander Vorobiev
2016-11-30 16:45                       ` Nick Dokos

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