Browse Source

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

Dan Davison 15 years ago
parent
commit
4e4972a558

+ 2 - 2
contrib/babel/lisp/langs/org-babel-R.el

@@ -186,7 +186,7 @@ last statement in BODY, as elisp."
 	 (with-temp-buffer
 	   (insert body)
 	   (org-babel-shell-command-on-region (point-min) (point-max) "R --slave --no-save" 'current-buffer 'replace)
-	   (buffer-string)))
+	   (org-babel-trim (buffer-string))))
 	(value
 	 (let* ((tmp-file (make-temp-file "R-out-functional-results")) exit-code
 		(stderr
@@ -235,7 +235,7 @@ last statement in BODY, as elisp."
 		     (if (= (length el) 0)
 			 nil
 		       (if (string-match comint-prompt-regexp el)
-			   (substring el (match-end 0))
+			   (org-babel-trim (substring el (match-end 0)))
 			 el)))))
 	     (mapconcat
 	      #'identity

+ 2 - 1
contrib/babel/lisp/langs/org-babel-latex.el

@@ -97,7 +97,8 @@ called by `org-babel-execute-src-block'."
             (if org-format-latex-header-extra
                 (concat "\n" org-format-latex-header-extra)
               "")
-            "\n\\begin{document}\n" body "\n\\end{document}\n")))
+            "\n\\begin{document}\n" body "\n\\end{document}\n")
+    (org-export-latex-fix-inputenc)))
 
 (defun org-babel-latex-tex-to-pdf (tex-file)
   "Extracted from `org-export-as-pdf' in org-latex.el."

+ 16 - 0
contrib/babel/lisp/org-babel-exp.el

@@ -34,6 +34,7 @@
 (org-export-blocks-add-block '(src org-babel-exp-src-blocks nil))
 (add-to-list 'org-export-interblocks '(src org-babel-exp-inline-src-blocks))
 (add-to-list 'org-export-interblocks '(lob org-babel-exp-lob-one-liners))
+(add-hook 'org-export-blocks-postblock-hook 'org-exp-res/src-name-cleanup)
 
 (defvar org-babel-function-def-export-keyword "function"
   "When exporting a source block function, this keyword will
@@ -113,6 +114,21 @@ options and are taken from `org-babel-defualt-inline-header-args'."
 	(setq end (+ end (- (length replacement) (length (match-string 1)))))
 	(replace-match replacement t t nil 1)))))
 
+(defun org-exp-res/src-name-cleanup ()
+  "Cleanup leftover #+results and #+srcname lines as part of the
+org export cycle.  This should only be called after all block
+processing has taken place."
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (while (org-re-search-forward-unprotected
+	    (concat
+	     "\\("org-babel-source-name-regexp"\\|"org-babel-result-regexp"\\)")
+	    nil t)
+      (delete-region
+       (progn (beginning-of-line) (point))
+       (progn (end-of-line) (+ 1 (point)))))))
+
 (defun org-babel-in-example-or-verbatim ()
   "Return true if the point is currently in an escaped portion of
 an org-mode buffer code which should be treated as normal

+ 6 - 5
contrib/babel/lisp/org-babel.el

@@ -887,7 +887,8 @@ following the source block."
 				     "#+results"
 				     (when hash (concat "["hash"]"))
 				     ":"
-				     (when name (concat " " name)) "\n"))
+				     (when name (concat " " name)) "\n\n"))
+			    (backward-char)
                             (beginning-of-line 0)
                             (if hash (org-babel-hide-hash)) t)))
                (point))))))
@@ -1066,16 +1067,16 @@ relies on `org-babel-insert-result'."
       (let ((case-fold-search t))
         (cond
          ((looking-at "[ \t]*#\\+begin_latex")
-          (search-forward "[ \t]*#\\+end_latex" nil t)
+          (re-search-forward "[ \t]*#\\+end_latex" nil t)
           (forward-line 1))
          ((looking-at "[ \t]*#\\+begin_html")
-          (search-forward "[ \t]*#\\+end_html" nil t)
+          (re-search-forward "[ \t]*#\\+end_html" nil t)
           (forward-line 1))
          ((looking-at "[ \t]*#\\+begin_example")
-          (search-forward "[ \t]*#\\+end_example" nil t)
+          (re-search-forward "[ \t]*#\\+end_example" nil t)
           (forward-line 1))
          ((looking-at "[ \t]*#\\+begin_src")
-          (search-forward "[ \t]*#\\+end_src" nil t)
+          (re-search-forward "[ \t]*#\\+end_src" nil t)
           (forward-line 1))
          (t (progn (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
                      (forward-line 1))))))

+ 4 - 4
doc/org.texi

@@ -265,7 +265,7 @@ Remember
 Archiving
 
 * Moving subtrees::             Moving a tree to an archive file
-* Internal archiving::          Switch off a tree but keep i in the file
+* Internal archiving::          Switch off a tree but keep it in the file
 
 Agenda Views
 
@@ -5137,8 +5137,8 @@ in @b{bold}.
 2/5/3         --> 2003-02-05
 14            --> @b{2006}-@b{06}-14
 12            --> @b{2006}-@b{07}-12
-2/5           --> @b{2003}-02-05
-Fri           --> nearest Friday (defaultdate or later)
+2/5           --> @b{2007}-02-05
+Fri           --> nearest Friday (default date or later)
 sep 15        --> @b{2006}-09-15
 feb 15        --> @b{2007}-02-15
 sep 12 9      --> 2009-09-12
@@ -6347,7 +6347,7 @@ Archive the current entry using the command specified in the variable
 
 @menu
 * Moving subtrees::             Moving a tree to an archive file
-* Internal archiving::          Switch off a tree but keep i in the file
+* Internal archiving::          Switch off a tree but keep it in the file
 @end menu
 
 @node Moving subtrees, Internal archiving, Archiving, Archiving

+ 2 - 2
lisp/org-agenda.el

@@ -4573,7 +4573,7 @@ be skipped."
 	      pos (1- (match-beginning 1))
 	      d2 (org-time-string-to-absolute
 		  (match-string 1) d1 'past
-		  org-agenda-repeating-timestamp-show-all)
+		  org-agenda-repeating-timestamp-show-all t)
 	      diff (- d2 d1)
 	      wdays (if suppress-prewarning
 			(let ((org-deadline-warning-days suppress-prewarning))
@@ -4675,7 +4675,7 @@ FRACTION is what fraction of the head-warning time has passed."
 	      pos (1- (match-beginning 1))
 	      d2 (org-time-string-to-absolute
 		  (match-string 1) d1 'past
-		  org-agenda-repeating-timestamp-show-all)
+		  org-agenda-repeating-timestamp-show-all t)
 	      diff (- d2 d1))
 	(setq pastschedp (and todayp (< diff 0)))
 	;; When to show a scheduled item in the calendar:

+ 8 - 3
lisp/org-exp-blocks.el

@@ -136,7 +136,11 @@ be exported."
   :group 'org-export-general
   :type 'list)
 
-(defvar org-export-blocks-postblock-hooks nil "")
+(defcustom org-export-blocks-postblock-hook nil
+  "Run after blocks have been processed with
+`org-export-blocks-preprocess'."
+  :group 'org-export-general
+  :type 'hook)
 
 (defun org-export-blocks-html-quote (body &optional open close)
   "Protext BODY from org html export.  The optional OPEN and
@@ -174,7 +178,7 @@ specified in BLOCKS which default to the value of
 	(goto-char (point-min))
 	(setq start (point))
 	(while (re-search-forward
-		"^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)[\r\n][ \t]*#\\+end_\\S-+.*" nil t)
+		"^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)[\r\n][ \t]*#\\+end_\\S-+.*[\r\n]?" nil t)
           (setq indentation (length (match-string 1)))
 	  (setq type (intern (downcase (match-string 2))))
 	  (setq headers (save-match-data (org-split-string (match-string 3) "[ \t]+")))
@@ -194,7 +198,8 @@ specified in BLOCKS which default to the value of
                   (indent-code-rigidly
                    (match-beginning 0) (match-end 0) indentation)))))
 	  (setq start (match-end 0)))
-	(interblock start (point-max))))))
+	(interblock start (point-max))
+	(run-hooks 'org-export-blocks-postblock-hook)))))
 
 (add-hook 'org-export-preprocess-hook 'org-export-blocks-preprocess)
 

+ 23 - 8
lisp/org-exp.el

@@ -1032,7 +1032,7 @@ on this string to produce the exported version."
       (untabify (point-min) (point-max))
 
       ;; Handle include files, and call a hook
-      (org-export-handle-include-files)
+      (org-export-handle-include-files-recurse)
       (run-hooks 'org-export-preprocess-after-include-files-hook)
 
       ;; Get rid of archived trees
@@ -1567,7 +1567,7 @@ These special cookies will later be interpreted by the backend."
       (setq beg (match-beginning 0)
 	    beg1 (1+ (match-end 0)))
       (when (re-search-forward (concat "^[ \t]*#\\+end_" type "\\>.*") nil t)
-	(setq end (1+ (point-at-eol))
+	(setq end (+ (point-at-eol) (if (looking-at "\n$") 1 0))
 	      end1 (1- (match-beginning 0)))
 	(setq content (org-remove-indentation (buffer-substring beg1 end1)))
 	(setq content (concat "ORG-" (upcase t1) "-START\n"
@@ -1637,7 +1637,7 @@ table line.  If it is a link, add it to the line containing the link."
   "Remove comments, or convert to backend-specific format.
 COMMENTSP can be a format string for publishing comments.
 When it is nil, all comments will be removed."
-  (let ((re "^\\(#\\|[ \t]*#\\+\\)\\(.*\n?\\)")
+  (let ((re "^\\(#\\|[ \t]*#\\+ \\)\\(.*\n?\\)")
 	pos)
     (goto-char (point-min))
     (while (or (looking-at re)
@@ -1649,9 +1649,8 @@ When it is nil, all comments will be removed."
 		  (match-beginning 0) (match-end 0) '(org-protected t))
 		 (replace-match (format commentsp (match-string 2)) t t))
 	(goto-char (1+ pos))
-	(org-if-unprotected
-	 (replace-match "")
-	 (goto-char (max (point-min) (1- pos))))))))
+	(replace-match "")
+	(goto-char (max (point-min) (1- pos)))))))
 
 (defun org-export-mark-radio-links ()
   "Find all matches for radio targets and turn them into internal links."
@@ -1969,7 +1968,7 @@ TYPE must be a string, any of:
 (defun org-export-handle-include-files ()
   "Include the contents of include files, with proper formatting."
   (let ((case-fold-search t)
-	params file markup lang start end prefix prefix1 switches)
+	params file markup lang start end prefix prefix1 switches all)
     (goto-char (point-min))
     (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
       (setq params (read (concat "(" (match-string 1) ")"))
@@ -1986,6 +1985,7 @@ TYPE must be a string, any of:
 	      (not (file-exists-p file))
 	      (not (file-readable-p file)))
 	  (insert (format "CANNOT INCLUDE FILE %s" file))
+	(setq all (cons file all))
 	(when markup
 	  (if (equal (downcase markup) "src")
 	      (setq start (format "#+begin_src %s %s\n"
@@ -1998,7 +1998,22 @@ TYPE must be a string, any of:
 	(insert (org-get-file-contents (expand-file-name file)
 				       prefix prefix1 markup))
 	(or (bolp) (newline))
-	(insert (or end ""))))))
+	(insert (or end ""))))
+    all))
+
+(defun org-export-handle-include-files-recurse ()
+  "Recursively include files aborting on circular inclusion."
+  (let ((now (list org-current-export-file)) all)
+    (while now
+      (setq all (remove-duplicates (append now all)))
+      (setq now (org-export-handle-include-files))
+      (let ((intersection
+	     (delq nil
+		   (mapcar
+		    (lambda (el) (when (member el all) el))
+		    now))))
+	(when (intersection now all)
+	  (error "recursive #+INCLUDE: %S" intersection))))))
 
 (defun org-get-file-contents (file &optional prefix prefix1 markup)
   "Get the contents of FILE and return them as a string.

+ 14 - 15
lisp/org-latex.el

@@ -2188,21 +2188,20 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   "Convert plain text lists in current buffer into LaTeX lists."
   (let (res)
     (goto-char (point-min))
-    (while (re-search-forward org-list-beginning-re nil t)
-      (org-if-unprotected
-       (beginning-of-line)
-       (setq res (org-list-to-latex (org-list-parse-list t)
-				    org-export-latex-list-parameters))
-       (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
-			    res)
-	 (setq res (replace-match
-		    (concat (format "\\setcounter{enumi}{%d}"
-				    (1- (string-to-number
-					 (match-string 2 res))))
-			    "\n"
-			    (match-string 1 res))
-		    t t res)))
-       (insert res "\n")))))
+    (while (org-re-search-forward-unprotected org-list-beginning-re nil t)
+      (beginning-of-line)
+      (setq res (org-list-to-latex (org-list-parse-list t)
+				   org-export-latex-list-parameters))
+      (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
+			   res)
+	(setq res (replace-match
+		   (concat (format "\\setcounter{enumi}{%d}"
+				   (1- (string-to-number
+					(match-string 2 res))))
+			   "\n"
+			   (match-string 1 res))
+		   t t res)))
+      (insert res "\n"))))
 
 (defconst org-latex-entities
  '("\\!"

+ 1 - 1
lisp/org-list.el

@@ -1170,7 +1170,7 @@ sublevels as a list of strings."
 				    (match-beginning 0)) end))))
 	     (item (buffer-substring
 		    (point)
-		    (or (and (re-search-forward
+		    (or (and (org-re-search-forward-unprotected
 			      org-list-beginning-re end t)
 			     (goto-char (match-beginning 0)))
 			(goto-char end))))

+ 6 - 1
lisp/org-publish.el

@@ -756,7 +756,12 @@ Default for SITEMAP-FILENAME is 'sitemap.org'."
   (save-window-excursion
     (let* ((org-publish-use-timestamps-flag
 	    (if force nil org-publish-use-timestamps-flag)))
-      (org-publish-projects (list project)))))
+      (org-publish-projects
+       (if (stringp project)
+	   ;; If this function is called in batch mode,
+	   ;; project is still a string here.
+	   (list (assoc project org-publish-project-alist))
+	   (list project))))))
 
 ;;;###autoload
 (defun org-publish-all (&optional force)

+ 27 - 19
lisp/org.el

@@ -5515,14 +5515,16 @@ and subscriipts."
 	     org-match-substring-regexp
 	   org-match-substring-with-braces-regexp)
 	 limit t)
-	(let* ((pos (point)) table-p comment-p emph-p link-p)
-	  (setq emph-p (get-text-property (match-beginning 3) 'org-emphasis))
-	  (setq link-p (get-text-property (match-beginning 3) 'mouse-face))
+	(let* ((pos (point)) table-p comment-p
+	       (mpos (match-beginning 3))
+	       (emph-p (get-text-property mpos 'org-emphasis))
+	       (link-p (get-text-property mpos 'mouse-face))
+	       (keyw-p (eq 'org-special-keyword (get-text-property mpos 'face))))
 	  (goto-char (point-at-bol))
 	  (setq table-p (org-looking-at-p org-table-dataline-regexp)
 		comment-p (org-looking-at-p "[ \t]*#"))
 	  (goto-char pos)
-	  (if (or comment-p emph-p link-p)
+	  (if (or comment-p emph-p link-p keyw-p)
 	      t
 	    (put-text-property (match-beginning 3) (match-end 0)
 			       'display
@@ -13198,12 +13200,11 @@ allowed value."
   (save-excursion
     (beginning-of-line 1)
     (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))
-     (let ((match (match-data)) ;; Keep match-data for use by calling
-	   (p (point))          ;; procedures.
-	   (range (unless (org-before-first-heading-p)
-		    (org-get-property-block))))
-       (prog1 (and range (<= (car range) p) (< p (cdr range)))
-	 (set-match-data match))))))
+      (save-match-data ;; Used by calling procedures
+	(let ((p (point))
+	      (range (unless (org-before-first-heading-p)
+		       (org-get-property-block))))
+	  (and range (<= (car range) p) (< p (cdr range))))))))
 
 (defun org-get-property-block (&optional beg end force)
   "Return the (beg . end) range of the body of the property drawer.
@@ -14683,18 +14684,20 @@ days in order to avoid rounding problems."
 (defun org-time-string-to-seconds (s)
   (org-float-time (org-time-string-to-time s)))
 
-(defun org-time-string-to-absolute (s &optional daynr prefer show-all)
+(defun org-time-string-to-absolute (s &optional daynr prefer show-all ignore-cyclic)
   "Convert a time stamp to an absolute day number.
-If there is a specifyer for a cyclic time stamp, get the closest date to
+If there is a specifier 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."
+the variable date is bound by the calendar when this is called.
+IGNORE-CYCLIC ignores cyclic repeaters so the returned absolute date
+is based on the original date."
   (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))
+   ((and (not ignore-cyclic) 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))
@@ -15571,10 +15574,6 @@ looks only before point, not after."
     (org-in-regexp
      "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")))
 
-(defun test ()
-  (interactive)
-  (message "%s" (org-inside-latex-macro-p)))
-
 (defun org-try-cdlatex-tab ()
   "Check if it makes sense to execute `cdlatex-tab', and do it if yes.
 It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
@@ -15925,7 +15924,7 @@ BEG and END default to the buffer boundaries."
       (widen)
       (setq beg (or beg (point-min)) end (or end (point-max)))
       (goto-char (point-min))
-      (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([-+~./_0-9a-zA-Z]+"
+      (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([-+~.:/\\_0-9a-zA-Z ]+"
 			(substring (org-image-file-name-regexp) 0 -2)
 			"\\)\\]" (if include-linked "" "\\]")))
 	    old file ov img)
@@ -15943,8 +15942,17 @@ BEG and END default to the buffer boundaries."
 		(overlay-put ov 'display img)
 		(overlay-put ov 'face 'default)
 		(overlay-put ov 'org-image-overlay t)
+		(overlay-put ov 'modification-hooks
+			     (list 'org-display-inline-modification-hook))
 		(push ov org-inline-image-overlays)))))))))
 
+(defun org-display-inline-modification-hook (ov after beg end &optional len)
+  "Remove inline-display overlay if a corresponding region is modified."
+  (let ((inhibit-modification-hooks t))
+    (when (and ov after)
+      (delete ov org-inline-image-overlays)
+      (delete-overlay ov))))
+
 (defun org-remove-inline-images ()
   "Remove inline display of images."
   (interactive)