I am currently experimenting with om and try to load external data for displaying it in a component.
My detail component:
(defn detail-component [app owner opts]
(reify
om/IInitState
(init-state [_]
(om/transact! app [:data] (fn [] "Test")))
om/IWillMount
(will-mount [_]
(go (let [foo (<! (fetch-something 1))]
(om/update! app #(assoc % :data foo))
)))
om/IRender
(render [_]
(dom/div nil
(dom/h1 nil "Foo")
(om/build another-component app)
)
))
)
(fetch-something is retrieving data from an API).
(defn another-component [{:keys [data]}]
(om/component
(.log js/console data)
(dom/h2 nil "Another component goes here")
(dom/h2 nil (data :description))
)
)
So to summarize, detail-component fetches data before mounting, attaches it to app and builds another-component. another-component then takes the description out of that data and displays it.
However when executing, I am getting Uncaught TypeError: Cannot read property 'call' of null at the point where I am trying to access the description. This indicates to me that at the point when another-component is getting built, the data is not there yet and it fails.
How can I tell om to build the app when data is available? Or do I have to build in some nil? checks?
Working example using state:
project.clj
(defproject asajax "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License - v 1.0"
:url "http://www.eclipse.org/legal/epl-v10.html"
:distribution :repo}
:min-lein-version "2.3.4"
:source-paths ["src/clj" "src/cljs"]
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2371"]
[org.clojure/core.async "0.1.267.0-0d7780-alpha"]
[om "0.7.3"]
[com.facebook/react "0.11.2"]]
:plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]]
:hooks [leiningen.cljsbuild]
:cljsbuild
{:builds {:asajax
{:source-paths ["src/cljs"]
:compiler
{:output-to "dev-resources/public/js/asajax.js"
:optimizations :whitespace
:pretty-print true}}}})
core.cljs
(ns asajax.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :as async])
(:require-macros [cljs.core.async.macros :refer (go)]))
(enable-console-print!)
(def app-state (atom {}))
(defn another-component [{:keys [data]}]
(reify
om/IRenderState
(render-state [_ state]
(dom/div nil
;; (.log js/console data)
(dom/h2 nil "Another component goes here")
(dom/h2 nil (:description state))))))
(defn fetch-something [x]
(let [c (async/chan)]
(go
;; pretend a blocking call
;; wait for 2 sec
(<! (async/timeout 2000))
(>! c {:data "Roast peach & Parma ham salad"
:description "This is a lovely light starter with fantastic sweet, salty and creamy flavours"}))
c))
(defn detail-component [app owner opts]
(reify
om/IInitState
(init-state [_]
{:data "Test"})
om/IWillMount
(will-mount [_]
(go (let [foo (<! (fetch-something 1))]
;; (prn "GOT" foo)
(om/set-state! owner foo))))
om/IRenderState
(render-state [_ state]
(dom/div nil
(dom/h1 nil (:data state))
(om/build another-component app
{:state (om/get-state owner)})))))
(om/root
detail-component
app-state
{:target (. js/document (getElementById "app"))})
UPDATE2
Here is one using sablono and not using set-state!
Add to project.clj
[sablono "0.2.22"]
Full core.cljs
(ns asajax.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :as async]
[sablono.core :as html :refer-macros [html]])
(:require-macros [cljs.core.async.macros :refer (go)]))
(enable-console-print!)
(def app-state (atom {:data "Initial"
:description "Loading..."}))
(defn another-component [{:keys [description]}]
(om/component
(html
[:.description
[:h2 "Another component"]
[:h2 description]])))
(defn fetch-something [x]
(let [c (async/chan)]
(go
;; pretend a blocking call
;; wait for 2 sec
(<! (async/timeout 2000))
(>! c {:data "Roast peach & Parma ham salad"
:description "This is a lovely light starter with fantastic sweet, salty and creamy flavours"}))
c))
(defn detail-component [app owner opts]
(reify
om/IWillMount
(will-mount [_]
(go (let [foo (<! (fetch-something 1))]
;; (prn "GOT" foo)
(om/update! app foo))))
om/IRender
(render [_]
(html [:div
[:h1 (:data app)]
(om/build another-component app)
]))))
(om/root
detail-component
app-state
{:target (. js/document (getElementById "app"))})
Related
I am having trouble with some basic IO operations using Clojure. I have a text file which I need to read, split with the "|" character, and enter into a list for later processing. Here are the contents of my text file:
1|John Smith|123 Here Street|456-4567
2|Sue Jones|43 Rose Court Street|345-7867
3|Fan Yuhong|165 Happy Lane|345-4533
And here is my current code:
((defn -main []
(println "Enter an option: \n")
(let [choice (read-line)]
(cond (= choice "1")
(let [cust-contents (slurp "file.txt")
nums-as-strings (clojure.string/split cust-contents #"|")
numbers (map read-string nums-as-strings)]
(print numbers)
)
)
) ) )
(-main)
I would think this code to work, however here is the error I get when running my program:
(; Execution error at user/eval7923$-main (REPL:11).
; EOF while reading
Could anyone please guide me on where I went wrong and on how to fix this?
That error is actually caused when you call read-string with argument " ".
And where that " " comes from? You used the wrong regex in clojure.string/split, you should use #"\|" instead of #"|".
And even then, you can't call read-string on everything, as it would soon crash again, trying to parse "456-4567".
Also, ending parentheses belong to the same line.
If your file contains newlines, you will need clojure.string/split-lines and if you will also implement 2 Display Product Table, 3. Display Sales Table and so on (I know the context for this code), case will be better than cond.
Here is your code with some improvements:
(ns homework.core
(:require [clojure.string :as s])
(:gen-class))
(defn -main []
(println "Enter an option: \n")
(let [choice (read-line)]
(case choice
"1" (->> (s/split-lines (slurp "file.txt"))
(mapv #(s/split % #"\|"))
println)
"Wrong number")))
(-main)
For one thing, you should not have 2 left parentheses in a row like ((defn ....
Also, CSV parsing has many libraries to remove the drudgery of reinventing the wheel. My favorite is illustrated below:
(ns tst.demo.core
(:use demo.core tupelo.core tupelo.test)
(:require
[tupelo.csv :as csv]))
(verify
; ***** NOTE ***** most CSV has a header line, which is added below for convenience!
(let [data-str "id|name|address|phone
1|John Smith|123 Here Street|456-4567
2|Sue Jones|43 Rose Court Street|345-7867
3|Fan Yuhong|165 Happy Lane|345-4533 "
entity-maps (csv/csv->entities data-str {:separator \|})]
(is= entity-maps
[{:address "123 Here Street", :id "1", :name "John Smith", :phone "456-4567"}
{:address "43 Rose Court Street", :id "2", :name "Sue Jones", :phone "345-7867"}
{:address "165 Happy Lane", :id "3", :name "Fan Yuhong", :phone "345-4533"}])))
This unit test leaves out the file-reading part as that just complicates things in a unit test.
The above solution is based on my favorite template project, which also has a list of documentation sources toward the end.
You can find examine the source code for tupelo.csv
and also the unit tests.
To clarify your code, here is a cleaned-up version:
(verify
(let [data-str "1|John Smith|123 Here Street|456-4567
2|Sue Jones|43 Rose Court Street|345-7867
3|Fan Yuhong|165 Happy Lane|345-4533 "
data-lines (str/split-lines data-str)
token-table-str (vec (for [line data-lines]
(let [token-strs (str/split line #"\|")]
(mapv str/trim token-strs))))]
(is= token-table-str
[["1" "John Smith" "123 Here Street" "456-4567"]
["2" "Sue Jones" "43 Rose Court Street" "345-7867"]
["3" "Fan Yuhong" "165 Happy Lane" "345-4533"]])))
Notice that I didn't parse the data past the String stage.
Add [clojure-csv/clojure-csv "2.0.1"] to your lein dependencies.
Do lein deps to install it.
Put into a file e.g. "/home/me/test.csv"
1|John Smith|123 Here Street|456-4567
2|Sue Jones|43 Rose Court Street|345-7867
3|Fan Yuhong|165 Happy Lane|345-4533
(ns csvread
(:require [clojure-csv.core :as csv]))
(defn parse-table [file]
(csv/parse-csv (slurp file) :delimiter \|))
(defn parse-table-from-string [s]
(csv/parse-csv s :delimiter \|))
Apply it:
(parse-table "/home/me/test.csv")
;; => (["1" "John Smith" "123 Here Street" "456-4567"]
;; ["2" "Sue Jones" "43 Rose Court Street" "345-7867"]
;; ["3" "Fan Yuhong" "165 Happy Lane" "345-4533 "])
(def s "1|John Smith|123 Here Street|456-4567
2|Sue Jones|43 Rose Court Street|345-7867
3|Fan Yuhong|165 Happy Lane|345-4533")
(parse-table-from-string s)
This example is a little contrived. The goal is to create a macro that loops over some values and programmatically generates some code.
A common pattern in Python is to initialize the properties of an object at calling time as follows:
(defclass hair [foo bar]
(defn __init__ [self]
(setv self.foo foo)
(setv self.bar bar)))
This correctly translates with hy2py to
class hair(foo, bar):
def __init__(self):
self.foo = foo
self.bar = bar
return None
I know there are Python approaches to this problem including attr.ib and dataclasses. But as a simplified learning exercise I wanted to approach this with a macro.
This is my non-working example:
(defmacro self-set [&rest args]
(for [[name val] args]
`(setv (. self (read-str ~name)) ~val)))
(defn fur [foo bar]
(defn __init__ [self]
(self-set [["foo" foo] ["bar" bar]])))
But this doesn't expand to the original pattern. hy2py shows:
from hy.core.language import name
from hy import HyExpression, HySymbol
import hy
def _hy_anon_var_1(hyx_XampersandXname, *args):
for [name, val] in args:
HyExpression([] + [HySymbol('setv')] + [HyExpression([] + [HySymbol
('.')] + [HySymbol('self')] + [HyExpression([] + [HySymbol(
'read-str')] + [name])])] + [val])
hy.macros.macro('self-set')(_hy_anon_var_1)
def fur(foo, bar):
def __init__(self, foo, bar):
return None
Wbat am I doing wrong?
for forms always return None. So, your loop is constructing the (setv ...) forms you request and then throwing them away. Instead, try lfor, which returns a list of results, or gfor, which returns a generator. Note also in the below example that I use do to group the generated forms together, and I've moved a ~ so that the read-str happens at compile-time, as it must in order for . to work.
(defmacro self-set [&rest args]
`(do ~#(gfor
[name val] args
`(setv (. self ~(read-str name)) ~val))))
(defclass hair []
(defn __init__ [self]
(self-set ["foo" 1] ["bar" 2])))
(setv h (hair))
(print h.bar) ; 2
I'm new to Clojure and I have a question regarding nested doseq loops.
I would like to iterate through a sequence and get a subsequence, and then get some keys to apply a function over all the sequence elements.
The given sequence has an structure more or less like this, but with hundreds of books, shelves and many libraries:
([:state/libraries {6 #:library {:name "MUNICIPAL LIBRARY OF X" :id 6
:shelves {3 #:shelf {:name "GREEN SHELF" :id 3 :books
{45 #:book {:id 45 :name "NECRONOMICON" :pages {...},
{89 #:book {:id 89 :name "HOLY BIBLE" :pages {...}}}}}}}}])
Here is my code:
(defn my-function [] (let [conn (d/connect (-> my-system :config :datomic-uri))]
(doseq [library-seq (read-string (slurp "given-sequence.edn"))]
(doseq [shelves-seq (val library-seq)]
(library/create-shelf conn {:id (:shelf/id (val shelves-seq))
:name (:shelf/name (val shelves-seq))})
(doseq [books-seq (:shelf/books (val shelves-seq))]
(library/create-book conn (:shelf/id (val shelves-seq)) {:id (:book/id (val books-seq))
:name (:book/name (val books-seq))})
)))))
The thing is that I want to get rid of that nested doseq mess but I don't know what would be the best approach, since in each iteration keys change. Using recur? reduce? Maybe I am thinking about this completely the wrong way?
Like Carcigenicate says in the comments, presuming that the library/... functions are only side effecting, you can just write this in a single doseq.
(defn my-function []
(let [conn (d/connect (-> my-system :config :datomic-uri))]
(doseq [library-seq (read-string (slurp "given-sequence.edn"))
shelves-seq (val library-seq)
:let [_ (library/create-shelf conn
{:id (:shelf/id (val shelves-seq))
:name (:shelf/name (val shelves-seq))})]
books-seq (:shelf/books (val shelves-seq))]
(library/create-book conn
(:shelf/id (val shelves-seq))
{:id (:book/id (val books-seq))
:name (:book/name (val books-seq))}))))
I would separate "connecting to the db" from "slurping a file" from "writing to the db" though. Together with some destructuring I'd end up with something more like:
(defn write-to-the-db [conn given-sequence]
(doseq [library-seq given-sequence
shelves-seq (val library-seq)
:let [{shelf-id :shelf/id,
shelf-name :shelf/name
books :shelf/books} (val shelves-seq)
_ (library/create-shelf conn {:id shelf-id, :name shelf-name})]
{book-id :book/id, book-name :book/name} books]
(library/create-book conn shelf-id {:id book-id, :name book-name})))
I have been trying to get org-mobile to work on my machine with little
success. I have read many previous answers from this mailing list to no
avail.
When I try to run org-mobile-push I get an error in the minibuffer: "Wrong
type argument: listp, todo".
I have attached a Backtrace of the error and my org-mode settings. I also
attached a debugger eval of the "todo" variable, which I think (I'm not
great at elisp) is causing the error.
Can anyone tell me how I can get org-mobile-push to work correctly?
Cheers!
---- Backtrace and org settings follow ----
Debugger entered--Lisp error: (void-variable todo)
eval(todo)
eval-expression(todo)
debugger-eval-expression(todo)
call-interactively(debugger-eval-expression nil nil)
recursive-edit()
byte-code("\306^P
#\307=\203!^#\310\311\312\"\210\313\311!\211^ZA#)\242\314=\203!^#\310\315\312\"\210\316^K!\210\317
\210\320
!\210\f\203d^#\321ed\"^MV\203W^#eb\210\322^M\245y\210`^^^[db\210\322^M\245^MZy\210^N^[`|\210)\323c\210eb\210\324\325\326
\"\210\327\306!\210\324\330!\210\331\312^^^\^^^]\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)
Debugger entered--Lisp error: (wrong-type-argument listp todo)
car(todo)
(setq type (car e) match (nth 1 e) settings (nth 2 e))
(while (setq e (pop cmds)) (setq type (car e) match (nth 1 e) settings
(nth 2 e)) (setq settings (append gsettings settings)) (setq settings (cons
... settings)) (push (list type match settings) new))
(cond ((stringp ...)) ((eq ... ...)) ((memq ... ...)) ((and ... ...))
((memq ... ...) (setq key ... desc ... type ... match ... settings ...)
(setq settings ...) (push ... new)) ((or ... ...)) (t (setq gkey ... gdesc
... gsettings ... cmds ...) (setq cnt 0) (while ... ... ... ... ...)))
(while (setq e (pop thelist)) (cond (...) (...) (...) (...) (... ... ...
...) (...) (t ... ... ...)))
(let ((custom-list ...) (default-list ...) thelist new e key desc type
match settings cmds gkey gdesc gsettings cnt) (cond (... ...) (... ...)
(... ... ... ...) (... ... ...)) (while (setq e ...) (cond ... ... ... ...
... ... ...)) (and new (list "X" "SUMO" ... ...)))
org-mobile-sumo-agenda-command()
(let* ((file ...) (file1 ...) (sumo ...) (org-agenda-custom-commands ...)
(org-mobile-creating-agendas t)) (unless (file-writable-p file1) (error
"Cannot write to file %s" file1)) (when sumo (org-store-agenda-views))
(when org-mobile-use-encryption (org-mobile-encrypt-and-move file1 file)
(delete-file file1) (org-mobile-cleanup-encryption-tempfile)))
org-mobile-create-sumo-agenda()
(let ((inhibit-redisplay t)) (org-mobile-create-sumo-agenda))
(save-window-excursion (run-hooks (quote org-mobile-pre-push-hook))
(org-mobile-check-setup) (org-mobile-prepare-file-lists) (message "Creating
agendas...") (let (...) (org-mobile-create-sumo-agenda)) (message "Creating
agendas...done") (org-save-all-org-buffers) (message "Copying files...")
(org-mobile-copy-agenda-files) (message "Writing index file...")
(org-mobile-create-index-file) (message "Writing checksums...")
(org-mobile-write-checksums) (run-hooks (quote org-mobile-post-push-hook)))
(save-excursion (save-window-excursion (run-hooks ...)
(org-mobile-check-setup) (org-mobile-prepare-file-lists) (message "Creating
agendas...") (let ... ...) (message "Creating agendas...done")
(org-save-all-org-buffers) (message "Copying files...")
(org-mobile-copy-agenda-files) (message "Writing index file...")
(org-mobile-create-index-file) (message "Writing checksums...")
(org-mobile-write-checksums) (run-hooks ...)))
(let ((org-agenda-buffer-name "*SUMO*") (org-agenda-filter
org-agenda-filter) (org-agenda-redo-command org-agenda-redo-command))
(save-excursion (save-window-excursion ... ... ... ... ... ... ... ... ...
... ... ... ... ...)))
(let ((a-buffer ...)) (let (... ... ...) (save-excursion ...))
(redraw-display) (when (and a-buffer ...) (if ... ... ...)))
org-mobile-push()
call-interactively(org-mobile-push t nil)
execute-extended-command(nil)
call-interactively(execute-extended-command nil nil)
Emacs : GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4)
of 2011-04-04 on rothera, modified by Debian
Package: Org-mode version 7.7
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-agenda-custom-commands '(("c" "TODO list, Priority down" todo
"NEXTACTION"
((org-agenda-sorting-strategy (quote (priority-down)))
)
("/media/sf_Conor/todolistprioritydown.ps"))
("x" "Todo List and Agenda"
(todo (quote (priority-down))
(agenda "" (org-agenda-ndays 1)))
((org-agenda-sorting-strategy (quote (time-up))))
("/media/sf_Conor/todolistprioritydown.ps"))
("w" "other Work" tags-todo "DONE"
((org-agenda-files
(quote
("/media/sf_Conor/Dropbox/Orgmode/2011/todo.org"))
)
(org-agenda-sorting-strategy
(quote (priority-up effort-down)))
)
("/media/sf_Conor/computer.html"))
("p" "Priority List" tags-todo
((org-agenda-sorting-strategy (quote (priority-up)))))
)
org-agenda-files '("/media/sf_Conor/Dropbox/Orgmode/2011/
accountmanagement.org"
"/media/sf_Conor/Dropbox/Orgmode/2011/heritage.org"
"/media/sf_Conor/Dropbox/Orgmode/2011/arbitrage.org"
"/media/sf_Conor/Dropbox/Orgmode/2011/kontagent.org"
"/media/sf_Conor/Dropbox/Orgmode/2011/todo.org")
org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
org-agenda-exporter-settings '((ps-number-of-columns 2) (ps-landscape-mode
t)
(org-agenda-add-entry-text-maxlines 5)
(htmlize-output-type (quote css)))
org-metaup-hook '(org-babel-load-in-session-maybe)
org-after-todo-state-change-hook '(wicked/org-clock-out-if-waiting
wicked/org-clock-in-if-starting
org-clock-out-if-current)
org-agenda-todo-ignore-scheduled t
org-show-entry-below t
org-export-blocks-postblock-hook '(org-exp-res/src-name-cleanup)
org-export-latex-format-toc-function 'org-export-latex-format-toc-default
org-mobile-inbox-for-pull "/media/sf_Conor/Dropbox/Orgmode/2011/
from-mobile.org"
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-confirm-shell-link-function 'yes-or-no-p
org-export-first-hook '(org-beamer-initialize-open-trackers)
org-clock-persist t
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-agenda-start-with-follow-mode t
org-directory "/media/sf_Conor/Dropbox/Orgmode/2011/"
org-export-docbook-xslt-proc-command ""
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-agenda-dim-blocked-tasks nil
org-mode-hook '((lambda nil (org-set-local (quote yas/trigger-key) [tab])
(define-key yas/keymap [tab] (quote yas/next-field-group))
(define-key org-mode-map "\301"
(quote org-archive-to-archive-sibling))
)
org-clock-load
(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-refile-targets '(:level . 2)
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-clock-out-hook '(org-clock-remove-empty-clock-drawer)
org-enforce-todo-dependencies t
org-occur-hook '(org-first-headline-recenter)
org-from-is-user-regexp "\\<Conor Nash\\>"
org-mobile-directory "/media/sf_Conor/Dropbox/MobileOrg/"
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-block nil)
(comment org-export-blocks-format-comment t)
(ditaa org-export-blocks-format-ditaa nil)
(dot org-export-blocks-format-dot nil))
)
I believe your problem is with the org-agenda-custom-commands variable. In particular you have the value
("x" "Todo List and Agenda"
(todo (quote (priority-down))
(agenda "" (org-agenda-ndays 1)))
((org-agenda-sorting-strategy (quote (time-up))))
("/media/sf_Conor/todolistprioritydown.ps"))
which is the cause of the problem, at least I get the same error when I set org-agenda-custom-commands as you have and run M-x org-agenda RET x. Changing it's value to
("x" "Todo List and Agenda"
((todo (quote (priority-down)))
(agenda "" ((org-agenda-ndays 1))))
((org-agenda-sorting-strategy (quote (time-up))))
("/media/sf_Conor/todolistprioritydown.ps"))
"fixes" the error, but I don't know if it actually does what you want. Note there are extra parentheses in 2 places: around (todo (quote (priority-down))) and ((org-agenda-ndays 1)).
Don't know about the backtracenot a elisper also but I've setup mine using the following post,
http://nakkaya.com/2010/03/19/org-mode-in-your-pocket-setting-up-mobileorg/
My .emacs:
;; enable orgmode en set files
(require 'org-install)
(setq org-directory "~/Dropbox/GTD/")
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(setq org-agenda-files (list (concat org-directory "nextactions.org")
(concat org-directory "projects.org")
(concat org-directory "birthday.org")))
;; Daily action list
(setq org-agenda-custom-commands
'(
("D" "Daily Action List"
(
(agenda "" ((org-agenda-ndays 1)
(org-agenda-sorting-strategy
(quote ((agenda time-up priority-down tag-up) )))
(org-deadline-warning-days 0)
))))
;; Office list
("H" "Office and Home Lists"
((agenda)
(tags-todo "OFFICE")
(tags-todo "HOME")))
)
)
;; Turn on diary within org-mode
(setq org-agenda-include-diary t)
;; Turn on Capture
(setq org-default-notes-file (concat org-directory "notes.org"))
(define-key global-map "\C-cc" 'org-capture)
;; Capture templates
(setq org-capture-templates
'(
("t" "Todo" entry (file+headline (concat org-directory "nextactions.org") "Inbox") "* TODO %?\n %i\n %a")
("j" "Journal" entry (file+datetree (concat org-directory "journal.org")) "* %?\nEntered on %U\n %i\n %a")
)
)
C-c c presents the capture menu buffer. I press then t and capture the buffer that appears (CAPTURE-notes.org). After C-c C-c the entry is added to notes.org instead of nextactions.org section "Inbox".
I have no .emacs parsing errors, how can I fix this so the todo capture-template puts its entry in nextactions.org?
Edit: Setting org-default-notes-file to nextactions.org lets me operate at least the first org-capture template (because its file is the same anyway). The second one stays writing to the default-notes-file.
What org-mode version are you using? I don't remember the exact version, but quoted capture templates were not eval'ed before that.
So you should try either
Update org-mode
use backquotes
(setq org-capture-templates
`(("t" "Todo" entry (file+headline ,(concat org-directory "nextactions.org")
"Inbox")
"* TODO %?\n %i\n %a")
("j" "Journal" entry (file+datetree ,(concat org-directory "journal.org"))
"* %?\nEntered on %U\n %i\n %a")
))
use the literal filepath
(setq org-capture-templates
'(("t" "Todo" entry (file+headline "~/Dropbox/GTD/nextactions.org"
"Inbox")
"* TODO %?\n %i\n %a")
("j" "Journal" entry (file+datetree "~/Dropbox/GTD/journal.org")
"* %?\nEntered on %U\n %i\n %a")
))
Apart from that I see no problem with your config, I use a similar one.
infact you can even refile from the capture buffer to which ever agenda file you want to with C-c C-w.