From 0dec8ac61707fdc244457ea07f4c1f6ca755f4ca Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 5 Jul 2010 23:18:34 +0200 Subject: [PATCH 01/27] Revert "Fix agenda display for late scheduled and deadline tasks" This reverts commit 516640aff96b627d8ad412f6cdb436535600aff0. --- lisp/org.el | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 99dbdc14b..500a8c8e3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14813,17 +14813,16 @@ If there is a specifyer for a cyclic time stamp, get the closest date to DAYNR. PREFER and SHOW-ALL are passed through to `org-closest-date'. the variable date is bound by the calendar when this is called." - (let ((today (calendar-absolute-from-gregorian (calendar-current-date)))) - (cond - ((and daynr (string-match "\\`%%\\((.*)\\)" s)) - (if (org-diary-sexp-entry (match-string 1 s) "" date) - daynr - (+ daynr 1000))) - ((and daynr (not (eq daynr today)) (string-match "\\+[0-9]+[dwmy]" s)) - (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr - (time-to-days (current-time))) (match-string 0 s) - prefer show-all)) - (t (time-to-days (apply 'encode-time (org-parse-time-string s))))))) + (cond + ((and daynr (string-match "\\`%%\\((.*)\\)" s)) + (if (org-diary-sexp-entry (match-string 1 s) "" date) + daynr + (+ daynr 1000))) + ((and daynr (string-match "\\+[0-9]+[dwmy]" s)) + (org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr + (time-to-days (current-time))) (match-string 0 s) + prefer show-all)) + (t (time-to-days (apply 'encode-time (org-parse-time-string s)))))) (defun org-days-to-iso-week (days) "Return the iso week number." From e4cfd468a0c64bb1d74fec919df7260053f91b9d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 5 Jul 2010 15:45:34 -0700 Subject: [PATCH 02/27] babel: :eval header argument takes arguments "never" and "query" to limit evaluation * lisp/ob.el (org-babel-confirm-evaluate): adding a new :eval header argument which can be used to control evaluation * doc/org.texi (eval): adding documentation for the new :eval header argument --- doc/org.texi | 25 ++++++++++++++++++++----- lisp/ob.el | 22 ++++++++++++++-------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index f71979a18..0c002ab88 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -11411,13 +11411,17 @@ The following header arguments are defined: @menu * var:: Pass arguments to code blocks -* results:: Specify the type of results and how they will be collectd and handled +* results:: Specify the type of results and how they will + be collectd and handled * file:: Specify a path for file output -* dir and remote execution:: Specify the default directory for code block execution +* dir and remote execution:: Specify the default directory for code block + execution * exports:: Export code and/or results * tangle:: Toggle tangling and specify file name -* no-expand:: Turn off variable assignment and noweb expansion during tangling -* comments:: Toggle insertion of comments in tangled code files +* no-expand:: Turn off variable assignment and noweb + expansion during tangling +* comments:: Toggle insertion of comments in tangled + code files * session:: Preserve the state of code evaluation * noweb:: Toggle expansion of noweb references * cache:: Avoid re-evaluating unchanged code blocks @@ -11425,6 +11429,7 @@ The following header arguments are defined: * colnames:: Handle column names in tables * rownames:: Handle row names in tables * shebang:: Make tangled files executable +* eval:: Limit evaluation of specific code blocks @end menu @node var, results, Specific header arguments, Specific header arguments @@ -12003,7 +12008,7 @@ and is then reapplied to the results. @end example @end itemize -@node shebang, , rownames, Specific header arguments +@node shebang, eval, rownames, Specific header arguments @subsubsection @code{:shebang} Setting the @code{:shebang} header argument to a string value @@ -12011,6 +12016,16 @@ Setting the @code{:shebang} header argument to a string value first line of any tangled file holding the code block, and the file permissions of the tangled file are set to make it executable. +@node eval, , shebang, Specific header arguments +@subsubsection @code{:eval} +The @code{:eval} header argument can be used to limit the evaluation of +specific code blocks. @code{:eval} accepts two arguments ``never'' and +``query''. @code{:eval never} will ensure that a code block is never +evaluated, this can be useful for protecting against the evaluation of +dangerous code blocks. @code{:eval query} will require a query for every +execution of a code block regardless of the value of the +@code{org-confirm-babel-evaluate} variable. + @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code @section Results of evaluation @cindex code block, results of evaluation diff --git a/lisp/ob.el b/lisp/ob.el index 11a9fd8cf..0b33d97d4 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -171,14 +171,20 @@ any confirmation from the user. Note disabling confirmation may result in accidental evaluation of potentially harmful code." - (unless (or (not (if (functionp org-confirm-babel-evaluate) - (funcall org-confirm-babel-evaluate - (nth 0 info) (nth 1 info)) - org-confirm-babel-evaluate)) - (yes-or-no-p - (format "Evaluate this%scode on your system?" - (if info (format " %s " (nth 0 info)) " ")))) - (error "evaluation aborted"))) + (let ((eval (cdr (assoc :eval (nth 2 info))))) + (when (or (equal eval "never") + (and (equal eval "query") + (not (yes-or-no-p + (format "Evaluate this%scode on your system?" + (if info (format " %s " (nth 0 info)) " "))))) + (and (or (and (functionp org-confirm-babel-evaluate) + (funcall org-confirm-babel-evaluate + (nth 0 info) (nth 1 info))) + org-confirm-babel-evaluate) + (not (yes-or-no-p + (format "Evaluate this%scode on your system?" + (if info (format " %s " (nth 0 info)) " ")))))) + (error "evaluation aborted")))) ;;;###autoload (defun org-babel-execute-src-block-maybe () From 07b8908903287b515ba799b16f2444eb6d7dd0f7 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 5 Jul 2010 18:43:55 -0700 Subject: [PATCH 03/27] ob-mscgen: support for mscgen code blocks by Juan Pechiar from the comments of the new file This software provides EMACS org-babel export support for message sequence charts. The mscgen utility is used for processing the sequence definition, and must therefore be installed in the system. Mscgen is available and documented at http://www.mcternan.me.uk/mscgen/index.html This code is directly inspired by Eric Schulte's ob-dot.el Example: msc { A,B; A -> B [ label = "send message" ]; A <- B [ label = "get answer" ]; } Header for alternative file type: This differs from most standard languages in that 1) there is no such thing as a "session" in mscgen 2) we are generally only going to return results of type "file" 3) we are adding the "file" and "filetype" header arguments 4) there are no variables --- Makefile | 1 + doc/org.texi | 15 ++++---- lisp/ob-mscgen.el | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 lisp/ob-mscgen.el diff --git a/Makefile b/Makefile index 641dbc353..f4cd9b590 100644 --- a/Makefile +++ b/Makefile @@ -131,6 +131,7 @@ LISPF = org.el \ ob-sh.el \ ob-R.el \ ob-dot.el \ + ob-mscgen.el \ ob-latex.el \ ob-python.el \ ob-sql.el \ diff --git a/doc/org.texi b/doc/org.texi index 0c002ab88..792c93ad7 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -11211,13 +11211,14 @@ Code blocks in the following languages are supported. @item css @tab css @tab ditaa @tab ditaa @item Graphviz @tab dot @tab Emacs Lisp @tab emacs-lisp @item gnuplot @tab gnuplot @tab Haskell @tab haskell -@item Matlab @tab matlab @tab LaTeX @tab latex -@item Objective Caml @tab ocaml @tab Octave @tab octave -@item OZ @tab oz @tab Perl @tab perl -@item Python @tab python @tab R @tab R -@item Ruby @tab ruby @tab Sass @tab sass -@item GNU Screen @tab screen @tab shell @tab sh -@item SQL @tab sql @tab Sqlite @tab sqlite +@item LaTeX @tab latex @tab Matlab @tab matlab +@item Mscgen @tab mscgen @tab Objective Caml @tab ocaml +@item Octave @tab octave @tab OZ @tab oz +@item Perl @tab perl @tab Python @tab python +@item R @tab R @tab Ruby @tab ruby +@item Sass @tab sass @tab GNU Screen @tab screen +@item shell @tab sh @tab SQL @tab sql +@item Sqlite @tab sqlite @end multitable Language specific documentation is available for some languages. If diff --git a/lisp/ob-mscgen.el b/lisp/ob-mscgen.el new file mode 100644 index 000000000..256448b08 --- /dev/null +++ b/lisp/ob-mscgen.el @@ -0,0 +1,93 @@ +;;; ob-msc.el --- org-babel functions for mscgen evaluation + +;; Copyright (C) 2010 Free Software Foundation, Inc. + +;; Author: Juan Pechiar +;; Keywords: literate programming, reproducible research +;; Homepage: http://orgmode.org +;; Version: 0.01 + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: +;; +;; This software provides EMACS org-babel export support for message +;; sequence charts. The mscgen utility is used for processing the +;; sequence definition, and must therefore be installed in the system. +;; +;; Mscgen is available and documented at http://www.mcternan.me.uk/mscgen/index.html +;; +;; This code is directly inspired by Eric Schulte's ob-dot.el +;; +;; Example: +;; +;; #+begin_src mscgen :file example.png +;; msc { +;; A,B; +;; A -> B [ label = "send message" ]; +;; A <- B [ label = "get answer" ]; +;; } +;; #+end_src +;; +;; Header for alternative file type: +;; +;; #+begin_src mscgen :file ex2.svg :filetype svg + +;; This differs from most standard languages in that +;; +;; 1) there is no such thing as a "session" in mscgen +;; 2) we are generally only going to return results of type "file" +;; 3) we are adding the "file" and "filetype" header arguments +;; 4) there are no variables + +;;; Code: +(require 'ob) + +(defvar org-babel-default-header-args:mscgen + '((:results . "file") (:exports . "results")) + "Default arguments to use when evaluating a mscgen source block.") + +(defun org-babel-expand-body:mscgen (body params &optional processed-params) + "Expand BODY according to PARAMS, return the expanded body." body) + +(defun org-babel-execute:mscgen (body params) + "Execute a block of Mscgen code with org-babel. This function is +called by `org-babel-execute-src-block'. +Default filetype is png. Modify by setting :filetype parameter to mscgen supported formats." + (message "executing Mscgen source code block") + (let* ((out-file (or (cdr (assoc :file params)) "output.png" )) + exit-code + (filetype (or (cdr (assoc :filetype params)) "png" )) + (stderr + (with-temp-buffer + (insert body) + (setq exit-code (org-babel-shell-command-on-region + (point-min) (point-max) (concat "mscgen -T " filetype " -o " out-file) + nil 'replace (current-buffer))) + (buffer-string)))) + (unless (cdr (assoc :file params)) (setq stderr (concat stderr "\nERROR: no output file specified. Add \":file some_name.png\" to the src header" )) (error stderr)) + (if (> exit-code 0) (org-babel-error-notify exit-code stderr)) + out-file)) + +(defun org-babel-prep-session:mscgen (session params) + "Prepare SESSION according to PARAMS." + (error "Mscgen does not support sessions")) + +(provide 'ob-mscgen) + +;; arch-tag: 74695b1e-715f-4b5a-a3a9-d78ee39ba5c8 + +;;; ob-msc.el ends here From 2538e687dae7dacab6d17f9fce4db7d16474fbaf Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 5 Jul 2010 19:03:25 -0700 Subject: [PATCH 04/27] babel: updating ob-dot.el and ob-mscgen.el to use ob-eval --- lisp/ob-dot.el | 7 ++++--- lisp/ob-mscgen.el | 28 +++++++++++++--------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lisp/ob-dot.el b/lisp/ob-dot.el index e22defd8e..a42f451c9 100644 --- a/lisp/ob-dot.el +++ b/lisp/ob-dot.el @@ -40,8 +40,10 @@ ;;; Code: (require 'ob) +(require 'ob-eval) -(defvar org-babel-default-header-args:dot '((:results . "file") (:exports . "results")) +(defvar org-babel-default-header-args:dot + '((:results . "file") (:exports . "results")) "Default arguments to use when evaluating a dot source block.") (defun org-babel-expand-body:dot (body params &optional processed-params) @@ -57,8 +59,7 @@ called by `org-babel-execute-src-block'." (cmd (or (cdr (assoc :cmd params)) "dot")) (in-file (make-temp-file "org-babel-dot"))) (with-temp-file in-file (insert body)) - (message (concat cmd " " in-file " " cmdline " -o " out-file)) - (shell-command (concat cmd " " in-file " " cmdline " -o " out-file)) + (org-babel-eval (concat cmd " " in-file " " cmdline " -o " out-file) "") out-file)) (defun org-babel-prep-session:dot (session params) diff --git a/lisp/ob-mscgen.el b/lisp/ob-mscgen.el index 256448b08..5c9f3e595 100644 --- a/lisp/ob-mscgen.el +++ b/lisp/ob-mscgen.el @@ -28,7 +28,8 @@ ;; sequence charts. The mscgen utility is used for processing the ;; sequence definition, and must therefore be installed in the system. ;; -;; Mscgen is available and documented at http://www.mcternan.me.uk/mscgen/index.html +;; Mscgen is available and documented at +;; http://www.mcternan.me.uk/mscgen/index.html ;; ;; This code is directly inspired by Eric Schulte's ob-dot.el ;; @@ -55,6 +56,7 @@ ;;; Code: (require 'ob) +(require 'ob-eval) (defvar org-babel-default-header-args:mscgen '((:results . "file") (:exports . "results")) @@ -64,22 +66,18 @@ "Expand BODY according to PARAMS, return the expanded body." body) (defun org-babel-execute:mscgen (body params) - "Execute a block of Mscgen code with org-babel. This function is -called by `org-babel-execute-src-block'. -Default filetype is png. Modify by setting :filetype parameter to mscgen supported formats." + "Execute a block of Mscgen code with org-babel. This function +is called by `org-babel-execute-src-block'. Default filetype is +png. Modify by setting :filetype parameter to mscgen supported +formats." (message "executing Mscgen source code block") (let* ((out-file (or (cdr (assoc :file params)) "output.png" )) - exit-code - (filetype (or (cdr (assoc :filetype params)) "png" )) - (stderr - (with-temp-buffer - (insert body) - (setq exit-code (org-babel-shell-command-on-region - (point-min) (point-max) (concat "mscgen -T " filetype " -o " out-file) - nil 'replace (current-buffer))) - (buffer-string)))) - (unless (cdr (assoc :file params)) (setq stderr (concat stderr "\nERROR: no output file specified. Add \":file some_name.png\" to the src header" )) (error stderr)) - (if (> exit-code 0) (org-babel-error-notify exit-code stderr)) + (filetype (or (cdr (assoc :filetype params)) "png" ))) + (unless (cdr (assoc :file params)) + (error (concat + "\nERROR: no output file specified. " + "Add \":file some_name.png\" to the src header"))) + (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body) out-file)) (defun org-babel-prep-session:mscgen (session params) From ae44ae853dba83522cfb9c3be6473acec6b453b3 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 5 Jul 2010 19:08:50 -0700 Subject: [PATCH 05/27] babel: adding ob-mscgen to org-babel-load-languages * lisp/org.el (org-babel-load-languages): adding ob-mscgen --- lisp/org.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/org.el b/lisp/org.el index 500a8c8e3..d5b62953d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -164,6 +164,7 @@ default only Emacs Lisp (which has no requirements) is loaded." (const :tag "Haskell" haskell) (const :tag "Latex" latex) (const :tag "Matlab" matlab) + (const :tag "Mscgen" mscgen) (const :tag "Ocaml" ocaml) (const :tag "Octave" octave) (const :tag "Perl" perl) From c87b6a90b087af384f91dff7ad136702a0ec97f3 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 5 Jul 2010 20:17:26 -0700 Subject: [PATCH 06/27] ob-latex: shouldn't require org-latex as that results in a recursive require Thanks to Juan Pechiar for pointing this out * lisp/ob-latex.el (org-latex): don't require org-latex as that results in a recursive require loop --- lisp/ob-latex.el | 1 - 1 file changed, 1 deletion(-) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index 6b817ae01..4d7c0d0bd 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -32,7 +32,6 @@ ;;; Code: (require 'ob) -(require 'org-latex) (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex")) From 44d56dfa2d2884d858c888e325d976a0ecedadf7 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 07:39:57 +0200 Subject: [PATCH 07/27] Autoload more org-table-functions * lisp/org.el (org-autoload): Autoload a few more org-table functions. --- lisp/org.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index d5b62953d..d207e5dff 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3572,7 +3572,9 @@ outside the table.") org-table-rotate-recalc-marks org-table-sort-lines org-table-sum org-table-toggle-coordinate-overlays org-table-toggle-formula-debugger org-table-wrap-region - orgtbl-mode turn-on-orgtbl org-table-to-lisp))) + orgtbl-mode turn-on-orgtbl org-table-to-lisp + orgtbl-to-generic orgtbl-to-tsv orgtbl-to-csv orgtbl-to-latex + orgtbl-to-orgtbl orgtbl-to-html orgtbl-to-texinfo))) (defun org-at-table-p (&optional table-type) "Return t if the cursor is inside an org-type table. From f3d72b13f41523fb2f4ca5aaa1dd7f1559f0a0ff Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 08:25:48 +0200 Subject: [PATCH 08/27] Implement comment standards in org-ctags.el --- lisp/org-ctags.el | 228 +++++++++++++++++++++++----------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/lisp/org-ctags.el b/lisp/org-ctags.el index d4735c9d3..35f432f33 100644 --- a/lisp/org-ctags.el +++ b/lisp/org-ctags.el @@ -1,9 +1,9 @@ ;;; org-ctags.el - Integrate Emacs "tags" facility with org mode. -;;; +;; ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -;;; Author: Paul Sexton -;;; Version: 1.0 +;; Author: Paul Sexton +;; Version: 1.0 ;; Keywords: org, wp ;; Version: 6.36trans @@ -23,116 +23,116 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . -;;; -;;; Synopsis -;;; ======== -;;; -;;; Allows org-mode to make use of the Emacs `etags' system. Defines tag -;;; destinations in org-mode files as any text between <>. This allows the tags-generation program `exuberant ctags' to -;;; parse these files and create tag tables that record where these -;;; destinations are found. Plain [[links]] in org mode files which do not have -;;; <> within the same file will then be interpreted as -;;; links to these 'tagged' destinations, allowing seamless navigation between -;;; multiple org-mode files. Topics can be created in any org mode file and -;;; will always be found by plain links from other files. Other file types -;;; recognised by ctags (source code files, latex files, etc) will also be -;;; available as destinations for plain links, and similarly, org-mode links -;;; will be available as tags from source files. Finally, the function -;;; `org-ctags-find-tag-interactive' lets you choose any known tag, using -;;; autocompletion, and quickly jump to it. -;;; -;;; Installation -;;; ============ -;;; -;;; Install org mode -;;; Ensure org-ctags.el is somewhere in your emacs load path. -;;; Download and install Exuberant ctags -- "http://ctags.sourceforge.net/" -;;; Edit your .emacs file (see next section) and load emacs. +;; +;; Synopsis +;; ======== +;; +;; Allows org-mode to make use of the Emacs `etags' system. Defines tag +;; destinations in org-mode files as any text between <>. This allows the tags-generation program `exuberant ctags' to +;; parse these files and create tag tables that record where these +;; destinations are found. Plain [[links]] in org mode files which do not have +;; <> within the same file will then be interpreted as +;; links to these 'tagged' destinations, allowing seamless navigation between +;; multiple org-mode files. Topics can be created in any org mode file and +;; will always be found by plain links from other files. Other file types +;; recognised by ctags (source code files, latex files, etc) will also be +;; available as destinations for plain links, and similarly, org-mode links +;; will be available as tags from source files. Finally, the function +;; `org-ctags-find-tag-interactive' lets you choose any known tag, using +;; autocompletion, and quickly jump to it. +;; +;; Installation +;; ============ +;; +;; Install org mode +;; Ensure org-ctags.el is somewhere in your emacs load path. +;; Download and install Exuberant ctags -- "http://ctags.sourceforge.net/" +;; Edit your .emacs file (see next section) and load emacs. -;;; To put in your init file (.emacs): -;;; ================================== -;;; -;;; Assuming you already have org mode installed and set up: -;;; -;;; (setq org-ctags-path-to-ctags "/path/to/ctags/executable") -;;; (add-hook 'org-mode-hook -;;; (lambda () -;;; (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive))) -;;; -;;; By default, with org-ctags loaded, org will first try and visit the tag -;;; with the same name as the link; then, if unsuccessful, ask the user if -;;; he/she wants to rebuild the 'TAGS' database and try again; then ask if -;;; the user wishes to append 'tag' as a new toplevel heading at the end of -;;; the buffer; and finally, defer to org's default behaviour which is to -;;; search the entire text of the current buffer for 'tag'. -;;; -;;; This behaviour can be modified by changing the value of -;;; ORG-CTAGS-OPEN-LINK-FUNCTIONS. For example I have the following in my -;;; .emacs, which describes the same behaviour as the above paragraph with -;;; one difference: -;;; -;;; (setq org-ctags-open-link-functions -;;; '(org-ctags-find-tag -;;; org-ctags-ask-rebuild-tags-file-then-find-tag -;;; org-ctags-ask-append-topic -;;; org-ctags-fail-silently)) ; <-- prevents org default behaviour -;;; -;;; -;;; Usage -;;; ===== -;;; -;;; When you click on a link "[[foo]]" and org cannot find a matching "<>" -;;; in the current buffer, the tags facility will take over. The file TAGS in -;;; the active directory is examined to see if the tags facility knows about -;;; "<>" in any other files. If it does, the matching file will be opened -;;; and the cursor will jump to the position of "<>" in that file. -;;; -;;; User-visible functions: -;;; - `org-ctags-find-tag-interactive': type a tag (plain link) name and visit -;;; it. With autocompletion. Bound to ctrl-O in the above setup. -;;; - All the etags functions should work. These include: -;;; -;;; M-. `find-tag' -- finds the tag at point -;;; -;;; C-M-. find-tag based on regular expression -;;; -;;; M-x tags-search RET -- like C-M-. but searches through ENTIRE TEXT -;;; of ALL the files referenced in the TAGS file. A quick way to -;;; search through an entire 'project'. -;;; -;;; M-* "go back" from a tag jump. Like `org-mark-ring-goto'. -;;; You may need to bind this key yourself with (eg) -;;; (global-set-key (kbd "") 'pop-tag-mark) -;;; -;;; (see etags chapter in Emacs manual for more) -;;; -;;; -;;; Keeping the TAGS file up to date -;;; ================================ -;;; -;;; Tags mode has no way of knowing that you have created new tags by typing in -;;; your org-mode buffer. New tags make it into the TAGS file in 3 ways: -;;; -;;; 1. You re-run (org-ctags-create-tags "directory") to rebuild the file. -;;; 2. You put the function `org-ctags-ask-rebuild-tags-file-then-find-tag' in -;;; your `org-open-link-functions' list, as is done in the setup -;;; above. This will cause the TAGS file to be rebuilt whenever a link -;;; cannot be found. This may be slow with large file collections however. -;;; 3. You run the following from the command line (all 1 line): -;;; -;;; ctags --langdef=orgmode --langmap=orgmode:.org -;;; --regex-orgmode="/<<([^>]+)>>/\1/d,definition/" -;;; -f /your/path/TAGS -e -R /your/path/*.org -;;; -;;; If you are paranoid, you might want to run (org-ctags-create-tags -;;; "/path/to/org/files") at startup, by including the following toplevel form -;;; in .emacs. However this can cause a pause of several seconds if ctags has -;;; to scan lots of files. -;;; -;;; (progn -;;; (message "-- rebuilding tags tables...") -;;; (mapc 'org-create-tags tags-table-list)) +;; To put in your init file (.emacs): +;; ================================== +;; +;; Assuming you already have org mode installed and set up: +;; +;; (setq org-ctags-path-to-ctags "/path/to/ctags/executable") +;; (add-hook 'org-mode-hook +;; (lambda () +;; (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive))) +;; +;; By default, with org-ctags loaded, org will first try and visit the tag +;; with the same name as the link; then, if unsuccessful, ask the user if +;; he/she wants to rebuild the 'TAGS' database and try again; then ask if +;; the user wishes to append 'tag' as a new toplevel heading at the end of +;; the buffer; and finally, defer to org's default behaviour which is to +;; search the entire text of the current buffer for 'tag'. +;; +;; This behaviour can be modified by changing the value of +;; ORG-CTAGS-OPEN-LINK-FUNCTIONS. For example I have the following in my +;; .emacs, which describes the same behaviour as the above paragraph with +;; one difference: +;; +;; (setq org-ctags-open-link-functions +;; '(org-ctags-find-tag +;; org-ctags-ask-rebuild-tags-file-then-find-tag +;; org-ctags-ask-append-topic +;; org-ctags-fail-silently)) ; <-- prevents org default behaviour +;; +;; +;; Usage +;; ===== +;; +;; When you click on a link "[[foo]]" and org cannot find a matching "<>" +;; in the current buffer, the tags facility will take over. The file TAGS in +;; the active directory is examined to see if the tags facility knows about +;; "<>" in any other files. If it does, the matching file will be opened +;; and the cursor will jump to the position of "<>" in that file. +;; +;; User-visible functions: +;; - `org-ctags-find-tag-interactive': type a tag (plain link) name and visit +;; it. With autocompletion. Bound to ctrl-O in the above setup. +;; - All the etags functions should work. These include: +;; +;; M-. `find-tag' -- finds the tag at point +;; +;; C-M-. find-tag based on regular expression +;; +;; M-x tags-search RET -- like C-M-. but searches through ENTIRE TEXT +;; of ALL the files referenced in the TAGS file. A quick way to +;; search through an entire 'project'. +;; +;; M-* "go back" from a tag jump. Like `org-mark-ring-goto'. +;; You may need to bind this key yourself with (eg) +;; (global-set-key (kbd "") 'pop-tag-mark) +;; +;; (see etags chapter in Emacs manual for more) +;; +;; +;; Keeping the TAGS file up to date +;; ================================ +;; +;; Tags mode has no way of knowing that you have created new tags by typing in +;; your org-mode buffer. New tags make it into the TAGS file in 3 ways: +;; +;; 1. You re-run (org-ctags-create-tags "directory") to rebuild the file. +;; 2. You put the function `org-ctags-ask-rebuild-tags-file-then-find-tag' in +;; your `org-open-link-functions' list, as is done in the setup +;; above. This will cause the TAGS file to be rebuilt whenever a link +;; cannot be found. This may be slow with large file collections however. +;; 3. You run the following from the command line (all 1 line): +;; +;; ctags --langdef=orgmode --langmap=orgmode:.org +;; --regex-orgmode="/<<([^>]+)>>/\1/d,definition/" +;; -f /your/path/TAGS -e -R /your/path/*.org +;; +;; If you are paranoid, you might want to run (org-ctags-create-tags +;; "/path/to/org/files") at startup, by including the following toplevel form +;; in .emacs. However this can cause a pause of several seconds if ctags has +;; to scan lots of files. +;; +;; (progn +;; (message "-- rebuilding tags tables...") +;; (mapc 'org-create-tags tags-table-list)) (eval-when-compile (require 'cl)) (require 'org) @@ -219,7 +219,7 @@ The following patterns are replaced in the string: ;;; General utility functions. =============================================== -;;; These work outside org-ctags mode. +;; These work outside org-ctags mode. (defun org-ctags-get-filename-for-tag (tag) "TAG is a string. Search the active TAGS file for a matching tag, @@ -535,5 +535,5 @@ a new topic." (provide 'org-ctags) -;;; arch-tag: 4b1ddd5a-8529-4b17-bcde-96a922d26343 +;; arch-tag: 4b1ddd5a-8529-4b17-bcde-96a922d26343 ;;; org-ctags.el ends here From 04e21124c3f1d9665d9ddc33f38d34ceabf93483 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 08:25:59 +0200 Subject: [PATCH 09/27] Fix typo --- doc/org.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/org.texi b/doc/org.texi index 792c93ad7..25406c0e8 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -3060,7 +3060,7 @@ link and description parts of the link. Open link at point. This will launch a web browser for URLs (using @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for the corresponding links, and execute the command in a shell link. When the -cursor is on an internal link, this commands runs the corresponding search. +cursor is on an internal link, this command runs the corresponding search. When the cursor is on a TAG list in a headline, it creates the corresponding TAGS view. If the cursor is on a timestamp, it compiles the agenda for that date. Furthermore, it will visit text and remote files in @samp{file:} links From 6d889cc363c9fd8bb23b973ddd05505892b7faeb Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 08:51:23 +0200 Subject: [PATCH 10/27] Escape parenthesis at bol in docstring --- lisp/ob-exp.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 59ad4af72..301f33da8 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -54,7 +54,7 @@ line. A source block is considered to be a source block function if the source name is present and is followed by a parenthesized argument list. The parentheses may be empty or contain whitespace. An example is the following which generates n random -(uniform) numbers. +\(uniform) numbers. #+source: rand(n) #+begin_src R From 4273e50ab703ea673e51ce57b7928731bd1765d3 Mon Sep 17 00:00:00 2001 From: David Maus Date: Tue, 6 Jul 2010 00:28:34 +0000 Subject: [PATCH 11/27] Don't create marker if target is entire file. * org-agenda.el (org-agenda-bulk-action): Don't create marker for position if target is entire file. If the target of a bulk refile operation is the entire file, `org-refile-get-location' returns nil for the refile position. Creating a marker for the target file's buffer at position nil returns a marker that points nowhere (Cf. GNU Emacs Lisp Reference Manual, 31.6). `org-refile' adds headings to level 1 if the target position for the target file is nil -- and hence a marker that points nowhere is not nil, tries to jump to nowhere. --- lisp/org-agenda.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 4345f061f..1fe463931 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -7489,11 +7489,12 @@ The prefix arg is passed through to the command if possible." "Refile to: " (marker-buffer (car org-agenda-bulk-marked-entries)) org-refile-allow-creating-parent-nodes)) - (setcar (nthcdr 3 rfloc) - (move-marker (make-marker) (nth 3 rfloc) - (or (get-file-buffer (nth 1 rfloc)) - (find-buffer-visiting (nth 1 rfloc)) - (error "This should not happen")))) + (if (nth 3 rfloc) + (setcar (nthcdr 3 rfloc) + (move-marker (make-marker) (nth 3 rfloc) + (or (get-file-buffer (nth 1 rfloc)) + (find-buffer-visiting (nth 1 rfloc)) + (error "This should not happen"))))) (setq cmd (list 'org-agenda-refile nil (list 'quote rfloc) t) redo-at-end t)) From 0e30108330372549233aab21388521fa2ed8a9be Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 09:12:50 +0200 Subject: [PATCH 12/27] Fix typo --- lisp/ob-exp.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 301f33da8..420f2236d 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -59,8 +59,7 @@ whitespace. An example is the following which generates n random #+source: rand(n) #+begin_src R runif(n) -#+end_src -") +#+end_src") (defvar org-babel-function-def-export-indent 4 "When exporting a source block function, the block contents From dfd0c7ad2e28b47bc851833a468db154aba75d98 Mon Sep 17 00:00:00 2001 From: David Maus Date: Sun, 4 Jul 2010 19:16:02 +0000 Subject: [PATCH 13/27] Fix typo in docstring. * babel/ob-exp.el (org-babel-exp-inline-src-blocks): Fix typo in docstring. --- lisp/ob-exp.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 420f2236d..7fa673b4b 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -98,7 +98,7 @@ none ----- do not display either code or results upon export" (defun org-babel-exp-inline-src-blocks (start end) "Process inline src blocks between START and END for export. See `org-babel-exp-src-blocks' for export options, currently the -options and are taken from `org-babel-defualt-inline-header-args'." +options and are taken from `org-babel-default-inline-header-args'." (interactive) (save-excursion (goto-char start) From 75192f263eb69737153512a540f0f215d28c5d06 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 09:40:46 +0200 Subject: [PATCH 14/27] Allow capture template to come from a file or from a function call * lisp/org-capture.el (org-capture-templates): Allow the template to come from a file or function call. (org-capture-place-entry): Get the template from file or function. --- lisp/org-capture.el | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index f6e89ef94..b3db087a0 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -145,7 +145,13 @@ target Specification of where the captured item should be placed. template The template for creating the capture item. If you leave this empty, an appropriate default template will be used. See below - for more details. + for more details. Instead of a string, this may also be one of + + (file \"/path/to/template-file\") + (function function-returning-the-template) + + in order to get a template from a file, or dynamically + from a function. The rest of the entry is a property list of additional options. Recognized properties are: @@ -274,7 +280,14 @@ calendar | %:type %:date" (list :tag "Function" (const :format "" function) (sexp :tag " Function"))) - (string :tag "Template (opt) ") + (choice :tag "Template" + (string) + (list :tag "File" + (const :format "" file-contents) + (file :tag "Template file")) + (list :tag "Function" + (const :format "" function) + (file :tag "Template function"))) (plist :inline t ;; Give the most common options as checkboxes :options (((const :format "%v " :prepend) (const t)) @@ -647,6 +660,20 @@ already gone." (reversed (org-capture-get :prepend)) (target-entry-p (org-capture-get :target-entry-p)) level beg end) + + ;; Get the full template + (cond + ((and (listp txt) (eq (car txt) 'file)) + (if (file-exists-p (nth 1 txt)) + (setq txt (org-file-contents (nth 1 txt))) + (setq txt (format "Template file %s not found" (nth 1 txt))))) + ((and (listp txt) (eq (car txt) 'function)) + (if (fboundp (nth 1 txt)) + (setq txt (funcall (nth 1 txt))) + (setq txt (format "Template function %s not found" (nth 1 txt))))) + ((not txt) (setq txt "")) + (t (setq txt "Invalid capture template"))) + (cond ((org-capture-get :exact-position) (goto-char (org-capture-get :exact-position))) From c80d5b9c2763e368481fcedc3ab5cf7bcdbca405 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 09:44:31 +0200 Subject: [PATCH 15/27] Capture: Expand template file name --- lisp/org-capture.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index b3db087a0..c689d6de4 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -659,13 +659,14 @@ already gone." (let* ((txt (org-capture-get :template)) (reversed (org-capture-get :prepend)) (target-entry-p (org-capture-get :target-entry-p)) - level beg end) + level beg end file) ;; Get the full template (cond ((and (listp txt) (eq (car txt) 'file)) - (if (file-exists-p (nth 1 txt)) - (setq txt (org-file-contents (nth 1 txt))) + (if (file-exists-p + (setq file (expand-file-name (nth 1 txt) org-directory))) + (setq txt (org-file-contents file)) (setq txt (format "Template file %s not found" (nth 1 txt))))) ((and (listp txt) (eq (car txt) 'function)) (if (fboundp (nth 1 txt)) From 85c90e96fd7e8164a263824046d975ede148217d Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 10:23:41 +0200 Subject: [PATCH 16/27] Allow org-indent-mode only on Emacsen that do support it * lisp/org-compat.el (org-version-check): New function. * lisp/org-indent.el (org-indent-mode): Check for exact emacs version. --- lisp/org-compat.el | 24 ++++++++++++++++++++++++ lisp/org-indent.el | 7 ++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index bfd4f8eb2..573b9ff71 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -89,6 +89,30 @@ any other entries, and any resulting duplicates will be removed entirely." (t specs))) (put 'org-compatible-face 'lisp-indent-function 1) +(defun org-version-check (version feature level) + (let* ((v1 (mapcar 'string-to-number (split-string version "[.]"))) + (v2 (mapcar 'string-to-number (split-string emacs-version "[.]"))) + (rmaj (or (nth 0 v1) 99)) + (rmin (or (nth 1 v1) 99)) + (rbld (or (nth 2 v1) 99)) + (maj (or (nth 0 v2) 0)) + (min (or (nth 1 v2) 0)) + (bld (or (nth 2 v2) 0))) + (if (or (< maj rmaj) + (and (= maj rmaj) + (< min rmin)) + (and (= maj rmaj) + (= min rmin) + (< bld rbld))) + (if (eq level :predicate) + ;; just return if we have the version + nil + (let ((msg (format "Emacs %s or greater is recommended for %s" + version feature))) + (display-warning 'org msg level) + t)) + t))) + ;;;; Emacs/XEmacs compatibility ;; Keys diff --git a/lisp/org-indent.el b/lisp/org-indent.el index 70618cb93..48b10b74c 100644 --- a/lisp/org-indent.el +++ b/lisp/org-indent.el @@ -130,10 +130,11 @@ FIXME: How to update when broken?" (cond ((org-bound-and-true-p org-inhibit-startup) (setq org-indent-mode nil)) + ((and org-indent-mode (featurep 'xemacs)) + (message "org-indent-mode does not work in XEmacs - refused to turn it on") + (setq org-indent-mode nil)) ((and org-indent-mode - (or (< emacs-major-version 23) - (and (= emacs-major-version 23) - (< emacs-minor-version 2)))) + (not (org-version-check "23.1.50" "Org Indent mode" :predicate))) (message "org-indent-mode is can crash Emacs 23.1 - refused to turn it on!") (ding) (sit-for 1) From e1262e57d28e32afb4685b3b2c996784d866613e Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 10:39:35 +0200 Subject: [PATCH 17/27] LaTeX export: Allow to customize the tabular environment * lisp/org-latex.el (org-export-latex-tabular-environment): New option. (org-export-latex-tables): Use `org-export-latex-tabular-environment'. --- lisp/org-latex.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 10e0628ec..e1e42e0fa 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -415,6 +415,11 @@ and `org-export-with-tags' instead." :group 'org-export-latex :type 'string) +(defcustom org-export-latex-tabular-environment "tabular" + "Default environment used to build tables." + :group 'org-export-latex + :type 'string) + (defcustom org-export-latex-inline-image-extensions '("pdf" "jpeg" "jpg" "png" "ps" "eps") "Extensions of image files that can be inlined into LaTeX. @@ -1660,7 +1665,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (if (and longtblp caption) "\\\\\n" "\n") (if (and org-export-latex-tables-centered (not longtblp)) "\\begin{center}\n") - (if (not longtblp) (concat "\\begin{tabular}{" align "}\n")) + (if (not longtblp) + (format "\\begin{%s}{%s}\n" + org-export-latex-tabular-environment align)) (orgtbl-to-latex lines `(:tstart nil :tend nil @@ -1672,7 +1679,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." \\endfoot \\endlastfoot" (length org-table-last-alignment)) nil))) - (if (not longtblp) (concat "\n\\end{tabular}")) + (if (not longtblp) + (format "\n\\end{%s}" + org-export-latex-tabular-environment)) (if longtblp "\n" (if org-export-latex-tables-centered "\n\\end{center}\n" "\n")) (if longtblp From d044ad3f1c192f53708aeef581e8b616e6bec286 Mon Sep 17 00:00:00 2001 From: David Maus Date: Tue, 6 Jul 2010 13:32:51 +0000 Subject: [PATCH 18/27] Remove text properties of body before calculating cache hash. * org-exp-blocks.el (org-export-blocks-format-ditaa) (org-export-blocks-format-dot): Remove text properties of body before calculating cache hash. Otherwise one and the same ditta/graphviz image has a different hash depending on the text properties of the body. E.g. `org-export-region-as-html' with target buffer 'string passed the body of the block without possible indentation property `wrap-prefix' while `org-export-as-html' does. --- lisp/org-exp-blocks.el | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lisp/org-exp-blocks.el b/lisp/org-exp-blocks.el index 4ff6c5c57..4bf5db6e5 100644 --- a/lisp/org-exp-blocks.el +++ b/lisp/org-exp-blocks.el @@ -227,13 +227,15 @@ passed to the ditaa utility as command line arguments." (message "ditaa-formatting...") (let* ((args (if (cdr headers) (mapconcat 'identity (cdr headers) " "))) (data-file (make-temp-file "org-ditaa")) - (hash (sha1 (prin1-to-string (list body args)))) - (raw-out-file (if headers (car headers))) - (out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file) - (cons (match-string 1 raw-out-file) - (match-string 2 raw-out-file)) - (cons raw-out-file "png"))) - (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts)))) + (hash (progn + (set-text-properties 0 (length body) nil body) + (sha1 (prin1-to-string (list body args))))) + (raw-out-file (if headers (car headers))) + (out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file) + (cons (match-string 1 raw-out-file) + (match-string 2 raw-out-file)) + (cons raw-out-file "png"))) + (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts)))) (unless (file-exists-p org-ditaa-jar-path) (error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path))) (setq body (if (string-match "^\\([^:\\|:[^ ]\\)" body) @@ -287,13 +289,15 @@ digraph data_relationships { (message "dot-formatting...") (let* ((args (if (cdr headers) (mapconcat 'identity (cdr headers) " "))) (data-file (make-temp-file "org-ditaa")) - (hash (sha1 (prin1-to-string (list body args)))) - (raw-out-file (if headers (car headers))) - (out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file) - (cons (match-string 1 raw-out-file) - (match-string 2 raw-out-file)) - (cons raw-out-file "png"))) - (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts)))) + (hash (progn + (set-text-properties 0 (length body) nil body) + (sha1 (prin1-to-string (list body args))))) + (raw-out-file (if headers (car headers))) + (out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file) + (cons (match-string 1 raw-out-file) + (match-string 2 raw-out-file)) + (cons raw-out-file "png"))) + (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts)))) (cond ((or htmlp latexp docbookp) (unless (file-exists-p out-file) From 2235ecb42242e1763cc97529d30d067994bd6e70 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 12:45:26 +0200 Subject: [PATCH 19/27] Fix bug in getting template from file or function --- lisp/org-capture.el | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index c689d6de4..2e12ddcab 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -385,6 +385,7 @@ bypassed." (error "Abort")) (t (org-capture-set-plist entry) + (org-capture-get-template) (org-capture-put :original-buffer orig-buf :annotation annotation :initial initial) (org-capture-put :default-time @@ -424,6 +425,25 @@ bypassed." (error "Could not start the clock in this capture buffer"))))))))))) + +(defun org-capture-get-template () + "Get the template from a file or a function if necessary." + (let ((txt (org-capture-get :template)) file) + (cond + ((and (listp txt) (eq (car txt) 'file)) + (if (file-exists-p + (setq file (expand-file-name (nth 1 txt) org-directory))) + (setq txt (org-file-contents file)) + (setq txt (format "* Template file %s not found" (nth 1 txt))))) + ((and (listp txt) (eq (car txt) 'function)) + (if (fboundp (nth 1 txt)) + (setq txt (funcall (nth 1 txt))) + (setq txt (format "* Template function %s not found" (nth 1 txt))))) + ((not txt) (setq txt "")) + ((stringp txt)) + (t (setq txt "* Invalid capture template"))) + (org-capture-put :template txt))) + (defun org-capture-finalize () "Finalize the capture process." (interactive) @@ -661,20 +681,6 @@ already gone." (target-entry-p (org-capture-get :target-entry-p)) level beg end file) - ;; Get the full template - (cond - ((and (listp txt) (eq (car txt) 'file)) - (if (file-exists-p - (setq file (expand-file-name (nth 1 txt) org-directory))) - (setq txt (org-file-contents file)) - (setq txt (format "Template file %s not found" (nth 1 txt))))) - ((and (listp txt) (eq (car txt) 'function)) - (if (fboundp (nth 1 txt)) - (setq txt (funcall (nth 1 txt))) - (setq txt (format "Template function %s not found" (nth 1 txt))))) - ((not txt) (setq txt "")) - (t (setq txt "Invalid capture template"))) - (cond ((org-capture-get :exact-position) (goto-char (org-capture-get :exact-position))) From b6305c713c54421257759c38c260f516686f2811 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 12:46:12 +0200 Subject: [PATCH 20/27] Make sure going to last capture also works after refile --- lisp/org-capture.el | 15 +++++++++++++-- lisp/org.el | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 2e12ddcab..2b02b77c9 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -534,7 +534,9 @@ already gone." (unless (eq (org-capture-get :type 'local) 'entry) (error "Refiling from a capture buffer makes only sense for `entry'-type templates")) - (let ((pos (point)) (base (buffer-base-buffer (current-buffer)))) + (let ((pos (point)) + (base (buffer-base-buffer (current-buffer))) + (org-refile-for-capture t)) (org-capture-finalize) (save-window-excursion (with-current-buffer (or base (current-buffer)) @@ -542,7 +544,16 @@ already gone." (save-restriction (widen) (goto-char pos) - (call-interactively 'org-refile))))))) + (call-interactively 'org-refile) + (when (and (boundp 'bookmark-alist) + (assoc "org-capture-last-stored" bookmark-alist)) + (if (assoc "org-refile-last-stored" bookmark-alist) + (setcdr (assoc "org-refile-last-stored" bookmark-alist) + (cdr (assoc "org-refile-last-stored" bookmark-alist))) + (push (cons "org-capture-last-stored" + (cdr (assoc "org-refile-last-stored" + bookmark-alist))) + bookmark-alist))))))))) (defun org-capture-kill () "Abort the current capture process." diff --git a/lisp/org.el b/lisp/org.el index d207e5dff..8848565bf 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10022,6 +10022,7 @@ such as the file name." Note that this is still *before* the stuff will be removed from the *old* location.") +(defvar org-capture-last-stored-marker) (defun org-refile (&optional goto default-buffer rfloc) "Move the entry at point to another heading. The list of target headings is compiled using the information in @@ -10142,6 +10143,11 @@ This can be done with a 0 prefix: `C-0 C-c C-w'" (save-excursion (org-add-log-note)))) (and org-auto-align-tags (org-set-tags nil t)) (bookmark-set "org-refile-last-stored") + ;; If we are refiling for capture, make sure that the + ;; last-capture pointers point here + (when (org-bound-and-true-p org-refile-for-capture) + (bookmark-set "org-refile-last-stored") + (move-marker org-capture-last-stored-marker (point))) (if (fboundp 'deactivate-mark) (deactivate-mark)) (run-hooks 'org-after-refile-insert-hook)))) (if regionp From b324bdca5ca9543ac387371cf9347ce7f24bbbb6 Mon Sep 17 00:00:00 2001 From: Daniel Clemente Date: Mon, 5 Jul 2010 13:14:59 +0000 Subject: [PATCH 21/27] default base-extension .org for org-publish Org-publish: correctly find files in projects which didn't define a base-extension. Previously, (org-publish-get-project-from-filename "~/org/file.org") would return nil because the constructed regular expression "^/home/dc/org/.+\\.\\(\\)$" required a dot at the end. #+BEGIN_QUOTE #+END_QUOTE --- lisp/org-publish.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-publish.el b/lisp/org-publish.el index b387e7b1c..a50cf5672 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -466,7 +466,7 @@ matching filenames." ;; [[info:org:Selecting%20files]] shows how this is supposed to work: (let* ((r (plist-get (cdr prj) :recursive)) (b (expand-file-name (plist-get (cdr prj) :base-directory))) - (x (plist-get (cdr prj) :base-extension)) + (x (or (plist-get (cdr prj) :base-extension) "org")) (e (plist-get (cdr prj) :exclude)) (i (plist-get (cdr prj) :include)) (xm (concat "^" b (if r ".+" "[^/]+") "\\.\\(" x "\\)$"))) From 4f26d13f52b5b53583acb3a030f83c4e57c3dfdb Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 14:00:09 +0200 Subject: [PATCH 22/27] org-mac-link-grabber.el: Add Firefox/vimperator --- contrib/lisp/org-mac-link-grabber.el | 55 +++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/contrib/lisp/org-mac-link-grabber.el b/contrib/lisp/org-mac-link-grabber.el index bb122043e..8ec428b2d 100644 --- a/contrib/lisp/org-mac-link-grabber.el +++ b/contrib/lisp/org-mac-link-grabber.el @@ -4,7 +4,7 @@ ;; Copyright (c) 2010 Free Software Foundation, Inc. ;; ;; Author: Anthony Lander -;; Version: 1.0 +;; Version: 1.0.1 ;; Keywords: org, mac, hyperlink ;; ;; This program is free software; you can redistribute it and/or modify @@ -39,6 +39,7 @@ ;; Mail.app - grab links to the selected messages in the message list ;; AddressBook.app - Grab links to the selected addressbook Cards ;; Firefox.app - Grab the url of the frontmost tab in the frontmost window +;; Vimperator/Firefox.app - Grab the url of the frontmost tab in the frontmost window ;; Safari.app - Grab the url of the frontmost tab in the frontmost window ;; Google Chrome.app - Grab the url of the frontmost tab in the frontmost window ;; Together.app - Grab links to the selected items in the library list @@ -108,6 +109,12 @@ applications and inserting them in org documents" :group 'org-mac-link-grabber :type 'boolean) +(defcustom org-mac-grab-Firefox+Vimperator-p nil + "Enable menu option [v]imperator to grab links from Firefox.app running the Vimperator plugin" + :tag "Grab Vimperator/Firefox.app links" + :group 'org-mac-link-grabber + :type 'boolean) + (defcustom org-mac-grab-Chrome-app-p t "Enable menu option [f]irefox to grab links from Google Chrome.app" :tag "Grab Google Chrome.app links" @@ -129,6 +136,7 @@ applications and inserting them in org documents" ("a" "ddressbook" org-mac-addressbook-insert-selected ,org-mac-grab-Addressbook-app-p) ("s" "afari" org-mac-safari-insert-frontmost-url ,org-mac-grab-Safari-app-p) ("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p) + ("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p) ("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p) ("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p))) (menu-string (make-string 0 ?x)) @@ -231,6 +239,51 @@ applications and inserting them in org documents" (interactive) (insert (org-mac-firefox-get-frontmost-url))) + +;; Handle links from Google Firefox.app running the Vimperator extension +;; Grab the frontmost url from Firefox+Vimperator. Same limitations are +;; Firefox + +(defun as-mac-vimperator-get-frontmost-url () + (let ((result (do-applescript + (concat + "set oldClipboard to the clipboard\n" + "set frontmostApplication to path to frontmost application\n" + "tell application \"Firefox\"\n" + " activate\n" + " delay 0.15\n" + " tell application \"System Events\"\n" + " keystroke \"y\"\n" + " end tell\n" + " delay 0.15\n" + " set theUrl to the clipboard\n" + " set the clipboard to oldClipboard\n" + " set theResult to (get theUrl) & \"::split::\" & (get name of window 1)\n" + "end tell\n" + "activate application (frontmostApplication as text)\n" + "set links to {}\n" + "copy theResult to the end of links\n" + "return links as string\n")))) + (replace-regexp-in-string "\s+-\s+Vimperator" "" (car (split-string result "[\r\n]+" t))))) + + +(defun org-mac-vimperator-get-frontmost-url () + (interactive) + (message "Applescript: Getting Vimperator url...") + (let* ((url-and-title (as-mac-vimperator-get-frontmost-url)) + (split-link (split-string url-and-title "::split::")) + (URL (car split-link)) + (description (cadr split-link)) + (org-link)) + (when (not (string= URL "")) + (setq org-link (org-make-link-string URL description))) + (kill-new org-link) + org-link)) + +(defun org-mac-vimperator-insert-frontmost-url () + (interactive) + (insert (org-mac-vimperator-get-frontmost-url))) + ;; Handle links from Google Chrome.app ;; Grab the frontmost url from Google Chrome. Same limitations are From b7157cc6661833fbd17b791458f1f6ce965328ae Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 14:55:47 +0200 Subject: [PATCH 23/27] Beamer: Put extra header last in header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/org-beamer.el (org-beamer-amend-header): Put extra header last in header. Tassilo Horn writes: > I'm doing a LaTeX beamer presentation with org. The org doc starts with > these lines: > > --8<---------------cut here---------------start------------->8--- > #+STARTUP: beamer > #+LaTeX_CLASS: beamer > #+TITLE: Implementieren, Integrieren, Installieren > #+AUTHOR: Tassilo Horn > #+EMAIL: horn@uni-koblenz.de > #+LANGUAGE: de > #+BEAMER_FRAME_LEVEL: 2 > #+LaTeX_CLASS_OPTIONS: [presentation] > #+BEAMER_HEADER_EXTRA: \usetheme[secheader]{Boadilla} \institute{Universität Koblenz, IST} > --8<---------------cut here---------------end--------------->8--- > > In the presentation, the ä in Universität is printed as an A with a ~ on > top, followed by a d'. The reason is that the BEAMER_HEADER_EXTRA is > put before the input encoding declaration. To be clear, org produces a > TeX file that starts with > > --8<---------------cut here---------------start------------->8--- > % Created 2010-07-06 Tue 08:57 > \documentclass[presentation]{beamer} > \usetheme[secheader]{Boadilla} \institute{Universität Koblenz, IST} > \usepackage[utf8]{inputenc} > \usepackage[T1]{fontenc} > --8<---------------cut here---------------end--------------->8--- > > but it should be at least: > > --8<---------------cut here---------------start------------->8--- > % Created 2010-07-06 Tue 08:57 > \documentclass[presentation]{beamer} > \usepackage[utf8]{inputenc} > \usetheme[secheader]{Boadilla} \institute{Universität Koblenz, IST} > \usepackage[T1]{fontenc} > --8<---------------cut here---------------end--------------->8--- > > In general, I'd say that it would be even more safe to put the extra > headers below all default headers. --- lisp/org-beamer.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-beamer.el b/lisp/org-beamer.el index af7887f3c..1530bfcdb 100644 --- a/lisp/org-beamer.el +++ b/lisp/org-beamer.el @@ -390,8 +390,8 @@ the value will be inserted right after the documentclass statement." ((re-search-forward "^[ \t]*BEAMER-HEADER-EXTRA-HERE[ \t]*$" nil t) (replace-match org-beamer-header-extra t t) (or (bolp) (insert "\n"))) - ((re-search-forward "^[ \t]*\\\\documentclass\\>" nil t) - (beginning-of-line 2) + ((re-search-forward "^[ \t]*\\\\begin{document}" nil t) + (beginning-of-line 1) (insert org-beamer-header-extra) (or (bolp) (insert "\n")))))) From 2cc4c0d564e042ba902d74d264fafdf10ee423c3 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 15:01:18 +0200 Subject: [PATCH 24/27] BEAMER: Standardize the header cookie for the beamer extra stuff * lisp/org-beamer.el (org-beamer-amend-header): Standardize the header cookie for the beamer extra stuff. --- lisp/org-beamer.el | 3 ++- lisp/org-latex.el | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/org-beamer.el b/lisp/org-beamer.el index 1530bfcdb..5afc4ee65 100644 --- a/lisp/org-beamer.el +++ b/lisp/org-beamer.el @@ -387,7 +387,8 @@ the value will be inserted right after the documentclass statement." org-beamer-header-extra) (goto-char (point-min)) (cond - ((re-search-forward "^[ \t]*BEAMER-HEADER-EXTRA-HERE[ \t]*$" nil t) + ((re-search-forward + "^[ \t]*\\[?BEAMER-HEADER-EXTRA\\(-HERE\\)?\\]?[ \t]*$" nil t) (replace-match org-beamer-header-extra t t) (or (bolp) (insert "\n"))) ((re-search-forward "^[ \t]*\\\\begin{document}" nil t) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index e1e42e0fa..70298fd4a 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -148,6 +148,7 @@ class, you can use the following macro-like placeholders. [NO-PACKAGES] do not include the packages [EXTRA] the stuff from #+LaTeX_HEADER [NO-EXTRA] do not include #+LaTeX_HEADER stuff + [BEAMER-HEADER-EXTRA] the beamer extra headers So a header like From 804d08b119e6b883f55b7194a74e9bc1ddf5f4d3 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Jul 2010 09:39:07 -0700 Subject: [PATCH 25/27] babel: don't ask twice for confirmation with :eval query Thanks to Carsten for the Patch * lisp/ob.el (org-babel-confirm-evaluate): don't ask twice for confirmation with :eval query --- lisp/ob.el | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index 0b33d97d4..7469876b0 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -171,18 +171,16 @@ any confirmation from the user. Note disabling confirmation may result in accidental evaluation of potentially harmful code." - (let ((eval (cdr (assoc :eval (nth 2 info))))) + (let* ((eval (cdr (assoc :eval (nth 2 info)))) + (query (or (equal eval "query") + (and (functionp org-confirm-babel-evaluate) + (funcall org-confirm-babel-evaluate + (nth 0 info) (nth 1 info))) + org-confirm-babel-evaluate))) (when (or (equal eval "never") - (and (equal eval "query") + (and query (not (yes-or-no-p - (format "Evaluate this%scode on your system?" - (if info (format " %s " (nth 0 info)) " "))))) - (and (or (and (functionp org-confirm-babel-evaluate) - (funcall org-confirm-babel-evaluate - (nth 0 info) (nth 1 info))) - org-confirm-babel-evaluate) - (not (yes-or-no-p - (format "Evaluate this%scode on your system?" + (format "Evaluate this%scode on your system? " (if info (format " %s " (nth 0 info)) " ")))))) (error "evaluation aborted")))) From f34f0b9b39322d93d9eefa1f4375f67335bcacf9 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Jul 2010 09:47:25 -0700 Subject: [PATCH 26/27] ob-latex: fix compiler warnings --- lisp/ob-latex.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index 4d7c0d0bd..7b549239b 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -33,6 +33,11 @@ ;;; Code: (require 'ob) +(declare-function org-create-formula-image "org" (string tofile options buffer)) +(declare-function org-splice-latex-header "org" + (tpl def-pkg pkg snippets-p &optional extra)) +(declare-function org-export-latex-fix-inputenc "org-latex" ()) + (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex")) (defvar org-babel-default-header-args:latex @@ -50,6 +55,8 @@ body))) (nth 1 (org-babel-process-params params))) body) +(defvar org-format-latex-options) +(defvar org-export-latex-packages-alist) (defun org-babel-execute:latex (body params) "Execute a block of Latex code with org-babel. This function is called by `org-babel-execute-src-block'." @@ -79,6 +86,10 @@ called by `org-babel-execute-src-block'." out-file) body)) +(defvar org-format-latex-header) +(defvar org-format-latex-header-extra) +(defvar org-export-latex-packages-alist) +(defvar org-export-latex-default-packages-alist) (defun org-babel-latex-body-to-tex-file (tex-file body &optional height width) "Place the contents of BODY into TEX-FILE. Extracted from `org-create-formula-image' in org.el." @@ -101,6 +112,9 @@ called by `org-babel-execute-src-block'." "\n\\begin{document}\n" body "\n\\end{document}\n") (org-export-latex-fix-inputenc))) +(defvar org-export-pdf-logfiles) +(defvar org-latex-to-pdf-process) +(defvar org-export-pdf-remove-logfiles) (defun org-babel-latex-tex-to-pdf (tex-file) "Generate a pdf according to the contents TEX-FILE. Extracted from `org-export-as-pdf' in org-latex.el." From c32d77391989d7499ce093f874da0657bc35a15d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 6 Jul 2010 10:30:58 -0700 Subject: [PATCH 27/27] babel: code cleaning -- `error' and `with-current-buffer' usage for Emacs inclusion --- lisp/ob-C.el | 56 +++++++++++++++++++--------------------------- lisp/ob-clojure.el | 7 +++--- lisp/ob-comint.el | 2 +- lisp/ob-ditaa.el | 2 +- lisp/ob-eval.el | 3 +-- lisp/ob-latex.el | 5 ++--- lisp/ob-mscgen.el | 5 ++--- lisp/ob-ref.el | 3 +-- lisp/ob.el | 17 +++++++------- 9 files changed, 43 insertions(+), 57 deletions(-) diff --git a/lisp/ob-C.el b/lisp/ob-C.el index 50527c358..fed688ea4 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -87,45 +87,35 @@ or `org-babel-execute:c++'." (let* ((processed-params (org-babel-process-params params)) (tmp-src-file (make-temp-file "org-babel-C-src" nil (cond - ((equal org-babel-c-variant 'c) ".c") - ((equal org-babel-c-variant 'cpp) ".cpp")))) + ((equal org-babel-c-variant 'c) ".c") + ((equal org-babel-c-variant 'cpp) ".cpp")))) (tmp-bin-file (make-temp-file "org-babel-C-bin")) (tmp-out-file (make-temp-file "org-babel-C-out")) (cmdline (cdr (assoc :cmdline params))) (flags (cdr (assoc :flags params))) (full-body (org-babel-C-expand body params)) - (error-buf (get-buffer-create "*Org-Babel Error Output*")) (compile - (progn - (with-temp-file tmp-src-file (insert full-body)) - (with-temp-buffer - (org-babel-shell-command-on-region - (point-min) (point-max) - (format "%s -o %s %s %s" - (cond - ((equal org-babel-c-variant 'c) org-babel-C-compiler) - ((equal org-babel-c-variant 'cpp) org-babel-c++-compiler)) - tmp-bin-file - (mapconcat 'identity - (if (listp flags) flags (list flags)) " ") - tmp-src-file) - (current-buffer) 'replace error-buf))))) - (if (= compile 0) - (org-babel-reassemble-table - (org-babel-read - (org-babel-trim - (org-babel-eval - (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))) - (org-babel-pick-name - (nth 4 processed-params) (cdr (assoc :colnames params))) - (org-babel-pick-name - (nth 5 processed-params) (cdr (assoc :rownames params)))) - (progn - (with-current-buffer error-buf - (goto-char (point-max)) - (insert (concat "\n\n--body--\n" full-body)) - (goto-char (point-min))) - (display-buffer error-buf) nil)))) + (progn + (with-temp-file tmp-src-file (insert full-body)) + (org-babel-eval + (format "%s -o %s %s %s" + (cond + ((equal org-babel-c-variant 'c) org-babel-C-compiler) + ((equal org-babel-c-variant 'cpp) org-babel-c++-compiler)) + tmp-bin-file + (mapconcat 'identity + (if (listp flags) flags (list flags)) " ") + tmp-src-file) "")))) + (org-babel-reassemble-table + (org-babel-read + (org-babel-trim + (org-babel-eval + (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))) + (org-babel-pick-name + (nth 4 processed-params) (cdr (assoc :colnames params))) + (org-babel-pick-name + (nth 5 processed-params) (cdr (assoc :rownames params)))))) + (defun org-babel-C-expand (body params &optional processed-params) "Expand a block of C or C++ code with org-babel according to diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 814803aac..58a1c2a89 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -93,8 +93,8 @@ (defun org-babel-clojure-babel-clojure-cmd () "Create the command to start clojure according to current settings." (if (and (not swank-clojure-binary) (not swank-clojure-classpath)) - (error (concat "You must specifiy either a `swank-clojure-binary' " - "or a `swank-clojure-jar-path'")) + (error "%s" (concat "You must specifiy either a `swank-clojure-binary' " + "or a `swank-clojure-jar-path'")) (if swank-clojure-binary (if (listp swank-clojure-binary) swank-clojure-binary @@ -269,8 +269,7 @@ repl buffer." (require 'slime) (require 'swank-clojure) (let ((raw nil) (results nil)) - (save-window-excursion - (set-buffer buffer) + (with-current-buffer buffer (setq raw (org-babel-clojure-slime-eval-sync body)) (setq results (reverse (mapcar #'org-babel-trim raw))) (cond diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index 7b742d5b7..6c13bb6ed 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -48,7 +48,7 @@ body inside the protection of `save-window-excursion' and `(save-excursion (save-match-data (unless (org-babel-comint-buffer-livep ,buffer) - (error (format "buffer %s doesn't exist or has no process" ,buffer))) + (error "buffer %s doesn't exist or has no process" ,buffer)) (set-buffer ,buffer) ,@body))) diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el index 1d70b5a44..1f56d1238 100644 --- a/lisp/ob-ditaa.el +++ b/lisp/ob-ditaa.el @@ -56,7 +56,7 @@ called by `org-babel-execute-src-block'." (cmdline (cdr (assoc :cmdline params))) (in-file (make-temp-file "org-babel-ditaa"))) (unless (file-exists-p org-ditaa-jar-path) - (error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path))) + (error "Could not find ditaa.jar at %s" org-ditaa-jar-path)) (with-temp-file in-file (insert body)) (message (concat "java -jar " org-ditaa-jar-path " " cmdline " " in-file " " out-file)) (shell-command (concat "java -jar " org-ditaa-jar-path " " cmdline " " in-file " " out-file)) diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el index 282baee29..40731a1e6 100644 --- a/lisp/ob-eval.el +++ b/lisp/ob-eval.el @@ -187,8 +187,7 @@ specifies the value of ERROR-BUFFER." ;; Clear the output buffer, then run the command with ;; output there. (let ((directory default-directory)) - (save-current-buffer - (set-buffer buffer) + (with-current-buffer buffer (setq buffer-read-only nil) (if (not output-buffer) (setq default-directory directory)) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index 7b549239b..b08e3a4c5 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -80,9 +80,8 @@ called by `org-babel-execute-src-block'." (when (file-exists-p out-file) (delete-file out-file)) (rename-file (org-babel-latex-tex-to-pdf tex-file) out-file)) ((string-match "\\.\\([^\\.]+\\)$" out-file) - (error - (message "can not create %s files, please specify a .png or .pdf file" - (match-string 1 out-file))))) + (error "can not create %s files, please specify a .png or .pdf file" + (match-string 1 out-file)))) out-file) body)) diff --git a/lisp/ob-mscgen.el b/lisp/ob-mscgen.el index 5c9f3e595..3c2b7900b 100644 --- a/lisp/ob-mscgen.el +++ b/lisp/ob-mscgen.el @@ -74,9 +74,8 @@ formats." (let* ((out-file (or (cdr (assoc :file params)) "output.png" )) (filetype (or (cdr (assoc :filetype params)) "png" ))) (unless (cdr (assoc :file params)) - (error (concat - "\nERROR: no output file specified. " - "Add \":file some_name.png\" to the src header"))) + (error " +ERROR: no output file specified. Add \":file name.png\" to the src header")) (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body) out-file)) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 85a29a216..14679bbd2 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -150,8 +150,7 @@ return nil." ;; buffer (marker-buffer id-loc) ;; loc (marker-position id-loc)) ;; (move-marker id-loc nil) - (progn (message (format "reference '%s' not found in this buffer" ref)) - (error (format "reference '%s' not found in this buffer" ref)))) + (error "reference '%s' not found in this buffer" ref)) (if lob-info (setq type 'lob) (while (not (setq type (org-babel-ref-at-ref-p))) diff --git a/lisp/ob.el b/lisp/ob.el index 7469876b0..5303f2d90 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1323,9 +1323,8 @@ block but are passed literally to the \"example-block\"." (nb-add (buffer-substring index (point))) (goto-char (match-end 0)) (setq index (point)) - (nb-add (save-current-buffer - (set-buffer parent-buffer) - (mapconcat ;; interpose `prefix' between every line + (nb-add (with-current-buffer parent-buffer + (mapconcat ;; interpose PREFIX between every line #'identity (split-string (if evaluate @@ -1334,7 +1333,8 @@ block but are passed literally to the \"example-block\"." (if (stringp raw) raw (format "%S" raw))) (save-restriction (widen) - (let ((point (org-babel-find-named-block source-name))) + (let ((point (org-babel-find-named-block + source-name))) (if point (save-excursion (goto-char point) @@ -1344,10 +1344,11 @@ block but are passed literally to the \"example-block\"." ;; optionally raise an error if named ;; source-block doesn't exist (if (member lang org-babel-noweb-error-langs) - (error - (concat "<<%s>> could not be resolved " - "(see `org-babel-noweb-error-langs')") - source-name) + (error "%s" + (concat + "<<" source-name ">> " + "could not be resolved (see " + "`org-babel-noweb-error-langs')")) ""))))) "[\n\r]") (concat "\n" prefix))))) (nb-add (buffer-substring index (point-max)))))