瀏覽代碼

Merge remote-tracking branch 'origin/master'

Rasmus 10 年之前
父節點
當前提交
1f8d4a06b7
共有 10 個文件被更改,包括 114 次插入35 次删除
  1. 5 6
      contrib/lisp/ox-koma-letter.el
  2. 1 0
      doc/org.texi
  3. 3 0
      etc/ORG-NEWS
  4. 26 15
      lisp/ob-ruby.el
  5. 14 4
      lisp/ob-sql.el
  6. 3 3
      lisp/org-agenda.el
  7. 24 1
      lisp/ox-ascii.el
  8. 2 1
      lisp/ox-latex.el
  9. 3 3
      testing/lisp/test-ob-exp.el
  10. 33 2
      testing/lisp/test-ob-ruby.el

+ 5 - 6
contrib/lisp/ox-koma-letter.el

@@ -391,7 +391,7 @@ was not present."
     (:lco "LCO" nil org-koma-letter-class-option-file)
     (:author "AUTHOR" nil (org-koma-letter--get-value org-koma-letter-author) t)
     (:author-changed-in-buffer-p "AUTHOR" nil nil t)
-    (:from-address "FROM_ADDRESS" nil nil newline)
+    (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline)
     (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
     (:email "EMAIL" nil (org-koma-letter--get-value org-koma-letter-email) t)
     (:to-address "TO_ADDRESS" nil nil newline)
@@ -504,15 +504,14 @@ KEY should be `to' or `from'.
 `ox-koma-letter' allows two ways to specify TO and FROM.  If both
 are present return the preferred one as determined by
 `org-koma-letter-prefer-special-headings'."
-  (let ((option (plist-get info (if (eq key 'to) :to-address :from-address)))
+  (let ((option (org-string-nw-p
+		 (plist-get info (if (eq key 'to) :to-address :from-address))))
 	(headline (org-koma-letter--get-tagged-contents key)))
     (replace-regexp-in-string
      "\n" "\\\\\\\\\n"
      (org-trim
-      (or (if (plist-get info :special-headings) (or headline option)
-	    (or option headline))
-	  ;; Fallback values.
-	  (if (eq key 'to) "\\mbox{}" org-koma-letter-from-address))))))
+      (if (plist-get info :special-headings) (or headline option "")
+	(or option headline ""))))))
 
 
 

+ 1 - 0
doc/org.texi

@@ -13807,6 +13807,7 @@ however, override everything.
 @item @code{:ascii-inlinetask-width}              @tab @code{org-ascii-inlinetask-width}
 @item @code{:ascii-inner-margin}                  @tab @code{org-ascii-inner-margin}
 @item @code{:ascii-links-to-notes}                @tab @code{org-ascii-links-to-notes}
+@item @code{:ascii-list-margin}                   @tab @code{org-ascii-list-margin}
 @item @code{:ascii-paragraph-spacing}             @tab @code{org-ascii-paragraph-spacing}
 @item @code{:ascii-quote-margin}                  @tab @code{org-ascii-quote-margin}
 @item @code{:ascii-table-keep-all-vertical-lines} @tab @code{org-ascii-table-keep-all-vertical-lines}

+ 3 - 0
etc/ORG-NEWS

@@ -61,6 +61,9 @@ which is now obsolete.  As a consequence, this change also deprecates
 *** Markdown export supports switches in source blocks
 For example, it is now possible to number lines using the =-n= switch
 in a source block.
+*** New option in ASCII export
+Plain lists can have an extra margin by setting
+~org-ascii-list-margin~ variable to an appopriate integer.
 *** New blocks in ASCII export
 ASCII export now supports =#+BEGIN_JUSTIFYRIGHT= and
 =#+BEGIN_JUSTIFYLEFT= blocks.  See documentation for details.

+ 26 - 15
lisp/ob-ruby.el

@@ -209,21 +209,32 @@ return the value of the last statement in BODY, as elisp."
     ;; comint session evaluation
     (case result-type
       (output
-       (mapconcat
-	#'identity
-	(butlast
-	 (split-string
-	  (mapconcat
-	   #'org-babel-trim
-	   (butlast
-	    (org-babel-comint-with-output
-		(buffer org-babel-ruby-eoe-indicator t body)
-	      (mapc
-	       (lambda (line)
-		 (insert (org-babel-chomp line)) (comint-send-input nil t))
-	       (list "conf.echo=false" body "conf.echo=true" org-babel-ruby-eoe-indicator))
-	      (comint-send-input nil t)) 2)
-	   "\n") "[\r\n]")) "\n"))
+       (let ((eoe-string (format "puts \"%s\"" org-babel-ruby-eoe-indicator)))
+	 ;; Force the session to be ready before the actual session
+	 ;; code is run.  There is some problem in comint that will
+	 ;; sometimes show the prompt after the the input has already
+	 ;; been inserted and that throws off the extraction of the
+	 ;; result for Babel.
+	 (org-babel-comint-with-output
+	     (buffer org-babel-ruby-eoe-indicator t eoe-string)
+	   (insert eoe-string) (comint-send-input nil t))
+	 ;; Now we can start the evaluation.
+	 (mapconcat
+	  #'identity
+	  (butlast
+	   (split-string
+	    (mapconcat
+	     #'org-babel-trim
+	     (org-babel-comint-with-output
+		 (buffer org-babel-ruby-eoe-indicator t body)
+	       (mapc
+		(lambda (line)
+		  (insert (org-babel-chomp line)) (comint-send-input nil t))
+		(list "conf.echo=false;_org_prompt_mode=conf.prompt_mode;conf.prompt_mode=:NULL"
+		      body
+		      "conf.prompt_mode=_org_prompt_mode;conf.echo=true"
+		      eoe-string)))
+	     "\n") "[\r\n]") 4) "\n")))
       (value
        (let* ((tmp-file (org-babel-temp-file "ruby-"))
 	      (ppp (or (member "code" result-params)

+ 14 - 4
lisp/ob-sql.el

@@ -78,15 +78,24 @@
   (org-babel-sql-expand-vars
    body (mapcar #'cdr (org-babel-get-header params :var))))
 
-(defun dbstring-mysql (host user password database)
+(defun org-babel-sql-dbstring-mysql (host user password database)
   "Make MySQL cmd line args for database connection.  Pass nil to omit that arg."
   (combine-and-quote-strings
-   (remq nil
+   (delq nil
 	 (list (when host     (concat "-h" host))
 	       (when user     (concat "-u" user))
 	       (when password (concat "-p" password))
 	       (when database (concat "-D" database))))))
 
+(defun org-babel-sql-dbstring-postgresql (host user database)
+  "Make PostgreSQL command line args for database connection.
+Pass nil to omit that arg."
+  (combine-and-quote-strings
+   (delq nil
+	 (list (when host (concat "-h" host))
+	       (when user (concat "-U" user))
+	       (when database (concat "-d" database))))))
+
 (defun org-babel-execute:sql (body params)
   "Execute a block of Sql code with Babel.
 This function is called by `org-babel-execute-src-block'."
@@ -117,14 +126,15 @@ This function is called by `org-babel-execute-src-block'."
                                      (org-babel-process-file-name in-file)
                                      (org-babel-process-file-name out-file)))
                     ('mysql (format "mysql %s %s %s < %s > %s"
-				    (dbstring-mysql dbhost dbuser dbpassword database)
+				    (org-babel-sql-dbstring-mysql dbhost dbuser dbpassword database)
 				    (if colnames-p "" "-N")
                                     (or cmdline "")
 				    (org-babel-process-file-name in-file)
 				    (org-babel-process-file-name out-file)))
 		    ('postgresql (format
-				  "psql --set=\"ON_ERROR_STOP=1\" %s -A -P footer=off -F \"\t\"  -f %s -o %s %s"
+				  "psql --set=\"ON_ERROR_STOP=1\" %s -A -P footer=off -F \"\t\"  %s -f %s -o %s %s"
 				  (if colnames-p "" "-t")
+				  (org-babel-sql-dbstring-postgresql dbhost dbuser database)
 				  (org-babel-process-file-name in-file)
 				  (org-babel-process-file-name out-file)
 				  (or cmdline "")))

+ 3 - 3
lisp/org-agenda.el

@@ -9680,7 +9680,7 @@ This is a command that has to be installed in `calendar-mode-map'."
 	  (overlay-put ov 'type 'org-marked-entry-overlay))
 	(end-of-line 1)
 	(or (ignore-errors
-	      (goto-char (next-single-property-change (point) 'txt)))
+	      (goto-char (next-single-property-change (point) 'org-hd-marker)))
 	    (beginning-of-line 2))
 	(while (and (get-char-property (point) 'invisible) (not (eobp)))
 	  (beginning-of-line 2))
@@ -9698,7 +9698,7 @@ This is a command that has to be installed in `calendar-mode-map'."
   (let ((entries-marked 0) txt-at-point)
     (save-excursion
       (goto-char (point-min))
-      (goto-char (next-single-property-change (point) 'txt))
+      (goto-char (next-single-property-change (point) 'org-hd-marker))
       (while (and (re-search-forward regexp nil t)
 		  (setq txt-at-point (get-text-property (point) 'txt)))
 	(when (string-match regexp txt-at-point)
@@ -9734,7 +9734,7 @@ This is a command that has to be installed in `calendar-mode-map'."
   (save-excursion
     (goto-char (point-min))
     (while (ignore-errors
-	     (goto-char (next-single-property-change (point) 'txt)))
+	     (goto-char (next-single-property-change (point) 'org-hd-marker)))
       (org-agenda-bulk-toggle))))
 
 (defun org-agenda-bulk-toggle ()

+ 24 - 1
lisp/ox-ascii.el

@@ -133,6 +133,7 @@
     (:ascii-inlinetask-width nil nil org-ascii-inlinetask-width)
     (:ascii-inner-margin nil nil org-ascii-inner-margin)
     (:ascii-links-to-notes nil nil org-ascii-links-to-notes)
+    (:ascii-list-margin nil nil org-ascii-list-margin)
     (:ascii-paragraph-spacing nil nil org-ascii-paragraph-spacing)
     (:ascii-quote-margin nil nil org-ascii-quote-margin)
     (:ascii-table-keep-all-vertical-lines
@@ -184,6 +185,15 @@ This margin is applied on both sides of the text."
   :package-version '(Org . "8.0")
   :type 'integer)
 
+(defcustom org-ascii-list-margin 0
+  "Width of margin used for plain lists, in characters.
+This margin applies to top level list only, not to its
+sub-lists."
+  :group 'org-export-ascii
+  :version "24.5"
+  :package-version '(Org . "8.3")
+  :type 'integer)
+
 (defcustom org-ascii-inlinetask-width 30
   "Width of inline tasks, in number of characters.
 This number ignores any margin."
@@ -581,6 +591,15 @@ INFO is a plist used as a communication channel."
 				 '(quote-block verse-block))
 		      count parent)
 		2 (plist-get info :ascii-quote-margin))
+	     ;; Apply list margin once per "top-level" plain-list
+	     ;; containing current line
+	     (* (let ((count 0))
+		  (dolist (e genealogy count)
+		    (and (eq (org-element-type e) 'plain-list)
+			 (not (eq (org-element-type (org-export-get-parent e))
+				  'item))
+			 (incf count))))
+		(plist-get info :ascii-list-margin))
 	     ;; Text width within a plain-list is restricted by
 	     ;; indentation of current item.  If that's the case,
 	     ;; compute it with the help of `:structure' property from
@@ -1558,7 +1577,11 @@ the plist used as a communication channel."
   "Transcode a PLAIN-LIST element from Org to ASCII.
 CONTENTS is the contents of the list.  INFO is a plist holding
 contextual information."
-  contents)
+  (let ((margin (plist-get info :ascii-list-margin)))
+    (if (or (< margin 1)
+	    (eq (org-element-type (org-export-get-parent plain-list)) 'item))
+	contents
+      (org-ascii--indent-string contents margin))))
 
 
 ;;;; Plain Text

+ 2 - 1
lisp/ox-latex.el

@@ -1982,7 +1982,8 @@ INFO is a plist holding contextual information.  See
 			     #'number-to-string
 			     (org-export-get-headline-number destination info)
 			     "-")))))
-	     (if (and (plist-get info :section-numbers) (not desc))
+	     (if (and (not desc)
+		      (org-export-numbered-headline-p destination info))
 		 (format "\\ref{%s}" label)
 	       (format "\\hyperref[%s]{%s}" label
 		       (or desc

+ 3 - 3
testing/lisp/test-ob-exp.el

@@ -342,7 +342,6 @@ be evaluated."
 			    result)))))
 
 (ert-deftest ob-exp/export-from-a-temp-buffer ()
-  :expected-result :failed
   (org-test-with-temp-text
       "
 #+Title: exporting from a temporary buffer
@@ -362,8 +361,9 @@ be evaluated."
 #+END_SRC
 "
     (let* ((ascii (org-export-as 'ascii)))
-      (should (string-match (regexp-quote (format nil "%S" '(:foo :bar)))
-			    ascii)))))
+      (should (string-match
+	       (regexp-quote " :foo  :bar \n")
+			     ascii)))))
 
 (ert-deftest ob-export/export-with-results-before-block ()
   "Test export when results are inserted before source block."

+ 33 - 2
testing/lisp/test-ob-ruby.el

@@ -21,7 +21,7 @@
 (unless (featurep 'ob-ruby)
   (signal 'missing-test-dependency "Support for Ruby code blocks"))
 
-(ert-deftest test-ob-ruby/session-output ()
+(ert-deftest test-ob-ruby/session-output-1 ()
     (should (equal (org-test-with-temp-text "#+begin_src ruby :session :results output
 s = \"1\"
 s = \"2\"
@@ -39,9 +39,40 @@ puts s
 #+end_src
 
 #+RESULTS:
-: 
 : 3
 
+")))
+(ert-deftest test-ob-ruby/session-output-2 ()
+    (should (equal (org-test-with-temp-text "#+begin_src ruby :session :results output
+s = \"5\"
+puts s
+#+end_src"
+  (org-ctrl-c-ctrl-c)
+  (substring-no-properties
+   (buffer-string)))
+		   "#+begin_src ruby :session :results output
+s = \"5\"
+puts s
+#+end_src
+
+#+RESULTS:
+: 5
+
+")))
+(ert-deftest test-ob-ruby/session-output-3 ()
+    (should (equal (org-test-with-temp-text "#+begin_src ruby :session :results output
+puts s
+#+end_src"
+  (org-ctrl-c-ctrl-c)
+  (substring-no-properties
+   (buffer-string)))
+		   "#+begin_src ruby :session :results output
+puts s
+#+end_src
+
+#+RESULTS:
+: 5
+
 ")))
 
 (provide 'test-ob-ruby)