Browse Source

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

Paul Sexton 8 years ago
parent
commit
34fa86edf5

+ 22 - 9
contrib/lisp/org-contacts.el

@@ -403,7 +403,10 @@ This adds `org-contacts-gnus-check-mail-address' and
   (add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-check-mail-address)
   (add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-store-last-mail))
 
-(defun wl-get-from-header-content ()
+(defun org-contacts-wl-get-from-header-content ()
+  "Retrieve the content of the `From' header of an email.
+Works from wl-summary-mode and mime-view-mode - that is while viewing email.
+Depends on Wanderlust been loaded."
   (save-excursion
     (set-buffer (org-capture-get :original-buffer))
     (cond
@@ -417,17 +420,27 @@ This adds `org-contacts-gnus-check-mail-address' and
                                           (std11-fetch-field "From")
                                         (widen))))))
 
+(defun org-contacts-wl-get-name-email ()
+  "Get name and email address from wanderlust email.
+See `org-contacts-wl-get-from-header-content' for limitations."
+  (let ((from (org-contacts-wl-get-from-header-content)))
+    (when from
+      (list (wl-address-header-extract-realname from)
+	    (wl-address-header-extract-address from)))))
+
 (defun org-contacts-template-wl-name (&optional return-value)
-  (let ((from (wl-get-from-header-content)))
-    (or (and from (wl-address-header-extract-realname from))
-       return-value
-       "%^{Name}")))
+  "Try to return the contact name for a template from wl.
+If not found return RETURN-VALUE or something that would ask the user."
+  (or (car (org-contacts-wl-get-name-email))
+      return-value
+      "%^{Name}"))
 
 (defun org-contacts-template-wl-email (&optional return-value)
-  (let ((from (wl-get-from-header-content)))
-    (or (and from (wl-address-header-extract-address from))
-       return-value
-       (concat "%^{" org-contacts-email-property "}p"))))
+  "Try to return the contact email for a template from wl.
+If not found return RETURN-VALUE or something that would ask the user."
+  (or (cadr (org-contacts-wl-get-name-email))
+      return-value
+      (concat "%^{" org-contacts-email-property "}p")))
 
 (defun org-contacts-view-send-email (&optional ask)
   "Send email to the contact at point.

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

@@ -107,7 +107,7 @@
 	      (goto-char (point-min))
 	      (while (re-search-forward "<hr>" nil t)
 		(replace-match "<hr/>" t t))
-	      (concat "\n#+BEGIN_HTML\n<div id=\"bibliography\">\n" (buffer-string) "\n</div>\n#+END_HTML\n"))))
+	      (concat "\n#+BEGIN_HTML\n<div id=\"bibliography\">\n<h2>References</h2>\n" (buffer-string) "\n</div>\n#+END_HTML\n"))))
 	 ((eq org-export-current-backend 'latex) ;; Latex export
 	  (concat "\n#+LATEX: \\bibliographystyle{" style "}"
 		  "\n#+LATEX: \\bibliography{" file "}\n"))) t t)))

+ 27 - 13
contrib/lisp/org-expiry.el

@@ -81,6 +81,11 @@
   :tag "Org Expiry"
   :group 'org)
 
