Browse Source

Merge branch 'master' of orgmode.org:org-mode

Carsten Dominik 14 years ago
parent
commit
468aa115ef

+ 2 - 1
Makefile

@@ -158,7 +158,8 @@ LISPF      = 	org.el			\
 		ob-js.el		\
 		ob-js.el		\
 		ob-scheme.el		\
 		ob-scheme.el		\
 		ob-lilypond.el		\
 		ob-lilypond.el		\
-		ob-java.el
+		ob-java.el		\
+		ob-shen.el
 
 
 LISPFILES0  = $(LISPF:%=lisp/%)
 LISPFILES0  = $(LISPF:%=lisp/%)
 LISPFILES   = $(LISPFILES0) lisp/org-install.el
 LISPFILES   = $(LISPFILES0) lisp/org-install.el

+ 1 - 0
contrib/lisp/org-elisp-symbol.el

@@ -106,6 +106,7 @@
 			  ((user-variable-p sym-name) "User variable")
 			  ((user-variable-p sym-name) "User variable")
 			  ((string= def "defvar") "Variable")
 			  ((string= def "defvar") "Variable")
 			  ((string= def "defmacro") "Macro")
 			  ((string= def "defmacro") "Macro")
+			  ((string= def "defun") "Function or command")
 			  (t "Symbol")))
 			  (t "Symbol")))
 	     (args (if (match-string 3)
 	     (args (if (match-string 3)
 		       (mapconcat (lambda (a) (unless (string-match "^&" a) a))
 		       (mapconcat (lambda (a) (unless (string-match "^&" a) a))

+ 1 - 1
contrib/lisp/org-exp-bibtex.el

@@ -102,7 +102,7 @@
 	    (save-match-data
 	    (save-match-data
 	      (insert-file-contents (concat file ".html"))
 	      (insert-file-contents (concat file ".html"))
 	      (goto-char (point-min))
 	      (goto-char (point-min))
-	      (while (re-search-forward "a name=\"\\(\\w+\\)\">\\(\\w+\\)" nil t)
+	      (while (re-search-forward (org-re "a name=\"\\([-_[:word:]]+\\)\">\\([[:word:]]+\\)") nil t)
 		(setq oebp-cite-plist (cons (cons (match-string 1) (match-string 2)) oebp-cite-plist)))
 		(setq oebp-cite-plist (cons (cons (match-string 1) (match-string 2)) oebp-cite-plist)))
 	      (goto-char (point-min))
 	      (goto-char (point-min))
 	      (while (re-search-forward "<hr>" nil t)
 	      (while (re-search-forward "<hr>" nil t)

+ 2 - 8
contrib/lisp/org-lparse.el

@@ -254,14 +254,8 @@ OPT-PLIST is the export options list."
 	       'ORG-LINK opt-plist type path nil desc attr descp)))
 	       'ORG-LINK opt-plist type path nil desc attr descp)))
 
 
        ((string= type "coderef")
        ((string= type "coderef")
-	(setq rpl
-	      (org-lparse-format
-	       'ORG-LINK opt-plist type "" (format "coderef-%s" path)
-	       (format
-		(org-export-get-coderef-format
-		 path
-		 (and descp desc))
-		(cdr (assoc path org-export-code-refs))) nil descp)))
+	(setq rpl (org-lparse-format
+		   'ORG-LINK opt-plist type "" path desc nil descp)))
 
 
        ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
        ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
 	;; The link protocol has a function for format the link
 	;; The link protocol has a function for format the link

+ 82 - 27
contrib/lisp/org-odt.el

@@ -917,10 +917,13 @@ styles congruent with the ODF-1.2 specification."
   (cond
   (cond
    ((and (= (string-to-char href) ?#) (not org-odt-suppress-xref))
    ((and (= (string-to-char href) ?#) (not org-odt-suppress-xref))
     (setq href (concat org-export-odt-bookmark-prefix (substring href 1)))
     (setq href (concat org-export-odt-bookmark-prefix (substring href 1)))
-    (org-odt-format-tags
-     '("<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"%s\">" .
-       "</text:bookmark-ref>")
-     desc href))
+    (let ((xref-format "text"))
+      (when (numberp desc)
+	(setq desc (format "%d" desc) xref-format "number"))
+      (org-odt-format-tags
+       '("<text:bookmark-ref text:reference-format=\"%s\" text:ref-name=\"%s\">" .
+	 "</text:bookmark-ref>")
+       desc xref-format href)))
    (org-lparse-link-description-is-image
    (org-lparse-link-description-is-image
     (org-odt-format-tags
     (org-odt-format-tags
      '("<draw:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</draw:a>")
      '("<draw:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</draw:a>")
@@ -978,18 +981,36 @@ to make available an enhanced version of `htmlfontify' library."
   :type 'boolean
   :type 'boolean
   :group 'org-export-odt)
   :group 'org-export-odt)
 
 
+(defun org-odt-format-source-line-with-line-number-and-label
+  (line rpllbl num fontifier par-style)
+
+  (let ((keep-label (not (numberp rpllbl)))
+	(ref (org-find-text-property-in-string 'org-coderef line)))
+    (setq line (concat line (and keep-label ref (format "(%s)" ref))))
+    (setq line (funcall fontifier line))
+    (when ref
+      (setq line (org-odt-format-target line (concat "coderef-" ref))))
+    (setq line (org-odt-format-stylized-paragraph par-style line))
+    (when num
+      (org-odt-format-tags '("<text:list-item>" . "</text:list-item>") line))))
+
 (defun org-odt-format-source-code-or-example-plain
 (defun org-odt-format-source-code-or-example-plain
   (lines lang caption textareap cols rows num cont rpllbl fmt)
   (lines lang caption textareap cols rows num cont rpllbl fmt)
   "Format source or example blocks much like fixedwidth blocks.
   "Format source or example blocks much like fixedwidth blocks.
 Use this when `org-export-odt-use-htmlfontify' option is turned
 Use this when `org-export-odt-use-htmlfontify' option is turned
 off."
 off."
-  (setq lines (org-export-number-lines (org-xml-encode-plain-text-lines lines)
-				       0 0 num cont rpllbl fmt))
+  (let* ((lines (org-split-string lines "[\r\n]"))
+	 (line-count (length lines))
+	 (i 0))
     (mapconcat
     (mapconcat
      (lambda (line)
      (lambda (line)
-       (org-odt-format-stylized-paragraph
-	'fixedwidth (org-odt-fill-tabs-and-spaces line)))
-     (org-split-string lines "[\r\n]") "\n"))
+       (incf i)
+       (org-odt-format-source-line-with-line-number-and-label
+	line rpllbl num (lambda (line)
+			  (org-odt-fill-tabs-and-spaces
+			   (org-xml-encode-plain-text line)))
+	(if (= i line-count) "OrgFixedWidthBlockLastLine" "OrgFixedWidthBlock")))
+     lines "\n")))
 
 
 (defvar org-src-block-paragraph-format
 (defvar org-src-block-paragraph-format
   "<style:style style:name=\"OrgSrcBlock\" style:family=\"paragraph\" style:parent-style-name=\"Preformatted_20_Text\">
   "<style:style style:name=\"OrgSrcBlock\" style:family=\"paragraph\" style:parent-style-name=\"Preformatted_20_Text\">
@@ -1100,10 +1121,16 @@ turned on."
 	    (insert (format "<text:span text:style-name=\"%s\">" style))))
 	    (insert (format "<text:span text:style-name=\"%s\">" style))))
 	 (hfy-end-span-handler (lambda nil (insert "</text:span>"))))
 	 (hfy-end-span-handler (lambda nil (insert "</text:span>"))))
     (when (fboundp 'htmlfontify-string)
     (when (fboundp 'htmlfontify-string)
-      (mapconcat
-       (lambda (line)
-	 (org-odt-format-stylized-paragraph 'src (htmlfontify-string line)))
-       (org-split-string lines "[\r\n]") "\n"))))
+      (let* ((lines (org-split-string lines "[\r\n]"))
+	     (line-count (length lines))
+	     (i 0))
+	(mapconcat
+	 (lambda (line)
+	   (incf i)
+	   (org-odt-format-source-line-with-line-number-and-label
+	    line rpllbl num 'htmlfontify-string
+	    (if (= i line-count) "OrgSrcBlockLastLine" "OrgSrcBlock")))
+	 lines "\n")))))
 
 
 (defun org-odt-format-source-code-or-example (lines lang caption textareap
 (defun org-odt-format-source-code-or-example (lines lang caption textareap
 						    cols rows num cont
 						    cols rows num cont
@@ -1112,16 +1139,23 @@ turned on."
 Use `org-odt-format-source-code-or-example-plain' or
 Use `org-odt-format-source-code-or-example-plain' or
 `org-odt-format-source-code-or-example-colored' depending on the
 `org-odt-format-source-code-or-example-colored' depending on the
 value of `org-export-odt-use-htmlfontify."
 value of `org-export-odt-use-htmlfontify."
-  (funcall
-   (if (and org-export-odt-use-htmlfontify
-	    (or (featurep 'htmlfontify) (require 'htmlfontify))
-	    (fboundp 'htmlfontify-string))
-       'org-odt-format-source-code-or-example-colored
-     'org-odt-format-source-code-or-example-plain)
-   lines lang caption textareap cols rows num cont rpllbl fmt))
-
-(defun org-xml-encode-plain-text-lines (rtn)
-  (mapconcat 'org-xml-encode-plain-text (org-split-string rtn "[\r\n]") "\n"))
+  (setq lines (org-export-number-lines
+	       lines 0 0 num cont rpllbl fmt ;; 'preprocess
+	       )
+	lines (funcall
+	       (or (and org-export-odt-use-htmlfontify
+			(or (featurep 'htmlfontify)
+			    (require 'htmlfontify))
+			(fboundp 'htmlfontify-string)
+			'org-odt-format-source-code-or-example-colored)
+		   'org-odt-format-source-code-or-example-plain)
+	       lines lang caption textareap cols rows num cont rpllbl fmt))
+  (if (not num) lines
+    (let ((extra (format " text:continue-numbering=\"%s\""
+			 (if cont "true" "false"))))
+      (org-odt-format-tags
+       '("<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>"
+	 . "</text:list>") lines extra))))
 
 
 (defun org-odt-remap-stylenames (style-name)
 (defun org-odt-remap-stylenames (style-name)
   (or
   (or
@@ -1265,6 +1299,28 @@ MAY-INLINE-P allows inlining it as an image."
 	     (org-odt-is-formula-link-p filename)
 	     (org-odt-is-formula-link-p filename)
 	     (or (not descp)))
 	     (or (not descp)))
 	(org-odt-format-inline-formula thefile))
 	(org-odt-format-inline-formula thefile))
+       ((string= type "coderef")
+	(let* ((ref fragment)
+	       (lineno-or-ref (cdr (assoc ref org-export-code-refs)))
+	       (desc (and descp desc))
+	       (org-odt-suppress-xref nil)
+	       (href (org-xml-format-href (concat "#coderef-" ref))))
+	  (cond
+	   ((and (numberp lineno-or-ref) (not desc))
+	    (org-odt-format-link lineno-or-ref href))
+	   ((and (numberp lineno-or-ref) desc
+		 (string-match (regexp-quote (concat "(" ref ")")) desc))
+	    (format (replace-match "%s" t t desc)
+		    (org-odt-format-link lineno-or-ref href)))
+	   (t
+	    (setq desc (format
+			(if (and desc (string-match
+				       (regexp-quote (concat "(" ref ")"))
+				       desc))
+			    (replace-match "%s" t t desc)
+			  (or desc "%s"))
+			lineno-or-ref))
+	    (org-odt-format-link (org-xml-format-desc desc) href)))))
        (t
        (t
 	(when (string= type "file")
 	(when (string= type "file")
 	  (setq thefile
 	  (setq thefile
@@ -1274,16 +1330,15 @@ MAY-INLINE-P allows inlining it as an image."
 		 (t (org-odt-relocate-relative-path
 		 (t (org-odt-relocate-relative-path
 		     thefile org-current-export-file)))))
 		     thefile org-current-export-file)))))
 
 
-	(when (and (member type '("" "http" "https" "file" "coderef"))
-		   fragment)
+	(when (and (member type '("" "http" "https" "file")) fragment)
 	  (setq thefile (concat thefile "#" fragment)))
 	  (setq thefile (concat thefile "#" fragment)))
 
 
 	(setq thefile (org-xml-format-href thefile))
 	(setq thefile (org-xml-format-href thefile))
 
 
-	(when (not (member type '("" "file" "coderef")))
+	(when (not (member type '("" "file")))
 	  (setq thefile (concat type ":" thefile)))
 	  (setq thefile (concat type ":" thefile)))
 
 
-	(let ((org-odt-suppress-xref (string= type "coderef")))
+	(let ((org-odt-suppress-xref nil))
 	  (org-odt-format-link
 	  (org-odt-format-link
 	   (org-xml-format-desc desc) thefile attr)))))))
 	   (org-xml-format-desc desc) thefile attr)))))))
 
 

+ 8 - 5
contrib/lisp/org-xhtml.el

@@ -715,7 +715,7 @@ See variable `org-export-xhtml-link-org-files-as-html'"
 
 
 ;;; org-xhtml-format-org-link
 ;;; org-xhtml-format-org-link
 (defun org-xhtml-format-org-link (opt-plist type-1 path fragment desc attr
 (defun org-xhtml-format-org-link (opt-plist type-1 path fragment desc attr
-					   descp)
+					    descp)
   "Make an HTML link.
   "Make an HTML link.
 OPT-PLIST is an options list.
 OPT-PLIST is an options list.
 TYPE is the device-type of the link (THIS://foo.html)
 TYPE is the device-type of the link (THIS://foo.html)
@@ -725,11 +725,14 @@ DESC is the link description, if any.
 ATTR is a string of other attributes of the a element.
 ATTR is a string of other attributes of the a element.
 MAY-INLINE-P allows inlining it as an image."
 MAY-INLINE-P allows inlining it as an image."
   (declare (special org-lparse-par-open))
   (declare (special org-lparse-par-open))
-  (when (string= type-1 "coderef")
-    (setq attr
-	  (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
-		  fragment fragment)))
   (save-match-data
   (save-match-data
+    (when (string= type-1 "coderef")
+      (let ((ref fragment))
+	(setq desc (format (org-export-get-coderef-format ref (and descp desc))
+			   (cdr (assoc ref org-export-code-refs)))
+	      fragment (concat  "coderef-" ref)
+	      attr (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
+			   fragment fragment))))
     (let* ((may-inline-p
     (let* ((may-inline-p
 	    (and (member type-1 '("http" "https" "file"))
 	    (and (member type-1 '("http" "https" "file"))
 		 (org-lparse-should-inline-p path descp)
 		 (org-lparse-should-inline-p path descp)

+ 41 - 0
contrib/odt/styles/OrgOdtStyles.xml

@@ -251,6 +251,14 @@
    </style:paragraph-properties>
    </style:paragraph-properties>
   </style:style>
   </style:style>
 
 
+  <style:style style:name="OrgFixedWidthBlockLastLine" style:family="paragraph" style:parent-style-name="OrgFixedWidthBlock">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.21cm"/>
+  </style:style>
+
+  <style:style style:name="OrgSrcBlockLastLine" style:family="paragraph" style:parent-style-name="OrgSrcBlock">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.21cm"/>
+  </style:style>
+
   <style:style style:name="OrgCenter" style:family="paragraph" style:parent-style-name="Text_20_body">
   <style:style style:name="OrgCenter" style:family="paragraph" style:parent-style-name="Text_20_body">
    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
   </style:style>
   </style:style>
@@ -643,6 +651,39 @@
    </text:list-level-style-number>
    </text:list-level-style-number>
   </text:list-style>
   </text:list-style>
 
 
+  <text:list-style style:name="OrgSrcBlockNumberedLine">
+   <text:list-level-style-number text:level="1" style:num-format="1">
+    <style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="2" style:num-format="1">
+    <style:list-level-properties text:space-before="1.27cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="3" style:num-format="1">
+    <style:list-level-properties text:space-before="1.905cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="4" style:num-format="1">
+    <style:list-level-properties text:space-before="2.54cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="5" style:num-format="1">
+    <style:list-level-properties text:space-before="3.175cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="6" style:num-format="1">
+    <style:list-level-properties text:space-before="3.81cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="7" style:num-format="1">
+    <style:list-level-properties text:space-before="4.445cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="8" style:num-format="1">
+    <style:list-level-properties text:space-before="5.08cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="9" style:num-format="1">
+    <style:list-level-properties text:space-before="5.715cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+   <text:list-level-style-number text:level="10" style:num-format="1">
+    <style:list-level-properties text:space-before="6.35cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/>
+   </text:list-level-style-number>
+  </text:list-style>
+
   <text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_20_Symbol" text:citation-body-style-name="Footnote_20_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/>
   <text:notes-configuration text:note-class="footnote" text:citation-style-name="Footnote_20_Symbol" text:citation-body-style-name="Footnote_20_anchor" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/>
   <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/>
   <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/>
   <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
   <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>

+ 78 - 0
lisp/ob-shen.el

@@ -0,0 +1,78 @@
+;;; ob-shen.el --- org-babel functions for Shen
+
+;; Copyright (C) 2010-2011 Free Software Foundation
+
+;; Author: Eric Schulte
+;; Keywords: literate programming, reproducible research, shen
+;; Homepage: http://orgmode.org
+
+;; 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:
+
+;; Currently this only works using session evaluation as there is no
+;; defined method for executing shen code outside of a session.
+
+;;; Requirements:
+
+;; - shen-mode and inf-shen will soon be available through the GNU
+;;   elpa, however in the interim they are available at
+;;   https://github.com/eschulte/shen-mode
+
+;;; Code:
+(require 'ob)
+
+(declare-function shen-eval-defun "ext:inf-shen" (&optional and-go))
+
+(defvar org-babel-default-header-args:shen '()
+  "Default header arguments for shen code blocks.")
+
+(defun org-babel-expand-body:shen (body params)
+  "Expand BODY according to PARAMS, return the expanded body."
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
+    (if (> (length vars) 0)
+        (concat "(let "
+                (mapconcat (lambda (var)
+			     (format "%s %s" (car var)
+				     (org-babel-shen-var-to-shen (cdr var))))
+			   vars " ")
+		body ")")
+      body)))
+
+(defun org-babel-shen-var-to-shen (var)
+  "Convert VAR into a shen variable."
+  (if (listp var)
+      (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var " ") "]")
+    (format "%S" var)))
+
+(defun org-babel-execute:shen (body params)
+  "Execute a block of Shen code with org-babel.
+This function is called by `org-babel-execute-src-block'"
+  (require 'inf-shen)
+  (let* ((result-type (cdr (assoc :result-type params)))
+         (full-body (org-babel-expand-body:shen body params)))
+    ((lambda (results)
+       (if (or (member 'scalar result-params)
+	       (member 'verbatim result-params))
+	   results
+	 (condition-case nil (org-babel-script-escape results)
+	   (error result))))
+     (with-temp-buffer
+       (insert full-body)
+       (call-interactively #'shen-eval-defun)))))
+
+(provide 'ob-shen)
+;;; ob-shen.el ends here

+ 53 - 40
lisp/ob-table.el

@@ -77,46 +77,59 @@ NOTE: by default string variable names are interpreted as
 references to source-code blocks, to force interpretation of a
 references to source-code blocks, to force interpretation of a
 cell's value as a string, prefix the identifier with two \"$\"s
 cell's value as a string, prefix the identifier with two \"$\"s
 rather than a single \"$\" (i.e. \"$$2\" instead of \"$2\" in the
 rather than a single \"$\" (i.e. \"$$2\" instead of \"$2\" in the
-example above."
-  (let* (quote
-	 (variables
-	  (mapcar
-	   (lambda (var)
-	     ;; ensure that all cells prefixed with $'s are strings
-	     (cons (car var)
-		   (delq nil (mapcar
-			      (lambda (el)
-				(if (eq '$ el)
-				    (setq quote t)
-				  (prog1 (if quote
-					     (format "\"%s\"" el)
-					   (org-babel-clean-text-properties el))
-				    (setq quote nil))))
-			      (cdr var)))))
-	   variables)))
-    (unless (stringp source-block)
-      (setq source-block (symbol-name source-block)))
-    ((lambda (result)
-       (org-babel-trim (if (stringp result) result (format "%S" result))))
-     (if (and source-block (> (length source-block) 0))
-         (let ((params
-                (eval `(org-babel-parse-header-arguments
-                        (concat ":var results="
-                                ,source-block
-                                "("
-                                (mapconcat
-				 (lambda (var-spec)
-				   (if (> (length (cdr var-spec)) 1)
-				       (format "%S='%S"
-					       (car var-spec)
-					       (mapcar #'read (cdr var-spec)))
-				     (format "%S=%s"
-					     (car var-spec) (cadr var-spec))))
-				 ',variables ", ")
-                                ")")))))
-           (org-babel-execute-src-block
-            nil (list "emacs-lisp" "results" params) '((:results . "silent"))))
-       ""))))
+example above.
+
+NOTE: it is also possible to pass header arguments to the code
+block.  In this case a table cell should hold the string value of
+the header argument which can then be passed before all variables
+as shown in the example below.
+
+| 1 | 2 | :file nothing.png | nothing.png |
+#+TBLFM: @1$4='(sbe test-sbe $3 (x $1) (y $2))"
+  (let* ((header-args (if (stringp (car variables)) (car variables) ""))
+	 (variables (if (stringp (car variables)) (cdr variables) variables)))
+    (let* (quote
+	   (variables
+	    (mapcar
+	     (lambda (var)
+	       ;; ensure that all cells prefixed with $'s are strings
+	       (cons (car var)
+		     (delq nil (mapcar
+				(lambda (el)
+				  (if (eq '$ el)
+				      (setq quote t)
+				    (prog1 (if quote
+					       (format "\"%s\"" el)
+					     (org-babel-clean-text-properties el))
+				      (setq quote nil))))
+				(cdr var)))))
+	     variables)))
+      (unless (stringp source-block)
+	(setq source-block (symbol-name source-block)))
+      ((lambda (result)
+	 (org-babel-trim (if (stringp result) result (format "%S" result))))
+       (if (and source-block (> (length source-block) 0))
+	   (let ((params
+		  (eval `(org-babel-parse-header-arguments
+			  (concat
+			   ":var results="
+			   ,source-block
+			   "[" ,header-args "]"
+			   "("
+			   (mapconcat
+			    (lambda (var-spec)
+			      (if (> (length (cdr var-spec)) 1)
+				  (format "%S='%S"
+					  (car var-spec)
+					  (mapcar #'read (cdr var-spec)))
+				(format "%S=%s"
+					(car var-spec) (cadr var-spec))))
+			    ',variables ", ")
+			   ")")))))
+	     (org-babel-execute-src-block
+	      nil (list "emacs-lisp" "results" params)
+	      '((:results . "silent"))))
+	 "")))))
 (def-edebug-spec sbe (form form))
 (def-edebug-spec sbe (form form))
 
 
 (provide 'ob-table)
 (provide 'ob-table)

+ 3 - 1
lisp/org-agenda.el

@@ -5409,7 +5409,9 @@ FRACTION is what fraction of the head-warning time has passed."
 				     org-agenda-timerange-leaders)
 				     org-agenda-timerange-leaders)
 				(1+ (- d0 d1)) (1+ (- d2 d1)))
 				(1+ (- d0 d1)) (1+ (- d2 d1)))
 			       head category tags
 			       head category tags
-			       (cond ((= d1 d0)
+			       (cond ((and (= d1 d0) (= d2 d0))
+				      (concat "<" start-time ">--<" end-time ">"))
+                                     ((= d1 d0)
 				      (concat "<" start-time ">"))
 				      (concat "<" start-time ">"))
 				     ((= d2 d0)
 				     ((= d2 d0)
 				      (concat "<" end-time ">"))
 				      (concat "<" end-time ">"))

+ 12 - 4
lisp/org.el

@@ -185,6 +185,7 @@ requirements) is loaded."
 		 (const :tag "Scheme" scheme)
 		 (const :tag "Scheme" scheme)
 		 (const :tag "Screen" screen)
 		 (const :tag "Screen" screen)
 		 (const :tag "Shell Script" sh)
 		 (const :tag "Shell Script" sh)
+		 (const :tag "Shen" shen)
 		 (const :tag "Sql" sql)
 		 (const :tag "Sql" sql)
 		 (const :tag "Sqlite" sqlite))
 		 (const :tag "Sqlite" sqlite))
 		:value-type (boolean :tag "Activate" :value t)))
 		:value-type (boolean :tag "Activate" :value t)))
@@ -1864,7 +1865,7 @@ will temporarily be changed to `time'."
 
 
 (defcustom org-refile-targets nil
 (defcustom org-refile-targets nil
   "Targets for refiling entries with \\[org-refile].
   "Targets for refiling entries with \\[org-refile].
-This is list of cons cells.  Each cell contains:
+This is a list of cons cells.  Each cell contains:
 - a specification of the files to be considered, either a list of files,
 - a specification of the files to be considered, either a list of files,
   or a symbol whose function or variable value will be used to retrieve
   or a symbol whose function or variable value will be used to retrieve
   a file name or a list of file names.  If you use `org-agenda-files' for
   a file name or a list of file names.  If you use `org-agenda-files' for
@@ -1886,6 +1887,10 @@ This is list of cons cells.  Each cell contains:
     Note that, when `org-odd-levels-only' is set, level corresponds to
     Note that, when `org-odd-levels-only' is set, level corresponds to
     order in hierarchy, not to the number of stars.
     order in hierarchy, not to the number of stars.
 
 
+Each element of this list generates a set of possible targets.
+The union of these sets is presented (with completion) to
+the user by `org-refile'.
+
 You can set the variable `org-refile-target-verify-function' to a function
 You can set the variable `org-refile-target-verify-function' to a function
 to verify each headline found by the simple criteria above.
 to verify each headline found by the simple criteria above.
 
 
@@ -2879,7 +2884,9 @@ This is an undocumented feature, you should not rely on it.")
   "The column to which tags should be indented in a headline.
   "The column to which tags should be indented in a headline.
 If this number is positive, it specifies the column.  If it is negative,
 If this number is positive, it specifies the column.  If it is negative,
 it means that the tags should be flushright to that column.  For example,
 it means that the tags should be flushright to that column.  For example,
--80 works well for a normal 80 character screen."
+-80 works well for a normal 80 character screen.
+When 0, place tags directly after headline text, with only one space in
+between."
   :group 'org-tags
   :group 'org-tags
   :type 'integer)
   :type 'integer)
 
 
@@ -9521,7 +9528,8 @@ application the system uses for this file type."
 			      ((equal arg '(16)) ''org-occur)
 			      ((equal arg '(16)) ''org-occur)
 			      (t nil))
 			      (t nil))
 		       ,pos)))
 		       ,pos)))
-	    (condition-case nil (eval cmd)
+	    (condition-case nil (let ((org-link-search-inhibit-query t))
+				  (eval cmd))
 	      (error (progn (widen) (eval cmd))))))
 	      (error (progn (widen) (eval cmd))))))
 
 
 	 (t
 	 (t
@@ -13065,7 +13073,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
 	  (goto-char (match-beginning 1))
 	  (goto-char (match-beginning 1))
 	  (insert " ")
 	  (insert " ")
 	  (delete-region (point) (1+ (match-beginning 2)))
 	  (delete-region (point) (1+ (match-beginning 2)))
-	  (setq ncol (max (1+ (current-column))
+	  (setq ncol (max (current-column)
 			  (1+ col)
 			  (1+ col)
 			  (if (> to-col 0)
 			  (if (> to-col 0)
 			      to-col
 			      to-col