From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Capture with org-directory not working? Date: Mon, 19 Sep 2016 15:46:50 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blyuV-0000L1-Hc for emacs-orgmode@gnu.org; Mon, 19 Sep 2016 09:47:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blyuQ-0003c5-Ni for emacs-orgmode@gnu.org; Mon, 19 Sep 2016 09:47:02 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:62363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blyuQ-0003bq-DE for emacs-orgmode@gnu.org; Mon, 19 Sep 2016 09:46:58 -0400 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" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi I have the following capture template: ,---- | ("T" "TODO to be logged in notes.org"=20=20=20=20 | entry (file+headline (concat org-directory "/notes.org") "Tasks")=20= =20=20=20=20=20=20=20 | ;; entry (file+headline "~/org/notes.org" "Tasks")=20=20=20=20=20=20= =20=20 | "* 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=3Dd 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 14= 04.47) of 2016-09-19 | Org-mode version 8.3.6 (release_8.3.6-1149-g582233 @ /Users/rainerkrug/.e= macs.d/org-mode/lisp/) `---- Backtrace: =2D-8<---------------cut here---------------start------------->8--- Debugger entered--Lisp error: (error "Target buffer \".notes\" for file+hea= dline should be in Org mode") signal(error ("Target buffer \".notes\" for file+headline should be in Or= g mode")) error("Target buffer \"%s\" for file+headline should be in Org mode" #) (if (derived-mode-p (quote org-mode)) nil (error "Target buffer \"%s\" fo= r file+headline should be in Org mode" (current-buffer))) (let ((hd (nth 2 target))) (goto-char (point-min)) (if (derived-mode-p (q= uote org-mode)) nil (error "Target buffer \"%s\" for file+headline should b= e in Org mode" (current-buffer))) (if (re-search-forward (format org-comple= x-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-buf= fer (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 or= g-mode)) nil (error "Target buffer \"%s\" for file+headline should be in Or= g mode" (current-buffer))) (if (re-search-forward (format org-complex-headi= ng-regexp-format (regexp-quote hd)) nil t) (goto-char (point-at-bol)) (goto= -char (point-max)) (or (bolp) (insert "\n")) (insert "* " hd "\n") (beginni= ng-of-line 0)))) ((eq (car target) (quote file+olp)) (let ((m (org-find-olp= (cons (org-capture-expand-file ...) (cdr ...))))) (set-buffer (marker-buff= er m)) (org-capture-put-target-region-and-position) (widen) (goto-char m)))= ((eq (car target) (quote file+regexp)) (set-buffer (org-capture-target-buf= fer (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 (der= ived-mode-p (quote org-mode)) (org-at-heading-p)))) (error "No match for ta= rget regexp in file %s" (nth 1 target)))) ((memq (car target) (quote (file+= datetree file+datetree+prompt file+weektree file+weektree+prompt))) (requir= e (quote org-datetree)) (set-buffer (org-capture-target-buffer (nth 1 targe= t))) (org-capture-put-target-region-and-position) (widen) (funcall (cond ((= memq (car target) (quote (file+weektree file+weektree+prompt))) (function o= rg-datetree-find-iso-week-create)) (t (function org-datetree-find-date-crea= te))) (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-pos= ition (point)) (setq target-entry-p (and (derived-mode-p (quote org-mode)) = (org-at-heading-p)))) ((eq (car target) (quote function)) (funcall (nth 1 t= arget)) (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-cl= ock-hd-marker)) (progn (set-buffer (marker-buffer org-clock-hd-marker)) (or= g-capture-put-target-region-and-position) (widen) (goto-char org-clock-hd-m= arker)) (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-ca= pture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-pos= ition) (widen) (setq target-entry-p nil)) ((eq (car target) (quote id)) (le= t ((loc (org-id-find (nth 1 target)))) (if (not loc) (error "Cannot find ta= rget ID \"%s\"" (nth 1 target)) (set-buffer (org-capture-target-buffer (car= loc))) (widen) (org-capture-put-target-region-and-position) (goto-char (cd= r loc))))) ((eq (car target) (quote file+headline)) (set-buffer (org-captur= e-target-buffer (nth 1 target))) (org-capture-put-target-region-and-positio= n) (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 o= rg-complex-heading-regexp-format (regexp-quote hd)) nil t) (goto-char (poin= t-at-bol)) (goto-char (point-max)) (or (bolp) (insert "\n")) (insert "* " h= d "\n") (beginning-of-line 0)))) ((eq (car target) (quote file+olp)) (let (= (m (org-find-olp (cons ... ...)))) (set-buffer (marker-buffer m)) (org-capt= ure-put-target-region-and-position) (widen) (goto-char m))) ((eq (car targe= t) (quote file+regexp)) (set-buffer (org-capture-target-buffer (nth 1 targe= t))) (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-f= ind-date-create))) (calendar-gregorian-from-absolute (cond (org-overriding-= default-time (time-to-days org-overriding-default-time)) ((memq ... ...) (l= et ... ... ...)) (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 (quo= te org-mode)) (org-at-heading-p)))) ((eq (car target) (quote function)) (fu= ncall (nth 1 target)) (org-capture-put :exact-position (point)) (setq targe= t-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-h= d-marker)) (org-capture-put-target-region-and-position) (widen) (goto-char = org-clock-hd-marker)) (error "No running clock that could be used as captur= e 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) :targe= t-entry-p target-entry-p :decrypted decrypted-hl-pos)) (let ((target-entry-p t) decrypted-hl-pos) (setq target (or target (org-c= apture-get :target))) (save-excursion (cond ((eq (car target) (quote file))= (set-buffer (org-capture-target-buffer (nth 1 target))) (org-capture-put-t= arget-region-and-position) (widen) (setq target-entry-p nil)) ((eq (car tar= get) (quote id)) (let ((loc (org-id-find ...))) (if (not loc) (error "Canno= t find target ID \"%s\"" (nth 1 target)) (set-buffer (org-capture-target-bu= ffer ...)) (widen) (org-capture-put-target-region-and-position) (goto-char = (cdr loc))))) ((eq (car target) (quote file+headline)) (set-buffer (org-cap= ture-target-buffer (nth 1 target))) (org-capture-put-target-region-and-posi= tion) (widen) (let ((hd (nth 2 target))) (goto-char (point-min)) (if (deriv= ed-mode-p (quote org-mode)) nil (error "Target buffer \"%s\" for file+headl= ine should be in Org mode" (current-buffer))) (if (re-search-forward (forma= t org-complex-heading-regexp-format ...) nil t) (goto-char (point-at-bol)) = (goto-char (point-max)) (or (bolp) (insert "\n")) (insert "* " hd "\n") (be= ginning-of-line 0)))) ((eq (car target) (quote file+olp)) (let ((m (org-fin= d-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-capt= ure-put :exact-position (point)) (setq target-entry-p (and ... ...))) (erro= r "No match for target regexp in file %s" (nth 1 target)))) ((memq (car tar= get) (quote (file+datetree file+datetree+prompt file+weektree file+weektree= +prompt))) (require (quote org-datetree)) (set-buffer (org-capture-target-b= uffer (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-a= bsolute (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) (func= all (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 :ex= act-position (point)) (setq target-entry-p (and (derived-mode-p (quote org-= mode)) (org-at-heading-p)))) ((eq (car target) (quote clock)) (if (and (mar= kerp 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 c= lock that could be used as capture target"))) (t (error "Invalid capture ta= rget specification"))) (if (and (featurep (quote org-crypt)) (org-at-encryp= ted-entry-p)) (progn (org-decrypt-entry) (setq decrypted-hl-pos (save-excur= sion (and (org-back-to-heading t) (point)))))) (org-capture-put :buffer (cu= rrent-buffer) :pos (point) :target-entry-p target-entry-p :decrypted decryp= ted-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 entr= y) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :o= riginal-file (or (buffer-file-name orig-buf) (and (featurep (quote dired)) = (car (rassq orig-buf dired-buffers)))) :original-file-nondirectory (and (bu= ffer-file-name orig-buf) (file-name-nondirectory (buffer-file-name orig-buf= ))) :annotation annotation :initial initial :return-to-wconf (current-windo= w-configuration) :default-time (or org-overriding-default-time (org-current= -time))) (org-capture-set-target-location) (condition-case error (org-captu= re-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 go= to 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-captur= e-get :return-to-wconf)) (error "Capture template `%s': %s" (org-capture-ge= t :key) (nth 1 error)))) (if (and (derived-mode-p (quote org-mode)) (org-ca= pture-get :clock-in)) (condition-case nil (progn (if (org-clock-is-active) = (org-capture-put :interrupted-clock ...)) (org-clock-in) (set (make-local-v= ariable ...) 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 or= g-capture-link-is-already-stored)) org-capture-link-is-already-stored) (pli= st-get org-store-link-plist :annotation) (condition-case nil (progn (org-st= ore-link nil)) (error nil)))) (entry (or org-capture-entry (org-capture-sel= ect-template keys))) initial) (setq initial (or org-capture-initial (and (o= rg-region-active-p) (buffer-substring (point) (mark))))) (if (stringp initi= al) (progn (remove-text-properties 0 (length initial) (quote (read-only t))= initial))) (if (stringp annotation) (progn (remove-text-properties 0 (leng= th annotation) (quote (read-only t)) annotation))) (cond ((equal entry "C")= (customize-variable (quote org-capture-templates))) ((equal entry "q") (us= er-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-templa= te) (org-capture-put :original-buffer orig-buf :original-file (or (buffer-f= ile-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-capt= ure-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 (ca= r ...) (quote function))) ((error quit) (if (and ... ...) (kill-buffer ...)= ) (set-window-configuration (org-capture-get :return-to-wconf)) (error "Cap= ture template `%s': %s" (org-capture-get :key) (nth 1 error)))) (if (and (d= erived-mode-p (quote org-mode)) (org-capture-get :clock-in)) (condition-cas= e nil (progn (if ... ...) (org-clock-in) (set ... t)) (error "Could not sta= rt the clock in this capture buffer"))) (if (org-capture-get :immediate-fin= ish) (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-b= uffer)) (annotation (if (and (boundp ...) org-capture-link-is-already-store= d) (plist-get org-store-link-plist :annotation) (condition-case nil (progn = ...) (error nil)))) (entry (or org-capture-entry (org-capture-select-templa= te 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 annotat= ion) (quote (read-only t)) annotation))) (cond ((equal entry "C") (customiz= e-variable (quote org-capture-templates))) ((equal entry "q") (user-error "= Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-c= apture-put :original-buffer orig-buf :original-file (or (buffer-file-name o= rig-buf) (and ... ...)) :original-file-nondirectory (and (buffer-file-name = orig-buf) (file-name-nondirectory ...)) :annotation annotation :initial ini= tial :return-to-wconf (current-window-configuration) :default-time (or org-= overriding-default-time (org-current-time))) (org-capture-set-target-locati= on) (condition-case error (org-capture-put :template (org-capture-fill-temp= late)) ((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) =2D-8<---------------cut here---------------end--------------->8--- Rainer =2D-=20 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 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBCAAGBQJX3+xOAAoJENvXNx4PUvmCBdYH/RUHZayD61zkr4B0Hb9O5gvk w1ZGIbsywY/8rCKc8UZnig4U4p81KIc/NQzpFlXs7eEUinbzegzMclxFSysBI3vB KpYSoLVPZI31RmVwoFJ8VAQk1b4oht9toVfthoYXe0qKXPph8x1jukt186RW/OfP FwbHFZ63jRgMCV0I8GIvN6c9Og6zW1rOgJa7/OcIMAwHkgeCoLfi10TdKwAZdvHw CVd7dXl2UtZV1dIK0okF7TLMtxtuyyxn2IfkkeiXZv/KmwpXLTwmNE01xrOmw2sD add1s22MHwLf0yxmSu0ax2aTs3Cgn/gWf2ImSCTuiuRHlfQJeXSxzEbvvSzbj7c= =tw7L -----END PGP SIGNATURE----- --=-=-=--