+(defcustom org-expiry-inactive-timestamps nil
+  "Insert inactive timestamps for the created and expired time properties"
+  :type 'boolean
+  :group 'org-expiry)
+
 (defcustom org-expiry-created-property-name "CREATED"
   "The name of the property for setting the creation date."
   :type 'string
@@ -283,21 +288,25 @@ to today's date.  With two `C-u' prefixes, prompt the user for to
 update the date."
   (interactive "P")
   (let* ((d (org-entry-get (point) org-expiry-created-property-name))
-	 d-time d-hour)
+	 d-time d-hour timestr)
     (when (or (null d) arg)
       ;; update if no date or non-nil prefix argument
       ;; FIXME Use `org-time-string-to-time' 
-      (setq d-time (if d (apply 'encode-time (org-parse-time-string d))
+      (setq d-time (if d (org-time-string-to-time d)
 		     (current-time)))
       (setq d-hour (format-time-string "%H:%M" d-time))
+      (setq timestr
+	    ;; two C-u prefixes will call org-read-date
+	    (if (equal arg '(16))
+		(concat "<" (org-read-date
+			     nil nil nil nil d-time d-hour) ">")
+	      (format-time-string (cdr org-time-stamp-formats))))
+      ;; maybe transform to inactive timestamp
+      (if org-expiry-inactive-timestamps
+	  (setq timestr (concat "[" (substring timestr 1 -1) "]")))
       (save-excursion
 	(org-entry-put
-	 (point) org-expiry-created-property-name
-	 ;; two C-u prefixes will call org-read-date
-	 (if (equal arg '(16))
-	     (concat "<" (org-read-date
-			  nil nil nil nil d-time d-hour) ">")
-	   (format-time-string (cdr org-time-stamp-formats))))))))
+	 (point) org-expiry-created-property-name timestr)))))
 
 (defun org-expiry-insert-expiry (&optional today)
   "Insert a property with the expiry date.
@@ -306,15 +315,20 @@ and insert today's date."
   (interactive "P")
   (let* ((d (org-entry-get (point) org-expiry-expiry-property-name))
 	 d-time d-hour)
-    (setq d-time (if d (apply 'encode-time (org-parse-time-string d))
+    (setq d-time (if d (org-time-string-to-time d)
 		   (current-time)))
     (setq d-hour (format-time-string "%H:%M" d-time))
+    (setq timestr (if today
+		      (format-time-string (cdr org-time-stamp-formats))
+		    (concat "<" (org-read-date
+				 nil nil nil nil d-time d-hour) ">")))
+    ;; maybe transform to inactive timestamp
+    (if org-expiry-inactive-timestamps
+	(setq timestr (concat "[" (substring timestr 1 -1) "]")))
+     
     (save-excursion
       (org-entry-put
-       (point) org-expiry-expiry-property-name
-       (if today (format-time-string (cdr org-time-stamp-formats))
-	 (concat "<" (org-read-date
-		      nil nil nil nil d-time d-hour) ">"))))))
+       (point) org-expiry-expiry-property-name timestr))))
 
 ;;; Functions to process expired entries:
 

+ 6 - 6
doc/org.texi

@@ -14376,12 +14376,12 @@ other block) with @code{org-narrow-to-block}.
 @vindex org-agenda-skip-function
 @vindex org-agenda-skip-function-global
 Org provides a special hook that can be used to narrow down the selection
-made by these agenda views: @code{todo}, @code{alltodo}, @code{tags},
-@code{tags-todo}, @code{tags-tree}.  You may specify a function that is used
-at each match to verify if the match should indeed be part of the agenda
-view, and if not, how much should be skipped.  You can specify a global
-condition that will be applied to all agenda views, this condition would be
-stored in the variable @code{org-agenda-skip-function-global}.  More
+made by these agenda views: @code{agenda}, @code{todo}, @code{alltodo},
+@code{tags}, @code{tags-todo}, @code{tags-tree}. You may specify a function
+that is used at each match to verify if the match should indeed be part of
+the agenda view, and if not, how much should be skipped. You can specify a
+global condition that will be applied to all agenda views, this condition
+would be stored in the variable @code{org-agenda-skip-function-global}. More
 commonly, such a definition is applied only to specific custom searches,
 using @code{org-agenda-skip-function}.
 

+ 1 - 1
lisp/ob-R.el

@@ -227,7 +227,7 @@ current code buffer."
 (defvar org-babel-R-eoe-indicator "'org_babel_R_eoe'")
 (defvar org-babel-R-eoe-output "[1] \"org_babel_R_eoe\"")
 
-(defvar org-babel-R-write-object-command "{function(object, transfer.file) {object;invisible(if(inherits(try(write.table(object, file=transfer.file, sep=\"\\t\", na=\"nil\",row.names=%s, col.names=%s, quote=FALSE), silent=TRUE),\"try-error\")) {if(!file.exists(transfer.file)) file.create(transfer.file)})}}(object=%s, transfer.file=\"%s\")")
+(defvar org-babel-R-write-object-command "{function(object,transfer.file){object;invisible(if(inherits(try({tfile<-tempfile();write.table(object,file=tfile,sep=\"\\t\",na=\"nil\",row.names=%s,col.names=%s,quote=FALSE);file.rename(tfile,transfer.file)},silent=TRUE),\"try-error\")){if(!file.exists(transfer.file))file.create(transfer.file)})}}(object=%s,transfer.file=\"%s\")")
 
 (defun org-babel-R-evaluate
   (session body result-type column-names-p row-names-p)

+ 1 - 1
lisp/ob-ledger.el

@@ -52,7 +52,7 @@ called by `org-babel-execute-src-block'."
         (in-file (org-babel-temp-file "ledger-"))
 	(out-file (org-babel-temp-file "ledger-output-")))
     (with-temp-file in-file (insert body))
-    (message (concat "ledger"
+    (message "%s" (concat "ledger"
 		     " -f " (org-babel-process-file-name in-file)
 		     " " cmdline))
     (with-output-to-string

+ 1 - 1
lisp/org-capture.el

@@ -415,7 +415,7 @@ bypassed."
 	   (annotation (if (and (boundp 'org-capture-link-is-already-stored)
 				org-capture-link-is-already-stored)
 			   (plist-get org-store-link-plist :annotation)
-			 (org-store-link nil)))
+			 (ignore-errors (org-store-link nil))))
 	   (initial (and (org-region-active-p)
 			 (buffer-substring (point) (mark))))
 	   (entry (org-capture-select-template keys)))

+ 1 - 1
lisp/org-exp.el

@@ -1298,7 +1298,7 @@ Also find all ID and CUSTOM_ID properties and store them."
 				       (org-outline-level))))
 	  (setq target (org-solidify-link-text
 			(format "sec-%s" (replace-regexp-in-string
-					  "\\." "_"
+					  "\\." "-"
 					  (org-section-number level)))))
 	  (setq last-section-target target)
 	  (push (cons target target) target-alist)

