Merge branch 'master' of git://repo.or.cz/org-mode

This commit is contained in:
Dan Davison 2010-07-06 14:28:29 -04:00
commit 8ddb11cfa5
24 changed files with 501 additions and 243 deletions

View File

@ -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 \

View File

@ -4,7 +4,7 @@
;; Copyright (c) 2010 Free Software Foundation, Inc.
;;
;; Author: Anthony Lander <anthony.lander@gmail.com>
;; 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

View File

@ -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
@ -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
@ -11411,13 +11412,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 +11430,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 +12009,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 +12017,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

View File

@ -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

View File

@ -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

View File

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

View File

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

View File

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

View File

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

View File

@ -54,13 +54,12 @@ 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
runif(n)
#+end_src
")
#+end_src")
(defvar org-babel-function-def-export-indent 4
"When exporting a source block function, the block contents
@ -99,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)

View File

@ -32,7 +32,11 @@
;;; Code:
(require 'ob)
(require 'org-latex)
(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"))
@ -51,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'."
@ -74,12 +80,15 @@ 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))
(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."
@ -102,6 +111,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."

90
lisp/ob-mscgen.el Normal file
View File

@ -0,0 +1,90 @@
;;; 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 <http://www.gnu.org/licenses/>.
;;; 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)
(require 'ob-eval)
(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" ))
(filetype (or (cdr (assoc :filetype params)) "png" )))
(unless (cdr (assoc :file params))
(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))
(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

View File

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

View File

@ -171,14 +171,18 @@ 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))))
(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 query
(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 ()
@ -1319,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
@ -1330,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)
@ -1340,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)))))

View File

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

View File

@ -387,11 +387,12 @@ 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]*\\\\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"))))))

View File

@ -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))
@ -372,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
@ -411,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)
@ -501,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))
@ -509,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."
@ -646,7 +690,8 @@ 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)
(cond
((org-capture-get :exact-position)
(goto-char (org-capture-get :exact-position)))

View File

@ -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

View File

@ -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 <eeeickythump@gmail.com>
;;; Version: 1.0
;; Author: Paul Sexton <eeeickythump@gmail.com>
;; 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 <http://www.gnu.org/licenses/>.
;;;
;;; Synopsis
;;; ========
;;;
;;; Allows org-mode to make use of the Emacs `etags' system. Defines tag
;;; destinations in org-mode files as any text between <<double angled
;;; brackets>>. 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
;;; <<matching destinations>> 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 <<double angled
;; brackets>>. 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
;; <<matching destinations>> 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 "<<foo>>"
;;; 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
;;; "<<foo>>" in any other files. If it does, the matching file will be opened
;;; and the cursor will jump to the position of "<<foo>>" 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 "<M-kp-multiply>") '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 "<<foo>>"
;; 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
;; "<<foo>>" in any other files. If it does, the matching file will be opened
;; and the cursor will jump to the position of "<<foo>>" 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 "<M-kp-multiply>") '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

View File

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

View File

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

View File

@ -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
@ -415,6 +416,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 +1666,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 +1680,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

View File

@ -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 "\\)$")))

View File

@ -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)
@ -3571,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.
@ -10019,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
@ -10139,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
@ -14813,17 +14822,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."