In org agenda clock table the file time is coming ** instead of sum of time in all task. How can I fix this?
Update:
This issue has been fixed in the latest build or org-mode and emacs
This is a bug AFAICS.
To fix it immediately you can fix function org-clocktable-write-default in your installation by replacing the line
(format (concat "| %s %s | %s%s"
with
(format (concat "| %s %s | %s%s%s"
Or you can wait for the next release of Org.
Related
I am trying to create an org-table based on the content of a CSV file that uses ";" as a delimiter.
I thought it would be easy to have a source code block to "cat" the content of the file and then pass the result to a function that creates the table, but I got stuck: I can't find a way to use the "results" of the first source code block. The function I know (org-table-convert-region) expects a region to work on and I don't know how to pass the "cat"-ed text as a region.
#+NAME: csvraw
#+BEGIN_SRC sh :results raw
cat afile.csv
#+END_SRC
I'd appreciate your help to generate a code block that produces an org-table out of my csv file, which contains lines like the following:
ID;Region;SubRegion;Area;No
1234;Asia;India;45;2
24251;Europe;Romania;456;67
There is org-table-convert-region (bound to C-c |) which can do the transformation fairly simply. The only trick is to specify ; as the separator. You can do that by invoking it with the proper prefix argument - the doc string says:
(org-table-convert-region BEG0 END0 &optional SEPARATOR)
Convert region to a table.
The region goes from BEG0 to END0, but these borders will be moved
slightly, to make sure a beginning of line in the first line is included.
SEPARATOR specifies the field separator in the lines. It can have the
following values:
(4) Use the comma as a field separator
(16) Use a TAB as field separator
(64) Prompt for a regular expression as field separator
integer When a number, use that many spaces, or a TAB, as field separator
regexp When a regular expression, use it to match the separator
nil When nil, the command tries to be smart and figure out the
separator in the following way:
- when each line contains a TAB, assume TAB-separated material
- when each line contains a comma, assume CSV material
- else, assume one or more SPACE characters as separator.
The (64) value is just three C-u in a row, so the process is as follows:
insert the CSV file with C-x i.
C-x C-x to mark the inserted contents as the active region.
C-u C-u C-u C-c | ; RET
What's even cooler, leaving an empty line in the CSV file between the first line and the rest of the lines, will make the first line a header in the table automatically.
And you can wrap it up in a code block as well:
#+begin_src elisp :var file="/tmp/foo.csv" :results raw
(defun csv-to-table (file)
(with-temp-buffer
(erase-buffer)
(insert-file file)
(org-table-convert-region (point-min) (point-max) ";")
(buffer-string)))
(csv-to-table file)
#+end_src
#+RESULTS:
| a | b | c |
|---+---+---|
| d | e | f |
| g | h | i |
(defun jea-convert-csv-to-org-table (fname)
(interactive "fCSV to convert: ")
(let ((result '("|-\n")))
(with-temp-buffer
(save-excursion (insert-file-contents-literally fname))
(while (and (not (eobp)) (re-search-forward "^\\(.+\\)$" nil t nil))
(push (concat "|" (replace-regexp-in-string ";" "|" (match-string 1)) "|\n")
result))
(push '"|-\n" result))
(concat (seq-mapcat #'identity (reverse result)))))
install the elisp code in your ~/.emacs file and restart emacs. Or, better yet, eval it into existence (CTRL+x, CTRL+e or ALT+x eval-last-sexp).
#+NAME: csvraw
#+BEGIN_SRC elisp :results raw
(jea-convert-csv-to-org-table "/Users/jamesanderson/Downloads/test1.csv")
#+END_SRC
note the change to elisp from sh in the above. here is a gif of it in action:
emacs converting csv to org table
The code is not optimized for large files, and, to be frank, quite quickly thrown together. But, after a tiny bit of testing, seems to work.
I am sure some of you may have gathered (from my recent barrage of questions) that I am setting up org-mode on emacs and walking through Brent Hansen's impressive org set up. He is a clocking fanatic, and I like a lot of the stuff he does to track time spent on projects.
I (think) haven't messed up in setting things up, but whenever I try to clock in our out of a task I get an error with a lot of gibberish (reported below). I've tried to see if there are some patterns to how the error emerges but am unable to discover them. They seem to happen pretty often but not all the time which makes debugging them an even bigger pain.
Typically, when I clock out of a task (but sometime when I clock in too), I get a message like this
save-excursion: Wrong number of arguments: #[(drawer pos) "rÂ!
Ã!pq~bÄÅ ÆQÇ\"$ÈÉ!+" [pos drawer markerp marker-buffer org-in-regexp "^[ ]*:" ":[ ]*
[ ]*:END:[ ]*
?" 2 replace-match ""] 4 ("/Users/krishnan/.emacs.d/elpa/org-20140210/org.elc" . 450779)], 1
[a-z..]:Set [SPC]:clear [2 times]
As always, I am happy to follow up to questions that might help discover the source of the error. I have not been able to discern if it standard practice to include my entire .emacs etc, but am happy to post follow up information as is needed.
Many thanks in advance!
edit 1: Following #iqbal-ansari , I did M-x toggle-debug-on-error which produces the following gunk:
Debugger entered--Lisp error: (wrong-number-of-arguments #[(drawer pos) "r\302!\203
\303!\202pq\210\212\214~\210b\210\304\305 \306Q\307\"\205$\310\311!+\207" [pos drawer markerp marker-buffer org-in-regexp "^[ ]*:" ":[ ]*
[ ]*:END:[ ]*
?" 2 replace-match ""] 4 ("/Users/krishnan/.emacs.d/elpa/org-20140210/org.elc" . 450779)] 1)
org-remove-empty-drawer-at(307)
(save-excursion (beginning-of-line 0) (org-remove-empty-drawer-at (point)))
bh/remove-empty-drawer-on-clock-out()
#[(f) " \207" [f] 1](bh/remove-empty-drawer-on-clock-out)
mapc(#[(f) " \207" [f] 1] (org-clock-remove-empty-clock-drawer bh/remove-empty-drawer-on-clock-out bh/clock-out-maybe))
byte-code("\306 \204\307\310\" \311 \210\203\312\313\314\"\210\202\315\316!\210\f\2035\317\320r\321
!q\210#)\322\314\323%\2027A\324B!\322\211\211\211\211\211CDEFGHIAIJ\212\325 q\210\214~\210
b\210\326\327!\210\330\331KP!\203~\332\327!L\232\203~\332\333!H\202\216\203\212\312\313\322\"\210\202\216\334\335!\210\336\225b\210`\337 |\210\340c\210\341M\206\242I\342\343#G\344\345\346\347G!\"!\344\345\346\347H!\"!ZF\350F\351\245!EFE\351_ZF\350F\352\245!DF\211\352_ZF\353\354\355ED#\261\210N\205\364ED\\\336U\211C\203\326\327!\210`\337 |\210\330\356!\203d`TV\203\357\327!\210
\322\211\223\210O\322\211\223\210P\2033\360\361\322\211\211\211\362\363\314!\364Q&\210Q\203#\365Q!\210\322QR\203M\365R!\210\322R\307\310\" A\203\234\212\366\314!\210\314\322ST\367A!\203\205\330U!\210A\332\333!!\211V\203\201\370V!\210)\202\233A\203\233\330W\331A\371R!\204\233\370A!\210+\311 \210\372\373\374E\352_D\\!\375QGC\203\267\376\202\270\377#\210XEYZ\232\203\335[\201]=\203\335S\203\335\307\201^E\"E\201_\201`E\"\210)\306 ?\205\362\322\211\\.\n\207" [global-mode-string org-frame-title-format-backup frame-title-format fail-quietly switch-to-state org-clock-marker org-clocking-p delq org-mode-line-string force-mode-line-update throw exit t user-error "No active clock" completing-read "Switch to state: " marker-buffer nil "DONE" org-current-time org-clocking-buffer beginning-of-line 1 looking-at "[ ]*" match-string 2 error "Clock start time is gone" 0 point-at-eol "--" org-insert-time-stamp with-hm inactive org-float-time apply encode-time org-parse-time-string floor 3600 60 " => " format "%2d:%02d" "\n" delete-char org-add-log-setup clock-out ...] 10)
org-clock-out()
org-clock-out-if-current()
run-hooks(org-after-todo-state-change-hook)
byte-code("\306\307!\210\310\311P!\203\312 \210\307\310\n!\203\313\225Sb\210\310\314\315Q!\204)\310\316!\210\304 \317 \304 #\320\216\321\322\323\307\211$*ABBCCDDE\313\232\203X\322E\324\202ZFF\325\326!G\313\224H\327G!I\330IJ\"\211KA#L\331K8M\332K8NG\206\212\333O\307PGQ\235\211RAST\203\303E\334\232\203\255U\335=\204\276E\204\303U\203\303U\335=\204\303\336 \202E\337\232\203\341U\203\324T\204\341\340\341\342\343Q\"\322\307$\202E\344=\203\376G\203\370S\205S#\202Q#\202E\345=\203/RQ\232?\205G\203\"\346QGSG\347#Q8\202Q#\350#!#)\202U\307=\203DE\351\232\203D\322\211E\206E\203\310E\333\232\203T\322\202E\352=\203_\322\202E\353=\203qM\206V#\202E\354=\203\210IW\235A#\206W#\202E\355=\203\246\356W!WIW\235A#\206\242W#)\202EQ\235#\206E;\203\275\357\360E\"\202\361E!SQ8\202R\204\330I\206Q#\202GN\232\203\344\322\202S\204\355\322\202L\362>\203XY=\203S#\202SG\313V\205M\206V#\202S#Z\363\364ZO#\206&Z\211Z\2034\365Z\365Q\2025\365[\366\367\370G\371Z\372
\257\\\322\211]^=\203\230GV\235?_\212\304 #\373\216\212\214~\210\374\375\\\"-\204\230\376\377!\203\201\357\201jGZ`$\210\202\230\201k\201jGZ`$\210\201l\201m\322\"\210\201n\f!\210\201o[\307\211#\210\201pH!\204\276\201k\201q\201r[!\"\210I\204\342\327Z!I\330IJ\"\211KA#L\331K8M\332K8NE\201s>\203\201k\201t\346aG\201u\330Za\"a>G#aG\201v\201w\330Za\"\365#$\210ZV\235?_ZV\235\205,GV\235?^A\203:\201xA!\210D\204DB\203\357F\307=\204\357E\201y>\204\357\330ZD\"A#\206g\347\330GD\"8\211]\324=\203{F\324=\203{\201z]Z\204\205b\203\232Z\203\244Zc\235\203\244Gc\235\204\244\201{\322\211\201|#\210^\203\324B\203\324\201{\201|\201} \"\210]\204\324B\324=\203\324\201~\353ZG\201\324%\210Z\203\357]\203\357\201~\201\200ZG\201]%\210\201\201Z!\210d\203e\204\201\202\322\307\"\210f\203\201\203 \210\201\204\201\205!\210E\203,ZV\235\204,\327Z!I\201\206\317 \201\207 \201\210I$\210^\203a\201\211\201g!\203Z\304 #\201\212\216\201\213 g*\201\214Z!\210\201\215 \203\235n\204\235\212\201\216\326!\210\310h!)\203\235`\347\211\225\206\204\326\225\\W\203\235\347\225\206\220\326\225b\210\310\365!\203\235\201\217 \210i\203\256\212\201\220\201i\\\"\210) \205\264\312 .\207" [org-comment-string commentp org-outline-regexp org-todo-regexp match-data startpos org-back-to-heading t looking-at "^\\*+ " org-toggle-comment 0 " +" "\\( +\\|[ ]*$\\)" "\\(?: *\\|[ ]*$\\)" point-at-bol ((byte-code "\301\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) org-entry-get nil "LOGGING" note match-string 1 org-get-todo-sequence-head assoc 3 4 "" (4) prefix org-fast-todo-selection (4) org-icompleting-read "State: " mapcar list right left - 2 last (4) none done nextset previousset reverse user-error "State `%s' not valid in this file" prefix-numeric-value ...] 10)
org-todo(nil)
call-interactively(org-todo)
org-agenda-todo(nil)
call-interactively(org-agenda-todo nil nil)
The issue is caused by the line (org-remove-empty-drawer-at (point)) in the function bh/remove-empty-drawer-on-clock-out. If you read the documentation of the function org-remove-empty-drawer-at (do C-hforg-remove-empty-drawer-atRET, it says that the function accepts two arguments drawer and point while the function bh/remove-empty-drawer-on-clock-out passes only one argument (point). This causes the error you reported. It seems the code was written for an older version of org-mode.
This is a temporary solution, remove the line
(add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
from your init file (and restart emacs). This will get rid of the error.
UPDATE
I got (I think) a permanent solution to the problem. The first argument to the function org-remove-empty-drawer-at is the name of the drawer to remove, from Brent Hansen's setup it seems he wants to remove empty 'LOGBOOK' drawers, in this case the modify the function bh/remove-empty-drawer-on-clock-out as follows
(defun bh/remove-empty-drawer-on-clock-out ()
(interactive)
(save-excursion
(beginning-of-line 0)
(org-remove-empty-drawer-at "LOGBOOK" (point))))
Note that the argument "LOGBOOK" has been added to the call to function org-remove-empty-drawer-at. Also now you do not need to remove the line
(add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
from your init file.
Faced this issue after updating to Org-mode version 8.3.3 (8.3.3-51-g30bcff-elpa). Before the update, it was already working on my Emacs 24.4 (Linux OS, built from sources), thanks to the answer from user2053036.
Looks like the extra parameter is no longer needed in this version. My working init file now looks like:
(defun bh/remove-empty-drawer-on-clock-out ()
(interactive)
(save-excursion
(beginning-of-line 0)
(org-remove-empty-drawer-at (point))))
(add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
I have a capture template set up to file journal entries in an org file.
(setq org-capture-templates
'(("j" "Journal" entry (file+datetree "/home/emil/org/journal_.org")
(file "/home/emil/org/journal-template.org") :prepend :clock-in))
I want to clock out and output the time elapsed on the clock started with :clock-in when the capture is filed, but I don't know how to do this. Can anyone give me some ideas?
I think you got the template slightly wrong.
Here's how I have it:
(setq org-capture-templates
`(("t" "todo" entry
(file+headline (concat org.d "gtd.org") "Tasks")
"* TODO %^{Brief Description} %^g \nAdded: %U %i\n %?\n"
:clock-in t :clock-resume t)))
So that's :clock-in t, not just plain :clock-in.
With these lines in my init.el I am able to sync the Emacs LaTeX buffer with Sumatra:
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-view-program-list
'(("Sumatra PDF" ("\"C:/bin86/SumatraPDF/SumatraPDF.exe\" -reuse-instance"
(mode-io-correlate " -forward-search %b %n ") " %o"))))
(setq TeX-view-program-selection
'(((output-dvi style-pstricks) "dvips and start") (output-dvi "Yap")
(output-pdf "Sumatra PDF") (output-html "start")))
To set a double click on the PDF to get me to the related LaTeX code, I also set in Sumatra options Set inverse search command line to:
"c:\bin86\GNU Emacs 24.2\bin\emacsclient.exe" --no-wait +%l "%f"
Despite the sync works, I’d like to code it differently.
If I didn’t set the last expression, (setq TeX-view-program-selection..., I would get the default values, which are the same as above, apart from the value for the PDF output that would be: (output-pdf "start").
I’d like to change this one to "Sumatra PDF" and leave the other values to their default, that is, I’d like to ask Emacs the default values for the viewers and change only the PDF value.
It is mostly an ELisp question concerning the manipulation of the variable TeX-view-program-selection.
Thanks for helping.
P.S. Please tell me if this question is best fit on tex.stackexchange
Update based on lunaryorn comments/answer
To update TeX-view-program-selection I could use:
(assq-delete-all 'output-pdf TeX-view-program-selection)
(add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF"))
The first line is optional, but it makes the list look "cleaner".
In both cases (with or without assq-delete-all) I now need to insert the code in the proper hook, since TeX-view-program-selection is void in init.el.
My credits to lunaryorn for suggestions! I am repackaging the steps involved to the benefits of the others.
Emacs side
Add to your init.el:
(setq TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-view-program-list
'(("Sumatra PDF" ("\"path/to/SumatraPDF/SumatraPDF.exe\" -reuse-instance"
(mode-io-correlate " -forward-search %b %n ") " %o"))))
(eval-after-load 'tex
'(progn
(assq-delete-all 'output-pdf TeX-view-program-selection)
(add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF"))))
Sumatra side
In Settings->Options dialog set Set inverse search command line to:
"path\to\GNU Emacs ver\bin\emacsclient.exe" --no-wait +%l "%f"
How to use
In your LaTeX document in Emacs type C-c C-v or double click the related PDF in Sumatra and ... enjoy))
Use add-to-list instead of setq. See C-h f add-to-list for more information.
TeX-view-program-selection is defined in tex.el, so you'll need to execute this code after this library is loaded:
(eval-after-load 'tex
'(progn
(assq-delete-all 'output-pdf TeX-view-program-selection)
(add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF"))))
I was driven nearly mad by the quoting conventions for windows ->emacs
If you install SumatraPDF in the default place, then this works on windows 8.1
(setq TeX-view-program-list
'(("Sumatra PDF" ("\"C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe\" -reuse-instance"
(mode-io-correlate " -forward-search %b %n ") " %o")))))
That's an hour or so I'll never get back :)
I have prepared a batch file, Emacs_SumatraPDF.bat.
It works perfect with sumatra-forward.el to realize forward and backward search.
For example:
Download
http://www.ai.soc.i.kyoto-u.ac.jp/~shi/files/Emacs_SumatraPDF.bat
http:/william.famille-blum.org/software/sumatra/sumatra-forward.el
Prepare
put Emacs_SumatraPDF.bat and SumatraPDF.exe -->
%Emacs_Home%/bin.
put sumatra-forward.el --> %Emacs_Home%/site-lisp
Usage
;Emacs_Home=C:/Program Files (x86)/GNU Emacs 23.4
;~\.emacs add following information
;;; Emacs_SumatraPDF.bat
;; #info: pdf viewer
; #refer:
(setq TeX-view-program-list '(
("Sumatra" "C:/Program Files (x86)/GNU Emacs 23.4/bin/Emacs_SumatraPDF.bat
%o %t %n") ))
(setq TeX-view-program-selection '(
(output-pdf "Sumatra")
(output-dvi "Yap")
((output-dvi style-pstricks) "dvips and start")
(output-html "start")))
;;; sumatra-forward.el
;; #info: forward search.
; #refer: http:/william.famille-blum.org/blog/static.php?page=static081010-000413
(require 'sumatra-forward)
That is all.
Besides
Emacs 4 Latex Support under Windows 7 for newcomer for Emacs.
http://chunqishi.github.io/emacs4ls/
It's worth mentioning that Set inverse search command line is invisible in the Settings->Options dialog by default. To show this option field, go to Settings->Advanced options or open SumatraPDF-settings.txt and turn on EnableTeXEnhancements = true.
For Emacs, how do I store what view-lossage collects into an external file? Ideally I'd like to store these keystroke data into an external log file incrementally and automatically, meaning it is done so by default when Emacs is started.
In Emacs 24 at least (I can't check a prior version right now), the docstring for view-lossage states:
Display last 300 input keystrokes.
To record all your input on a file, use `open-dribble-file'.
And C-hf open-dribble-file RET tells me:
open-dribble-file is an interactive built-in function in `C source
code'.
(open-dribble-file FILE)
Start writing all keyboard characters to a dribble file called FILE.
If FILE is nil, close any open dribble file.
The file will be closed when Emacs exits.
So simply add something like the following to your .emacs file:
(open-dribble-file (expand-file-name "~/.emacs.d/lossage.txt"))
Experimentally this clobbers the file if it already exists, so you'll need to deal with that.
Here's one approach. It accounts for multiple Emacs sessions by using make-temp-name to generate a semi-random filename for the dribble file, and then appends the contents of that to a primary lossage log file when Emacs exists. (If Emacs crashes, it would leave behind the temp file for you to deal with manually.)
(defmacro my-persistent-dribble-file (file)
"Append the dribble-file for this session to persistent lossage log FILE."
`(let* ((persistent-file (expand-file-name ,file))
(temporary-file (make-temp-name (concat persistent-file "-")))
(persistent-arg (shell-quote-argument persistent-file))
(temporary-arg (shell-quote-argument temporary-file))
(append-dribble-command (format
"cat %s >>%s && rm %s"
temporary-arg persistent-arg temporary-arg)))
(open-dribble-file temporary-file)
(eval `(add-hook 'kill-emacs-hook
(lambda () (shell-command ,append-dribble-command))))))
(my-persistent-dribble-file "~/.emacs.d/lossage")