+ 37 - 35
lisp/org-html.el

@@ -1543,6 +1543,7 @@ lang=\"%s\" xml:lang=\"%s\">
 	  ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
 	  ;; Also handle sub_superscripts and checkboxes
 	  (or (string-match org-table-hline-regexp line)
+	      (string-match "^[ \t]*\\([+]-\\||[ ]\\)[-+ |]*[+|][ \t]*$" line)
 	      (setq line (org-html-expand line)))
 
 	  ;; Format the links
@@ -1888,24 +1889,13 @@ NO-CSS is passed to the exporter."
   (if (string-match "^[ \t]*|" (car lines))
       ;; A normal org table
       (org-format-org-table-html lines nil no-css)
-    ;; Table made by table.el - test for spanning
-    (let* ((hlines (delq nil (mapcar
-			      (lambda (x)
-				(if (string-match "^[ \t]*\\+-" x) x
-				  nil))
-			      lines)))
-	   (first (car hlines))
-	   (ll (and (string-match "\\S-+" first)
-		    (match-string 0 first)))
-	   (re (concat "^[ \t]*" (regexp-quote ll)))
-	   (spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
-				       hlines))))
-      (if (and (not spanning)
-	       (not org-export-prefer-native-exporter-for-tables))
-	  ;; We can use my own converter with HTML conversions
-	  (org-format-table-table-html lines)
-	;; Need to use the code generator in table.el, with the original text.
-	(org-format-table-table-html-using-table-generate-source olines)))))
+    ;; Table made by table.el 
+    (or (org-format-table-table-html-using-table-generate-source
+	 olines (not org-export-prefer-native-exporter-for-tables))
+	;; We are here only when table.el table has NO col or row
+	;; spanning and the user prefers using org's own converter for
+	;; exporting of such simple table.el tables.
+	(org-format-table-table-html lines))))
 
 (defvar org-table-number-fraction) ; defined in org-table.el
 (defun org-format-org-table-html (lines &optional splice no-css)
@@ -2116,10 +2106,20 @@ But it has the disadvantage, that no cell- or row-spanning is allowed."
     (setq html (concat html "</table>\n"))
     html))
 
-(defun org-format-table-table-html-using-table-generate-source (lines)
+(defun org-format-table-table-html-using-table-generate-source (lines
+								&optional
+								spanned-only)
   "Format a table into html, using `table-generate-source' from table.el.
-This has the advantage that cell- or row-spanning is allowed.
-But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
+Use SPANNED-ONLY to suppress exporting of simple table.el tables.
+
+When SPANNED-ONLY is nil, all table.el tables are exported.  When
+SPANNED-ONLY is non-nil, only tables with either row or column
+spans are exported.
+
+This routine returns the generated source or nil as appropriate.
+
+Refer docstring of `org-export-prefer-native-exporter-for-tables'
+for further information."
   (require 'table)
   (with-current-buffer (get-buffer-create " org-tmp1 ")
     (erase-buffer)
@@ -2128,10 +2128,14 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
     (if (not (re-search-forward "|[^+]" nil t))
 	(error "Error processing table"))
     (table-recognize-table)
-    (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
-    (table-generate-source 'html " org-tmp2 ")
-    (set-buffer " org-tmp2 ")
-    (buffer-substring (point-min) (point-max))))
+    (when (or (not spanned-only)
+	      (let* ((dim (table-query-dimension))
+		     (c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
+		(not (= (* c r) cells))))
+      (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
+      (table-generate-source 'html " org-tmp2 ")
+      (set-buffer " org-tmp2 ")
+      (buffer-substring (point-min) (point-max)))))
 
 (defun org-export-splice-style (style extra)
   "Splice EXTRA into STYLE, just before \"</style>\"."
@@ -2234,16 +2238,14 @@ If there are links in the string, don't modify these."
   (let* ((re (concat org-bracket-link-regexp "\\|"
 		     (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
 	 m s l res)
-    (if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string)
-	string
-      (while (setq m (string-match re string))
-	(setq s (substring string 0 m)
-	      l (match-string 0 string)
-	      string (substring string (match-end 0)))
-	(push (org-html-do-expand s) res)
-	(push l res))
-      (push (org-html-do-expand string) res)
-      (apply 'concat (nreverse res)))))
+    (while (setq m (string-match re string))
+      (setq s (substring string 0 m)
+	    l (match-string 0 string)
+	    string (substring string (match-end 0)))
+      (push (org-html-do-expand s) res)
+      (push l res))
+    (push (org-html-do-expand string) res)
+    (apply 'concat (nreverse res))))
 
 (defun org-html-do-expand (s)
   "Apply all active conversions to translate special ASCII to HTML."

+ 2 - 1
lisp/org-latex.el

@@ -1627,7 +1627,8 @@ See the `org-export-latex.el' code for a complete conversion table."
 	  (goto-char (point-min))
 	  (while (re-search-forward c nil t)
 	    ;; Put the point where to check for org-protected
-	    (unless (get-text-property (match-beginning 2) 'org-protected)
+	    (unless (or (get-text-property (match-beginning 2) 'org-protected)
+			(org-at-table.el-p))
 	      (cond ((member (match-string 2) '("\\$" "$"))
 		     (if (equal (match-string 2) "\\$")
 			 nil

+ 4 - 4
lisp/org.el

@@ -13900,13 +13900,13 @@ and the new value.")
 	  (if (re-search-forward
 	       (org-re-property property) (cdr range) t)
 	      (progn
-		(delete-region (match-beginning 1) (match-end 1))
-		(goto-char (match-beginning 1)))
+		(delete-region (match-beginning 0) (match-end 0))
+		(goto-char (match-beginning 0)))
 	    (goto-char (cdr range))
 	    (insert "\n")
 	    (backward-char 1)
-	    (org-indent-line-function)
-	    (insert ":" property ":"))
+	    (org-indent-line-function))
+	  (insert ":" property ":")
 	  (and value (insert " " value))
 	  (org-indent-line-function)))))
     (run-hook-with-args 'org-property-changed-functions property value)))