Org-Mode 9.3.1

-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEG+FaXQip1ZWVgUdrFDesAvc/kaIFAl4E+QkACgkQFDesAvc/
 kaJ7MAgAlY9s0UZ1eSpB1TfYLRR0+wL6LpqcCuPV2A8dK7hZKG1cZw1RiSxt2hf2
 gtw9M81M+xHjbB7kGCrzE6nti30BqWvtKCRhQCxtypG572yKiyvWYbmBux6oFduN
 PTRv17EFZ+5H7RA4tjZB95zjpTpi6IS4yaUvN2Lobd8zMeDV1lWV/qNu8/Di6BbK
 KM1V6GFLjj/wvIvATiWqXBx0VVI4WnjnZWTRGjE3+vMen5s3+1mnLtpFr1Kx1WaV
 EnhKgnOehzYshOM3k36xIvOu5e4vcaohJfe+DItSk+I9LSlQXgjV2S6NoayvSMta
 M6VXxzEwf9Q8O9iL1/+vhS1DryOSqQ==
 =R6YA
 -----END PGP SIGNATURE-----

Merge tag 'release_9.3.1' into emacs-sync

Org-Mode 9.3.1

# gpg: Signature made Thu 26 Dec 2019 01:16:41 PM EST
# gpg:                using RSA key 1BE15A5D08A9D5959581476B1437AC02F73F91A2
# gpg: Can't check signature: No public key
This commit is contained in:
Kyle Meyer 2019-12-29 10:52:52 -05:00
commit 84f72ac69d
23 changed files with 520 additions and 521 deletions

View File

@ -64,7 +64,7 @@
(interactive "MScreen name: ")
(save-excursion
(org-screen-helper name "-S"))
(insert-string (concat "[[screen:" name "]]")))
(insert (concat "[[screen:" name "]]")))
(defun org-screen-buffer-name (name)
"Returns the buffer name corresponding to the screen name given."

File diff suppressed because it is too large Load Diff

View File

@ -19,15 +19,11 @@ Org used to percent-encode sensitive characters in the URI part of the
bracket links.
Now, escaping mechanism uses the usual backslash character, according
to the following rules, applied in order:
to the following rules:
1. All consecutive =\= characters at the end of the link must be
escaped;
2. Any =]= character at the very end of the link must be escaped;
3. All consecutive =\= characters preceding =][= or =]]= patterns must
be escaped;
4. Any =]= character followed by either =[= or =]= must be escaped;
5. Others =]= and =\= characters need not be escaped.
1. All =[= and =]= characters in the URI must be escaped;
2. Every =\= character preceding either =[= or =]= must be escaped;
3. Every =\= character at the end of the URI must be escaped.
When in doubt, use the function ~org-link-escape~ in order to turn
a link string into its properly escaped form.
@ -92,7 +88,7 @@ the message to 30 characters in order to build the description of the
link. This behavior was considered as too surprising. As
a consequence, Org no longer truncates subjects.
You can get the old behaviour back with the following:
You can get the old behavior back with the following:
: (setq org-email-link-description-format "Email %c: %.30s")
@ -170,7 +166,7 @@ From now on inheritance requires no extra property and will adhere to
customized to always be activated or never be activated in
~org-attach-use-inheritance~.
The ATTACH_DIR property is deprecated in favour of the shorter
The ATTACH_DIR property is deprecated in favor of the shorter
property DIR. Links to folders inside the DIR property can now be
declared as relative links. This is not enabled by default, but can
be set in ~org-attach-dir-relative~.
@ -178,7 +174,7 @@ be set in ~org-attach-dir-relative~.
When adding new attachment to the outline node the preferred way of
doing so can be customized. Take a look at
~org-attach-preferred-new-method~. It defaults to using ID since that
was the behaviour before this change.
was the behavior before this change.
If both DIR and ID properties are set on the same node, DIR has
precedence and will be used.
@ -311,7 +307,7 @@ matches the same structures than 'latex but it calls
org-src-font-lock-fontify-block instead, thus bringing about full
LaTeX font locking.
*** ~org-clone-subtree-with-time-shift~ learnt to shift backward in time
*** ~org-clone-subtree-with-time-shift~ learned to shift backward in time
=<C-c C-x c>= (~org-clone-subtree-with-time-shift~) now takes a
negative value as a valid repeater to shift time stamps in backward
@ -335,7 +331,7 @@ parameters in ~sql-connection-alist~.
The builtin "latex" exporters now accept and use a =:scale= attribute,
which scales an image by a given factor.
This attribute is wrapped adound the =scale= parameter of LaTeX's
This attribute is wrapped around the =scale= parameter of LaTeX's
=\includegraphics= (bitmap images) or a TiKZ's =\scalebox=.
Therefore, its value should be some string palatable to LaTeX as
a positive float Its default value is an empty string (i.e. disabled).
@ -386,7 +382,7 @@ You can install it back from MELPA.
*** ~org-capture-insert-template-here~
*** ~org-attach-directory~
It has been deprecated in favour of ~org-attach-id-dir~ which is less
It has been deprecated in favor of ~org-attach-id-dir~ which is less
ambiguous given the restructured org-attach.
*** ~org-enable-fixed-width-editor~
@ -612,7 +608,7 @@ document, use =shrink= value instead, or in addition to align:
Function ~org-get-tags~ used to return local tags to the current
headline. It now returns all the inherited tags in addition to the
local tags. In order to get the old behaviour back, you can use:
local tags. In order to get the old behavior back, you can use:
: (org-get-tags nil t)

View File

@ -29,6 +29,13 @@
(require 'ob)
(require 'eshell)
(declare-function eshell-send-input "esh-mode"
(&optional use-region queue-p no-newline))
(defvar eshell-last-output-start)
(defvar eshell-last-output-end)
(defvar eshell-last-input-end)
(defvar org-babel-default-header-args:eshell '())
(defun org-babel-execute:eshell (body params)

View File

@ -69,10 +69,11 @@ function to convert variables to PlantUML assignments.
If BODY does not contain @startXXX ... @endXXX clauses, @startuml
... @enduml will be added."
(let ((assignments (org-babel-variable-assignments:plantuml params)))
(if (string-prefix-p "@start" body t) assignments
(format "@startuml\n%s\n@enduml"
(org-babel-expand-body:generic body params assignments)))))
(let ((full-body
(org-babel-expand-body:generic
body params (org-babel-variable-assignments:plantuml params))))
(if (string-prefix-p "@start" body t) full-body
(format "@startuml\n%s\n@enduml" full-body))))
(defun org-babel-execute:plantuml (body params)
"Execute a block of plantuml code with org-babel.

View File

@ -716,12 +716,10 @@ This should be called after the variable `org-link-parameters' has changed."
(rx (seq "[["
;; URI part: match group 1.
(group
;; Allow an even number of backslashes right
;; before the closing bracket.
(or (one-or-more "\\\\")
(and (*? anything)
(not (any "\\"))
(zero-or-more "\\\\"))))
(one-or-more
(or (not (any "[]\\"))
(and "\\" (zero-or-more "\\\\") (any "[]"))
(and (one-or-more "\\") (not (any "[]"))))))
"]"
;; Description (optional): match group 2.
(opt "[" (group (+? anything)) "]")
@ -838,30 +836,21 @@ E.g. \"%C3%B6\" becomes the german o-Umlaut."
(defun org-link-escape (link)
"Backslash-escape sensitive characters in string LINK."
;; Escape closing square brackets followed by another square bracket
;; or at the end of the link. Also escape final backslashes so that
;; we do not escape inadvertently URI's closing bracket.
(with-temp-buffer
(insert link)
(insert (make-string (- (skip-chars-backward "\\\\"))
?\\))
(while (search-backward "\]" nil t)
(when (looking-at-p "\\]\\(?:[][]\\|\\'\\)")
(insert (make-string (1+ (- (skip-chars-backward "\\\\")))
?\\))))
(buffer-string)))
(replace-regexp-in-string
(rx (seq (group (zero-or-more "\\")) (group (or string-end (any "[]")))))
(lambda (m)
(concat (match-string 1 m)
(match-string 1 m)
(and (/= (match-beginning 2) (match-end 2)) "\\")))
link nil t 1))
(defun org-link-unescape (link)
"Remove escaping backslash characters from string LINK."
(with-temp-buffer
(save-excursion (insert link))
(while (re-search-forward "\\(\\\\+\\)\\]\\(?:[][]\\|\\'\\)" nil t)
(replace-match (make-string (/ (- (match-end 1) (match-beginning 1)) 2)
?\\)
nil t nil 1))
(goto-char (point-max))
(delete-char (/ (- (skip-chars-backward "\\\\")) 2))
(buffer-string)))
(replace-regexp-in-string
(rx (group (one-or-more "\\")) (or string-end (any "[]")))
(lambda (_)
(concat (make-string (/ (- (match-end 1) (match-beginning 1)) 2) ?\\)))
link nil t 1))
(defun org-link-make-string (link &optional description)
"Make a bracket link, consisting of LINK and DESCRIPTION.

View File

@ -5135,6 +5135,7 @@ of what a project is and how to check if it stuck, customize the variable
(cons 'org-diary-default-entry diary-list-entries-hook))
(diary-file-name-prefix nil) ; turn this feature off
(diary-modify-entry-list-string-function 'org-modify-diary-entry-string)
(diary-time-regexp (concat "^" diary-time-regexp))
entries
(org-disable-agenda-to-diary t))
(save-excursion
@ -7636,7 +7637,7 @@ and deselects entries with tag `John' or matching the regexp `plot'.
During entry of the filter, completion for tags, categories and effort
values is offered. Since the syntax for categories and tags is identical
there should be no overlap between categoroes and tags. If there is, tags
there should be no overlap between categories and tags. If there is, tags
get priority.
A single `\\[universal-argument]' prefix arg STRIP-OR-ACCUMULATE will negate the
@ -7670,7 +7671,7 @@ the variable `org-agenda-auto-exclude-function'."
(if negate "Negative filter" "Filter")
" [+cat-tag<0:10-/regexp/]: ")
'org-agenda-filter-completion-function))
(keep (or (if (string-match "^+[-+]" f-string)
(keep (or (if (string-match "^\\+[+-]" f-string)
(progn (setq f-string (substring f-string 1)) t))
(equal strip-or-accumulate '(16))))
(fc (if keep org-agenda-category-filter))

View File

@ -187,7 +187,7 @@ attachment folders based on ID."
"Hook that is invoked by `org-attach-open'.
Created mostly to be compatible with org-attach-git after removing
git-funtionality from this file.")
git-functionality from this file.")
(defcustom org-attach-commands
'(((?a ?\C-a) org-attach-attach
@ -231,7 +231,7 @@ directory in dired and delete from there.\n")
Each entry in this list is a list of three elements:
- A list of keys (characters) to select the command (the fist
character in the list is shown in the attachment dispatcher's
splash buffer and minubuffer prompt).
splash buffer and minibuffer prompt).
- A command that is called interactively when one of these keys
is pressed.
- A docstring for this command in the attachment dispatcher's

View File

@ -698,21 +698,19 @@ of the day at point (if any) or the current HH:MM time."
(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)))
(org-capture-put
:template
(pcase (org-capture-get :template)
(`nil "")
((and (pred stringp) template) template)
(`(file ,file)
(let ((filename (expand-file-name file org-directory)))
(if (file-exists-p filename) (org-file-contents filename)
(format "* Template file %S not found" file))))
(`(function ,f)
(if (functionp f) (funcall f)
(format "* Template function %S not found" f)))
(_ "* Invalid capture template"))))
(defun org-capture-finalize (&optional stay-with-capture)
"Finalize the capture process.

View File

@ -27,6 +27,8 @@
;;; Code:
(require 'cl-lib)
(defvar org-outline-regexp)
(declare-function org-add-note "org" ())
@ -218,6 +220,8 @@
(defvar org-mode-map (make-sparse-keymap)
"Keymap fo Org mode.")
(defvaralias 'org-CUA-compatible 'org-replace-disputed-keys)
(defcustom org-replace-disputed-keys nil
"Non-nil means use alternative key bindings for some keys.
@ -244,8 +248,6 @@ loading Org."
:type 'boolean
:safe #'booleanp)
(defvaralias 'org-CUA-compatible 'org-replace-disputed-keys)
(defcustom org-disputed-keys
'(([(shift up)] . [(meta p)])
([(shift down)] . [(meta n)])

View File

@ -86,7 +86,6 @@
(defvar org-clock-string)
(defvar org-closed-string)
(defvar org-deadline-string)
(defvar org-description-max-indent)
(defvar org-done-keywords)
(defvar org-drawer-regexp)
(defvar org-element-all-objects)

View File

@ -1709,7 +1709,7 @@ The function assumes `org-table-copy-increment' is non-nil."
(number-suffix-regexp (rx (and (one-or-more digit) string-end)))
(analyze
(lambda (field)
;; Analyse string FIELD and return information related to
;; Analyze string FIELD and return information related to
;; increment or nil. When non-nil, return value has the
;; following scheme: (TYPE VALUE PATTERN) where
;; - TYPE is a symbol among `number', `prefix', `suffix'
@ -4642,7 +4642,7 @@ blank, and the content is appended to the field above."
(skip-chars-backward " ")
(insert " " (org-trim s))
(org-table-align)))
((looking-at "\\([^|]+\\)+|") ; Split field.
((looking-at "\\([^|]+\\)|") ; Split field.
(let ((s (match-string 1)))
(replace-match " |")
(goto-char (match-beginning 0))

View File

@ -6,7 +6,7 @@
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: https://orgmode.org
;; Version: 9.3
;; Version: 9.3.1
;;
;; This file is part of GNU Emacs.
;;
@ -4955,7 +4955,8 @@ The following commands are available:
("8.3" . "26.1")
("9.0" . "26.1")
("9.1" . "26.1")
("9.2" . "27.1")))
("9.2" . "27.1")
("9.3" . "27.1")))
(defvar org-mode-transpose-word-syntax-table
(let ((st (make-syntax-table text-mode-syntax-table)))
@ -5249,7 +5250,15 @@ by a #."
"Fontify #+ lines and blocks."
(let ((case-fold-search t))
(when (re-search-forward
"^\\([ \t]*#\\(\\(\\+[a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\(\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)\\)"
(rx bol (group (zero-or-more blank) "#"
(group (group (or (seq "+" (one-or-more (any "a-zA-Z")) (optional ":"))
space
eol))
(optional (group "_" (group (one-or-more (any "a-zA-Z"))))))
(zero-or-more blank)
(group (group (zero-or-more (not (any " \t\n"))))
(zero-or-more blank)
(group (zero-or-more any)))))
limit t)
(let ((beg (match-beginning 0))
(end-of-beginline (match-end 0))
@ -5267,7 +5276,12 @@ by a #."
(setq block-type (downcase (match-string 5))
quoting (member block-type org-protecting-blocks)) ; src, example, export, maybe more
(when (re-search-forward
(concat "^[ \t]*#\\+end" (match-string 4) "\\>.*")
(rx-to-string `(group bol (or (seq (one-or-more "*") space)
(seq (zero-or-more blank)
"#+end"
,(match-string 4)
word-end
(zero-or-more any)))))
nil t) ;; on purpose, we look further than LIMIT
;; We do have a matching #+end line
(setq beg-of-endline (match-beginning 0)
@ -5306,10 +5320,14 @@ by a #."
(add-text-properties
beg (if whole-blockline bol-after-beginline end-of-beginline)
'(face org-block-begin-line))
(add-text-properties
beg-of-endline
(min (point-max) (if whole-blockline (min (point-max) (1+ end-of-endline)) end-of-endline))
'(face org-block-end-line))
(unless (string-prefix-p "*" (match-string 1))
(add-text-properties
beg-of-endline
(if whole-blockline
(let ((beg-of-next-line (1+ end-of-endline)))
(min (point-max) beg-of-next-line))
(min (point-max) end-of-endline))
'(face org-block-end-line)))
t))
((member dc1 '("+title:" "+author:" "+email:" "+date:"))
(org-remove-flyspell-overlays-in
@ -5332,7 +5350,11 @@ by a #."
;; Handle short captions.
(save-excursion
(beginning-of-line)
(looking-at "\\([ \t]*#\\+caption\\(?:\\[.*\\]\\)?:\\)[ \t]*"))
(looking-at (rx (group (zero-or-more blank)
"#+caption"
(optional "[" (zero-or-more any) "]")
":")
(zero-or-more blank))))
(add-text-properties (line-beginning-position) (match-end 1)
'(font-lock-fontified t face org-meta-line))
(add-text-properties (match-end 0) (line-end-position)
@ -7825,7 +7847,7 @@ with the original repeater."
""))) ;No time shift
(doshift
(and (org-string-nw-p shift)
(or (string-match "\\`[ \t]*\\([\\+\\-]?[0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
(or (string-match "\\`[ \t]*\\([+-]?[0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
shift)
(user-error "Invalid shift specification %s" shift)))))
(goto-char end-of-tree)
@ -9854,9 +9876,9 @@ Elements of length one have a tab appended. Elements of length
two are kept as is. Longer elements are truncated to length two.
If an element cannot be made unique, an error is raised."
(let ((orderd-keys (cl-sort (copy-sequence keys) #'< :key #'length))
(let ((ordered-keys (cl-sort (copy-sequence keys) #'< :key #'length))
menu-keys)
(dolist (key orderd-keys)
(dolist (key ordered-keys)
(let ((potential-key
(cl-case (length key)
(1 (concat key "\t"))
@ -10008,7 +10030,7 @@ By default the available states are \"TODO\" and \"DONE\". So, for this
example: when the item starts with TODO, it is changed to DONE.
When it starts with DONE, the DONE is removed. And when neither TODO nor
DONE are present, add TODO at the beginning of the heading.
You can set up single-charcter keys to fast-select the new state. See the
You can set up single-character keys to fast-select the new state. See the
`org-todo-keywords' and `org-use-fast-todo-selection' for details.
With `\\[universal-argument]' prefix ARG, force logging the state change \
@ -16499,12 +16521,16 @@ a HTML file."
(setq bg (org-latex-color :background))
(setq bg (org-latex-color-format
(if (string= bg "Transparent") "white" bg))))
;; Remove TeX \par at end of snippet to avoid trailing space.
(if (string-suffix-p string "\n")
(aset string (1- (length string)) ?%)
(setq string (concat string "%")))
(with-temp-file texfile
(insert latex-header)
(insert "\n\\begin{document}\n"
"\\definecolor{fg}{rgb}{" fg "}\n"
"\\definecolor{bg}{rgb}{" bg "}\n"
"\n\\pagecolor{bg}\n"
"\\definecolor{fg}{rgb}{" fg "}%\n"
"\\definecolor{bg}{rgb}{" bg "}%\n"
"\n\\pagecolor{bg}%\n"
"\n{\\color{fg}\n"
string
"\n}\n"

View File

@ -2903,6 +2903,12 @@ used as a predicate for `org-export-get-ordinal' or a value to
(string-match-p org-latex-math-environments-re
(org-element-property :value element)))
(defun org-html--latex-environment-numbered-p (element)
"Non-nil when ELEMENT contains a numbered LaTeX math environment.
Starred and \"displaymath\" environments are not numbered."
(not (string-match-p "\\`[ \t]*\\\\begin{\\(.*\\*\\|displaymath\\)}"
(org-element-property :value element))))
(defun org-html--unlabel-latex-environment (latex-frag)
"Change environment in LATEX-FRAG string to an unnumbered one.
For instance, change an 'equation' environment to 'equation*'."
@ -2923,10 +2929,13 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(attributes (org-export-read-attribute :attr_html latex-environment))
(label (and (org-element-property :name latex-environment)
(org-export-get-reference latex-environment info)))
(caption (number-to-string
(org-export-get-ordinal
latex-environment info nil
#'org-html--math-environment-p))))
(caption (and (org-html--latex-environment-numbered-p latex-environment)
(number-to-string
(org-export-get-ordinal
latex-environment info nil
(lambda (l _)
(and (org-html--math-environment-p l)
(org-html--latex-environment-numbered-p l))))))))
(cond
((memq processing-type '(t mathjax))
(org-html-format-latex

View File

@ -2425,7 +2425,8 @@ used as a communication channel."
(format "\\resizebox{%s}{%s}{%s}"
(if (org-string-nw-p width) width "!")
(if (org-string-nw-p height) height "!")
image-code)))))
image-code))
(t image-code))))
;; For other images:
;; - add scale, or width and height to options.
;; - include the image with \includegraphics.

View File

@ -1383,6 +1383,8 @@ original parsed data. INFO is a plist holding export options."
;; create a manifest entry for styles.xml
(org-odt-create-manifest-file-entry "text/xml" "styles.xml")
;; Ensure we have write permissions to this file.
(set-file-modes (concat org-odt-zip-dir "styles.xml") #o600)
;; FIXME: Who is opening an empty styles.xml before this point?
(with-current-buffer

View File

@ -6929,7 +6929,7 @@ options as CDR."
(org-export--dispatch-ui options first-key expertp))
;; q key at first level aborts export. At second level, cancel
;; first key instead.
((eq key ?q) (if (not first-key) (error "Export aborted")
((eq key ?q) (if (not first-key) (user-error "Export aborted")
(org-export--dispatch-ui options nil expertp)))
;; Help key: Switch back to standard interface if expert UI was
;; active.

View File

@ -38,7 +38,7 @@ ORGFULL = README COPYING lisp/ \
etc/ contrib/ doc/ testing/
ORGFULL := $(ORGFULL:%/=%/*)
ORGELPA = README_ELPA COPYING etc/ORG-NEWS lisp/ \
doc/dir doc/org doc/orgcard.pdf \
doc/dir doc/org doc/orgguide doc/orgcard.pdf \
etc/styles/ org-pkg.el
ORGELPA := $(ORGELPA:%/=%/*)
ORGELPAPLUS := $(ORGELPA:org-pkg%=org-plus-contrib-pkg%)

View File

@ -24,7 +24,9 @@
(signal 'missing-test-dependency "Support for Python code blocks"))
(ert-deftest test-ob-python/colnames-yes-header-argument ()
(org-test-with-temp-text "#+name: eg
(should
(equal '(("col") hline ("a") ("b"))
(org-test-with-temp-text "#+name: eg
| col |
|-----|
| a |
@ -32,30 +34,30 @@
#+header: :colnames yes
#+header: :var x = eg
#+begin_src python
<point>#+begin_src python
return x
#+end_src"
(org-babel-next-src-block)
(should (equal '(("col") hline ("a") ("b"))
(org-babel-execute-src-block)))))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-yes-header-argument-again ()
(org-test-with-temp-text "#+name: less-cols
(should
(equal '(("a") hline ("b*") ("c*"))
(org-test-with-temp-text "#+name: less-cols
| a |
|---|
| b |
| c |
#+header: :colnames yes
#+begin_src python :var tab=less-cols
<point>#+begin_src python :var tab=less-cols
return [[val + '*' for val in row] for row in tab]
#+end_src"
(org-babel-next-src-block)
(should (equal '(("a") hline ("b*") ("c*"))
(org-babel-execute-src-block)))))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-nil-header-argument ()
(org-test-with-temp-text "#+name: eg
(should
(equal '(("col") hline ("a") ("b"))
(org-test-with-temp-text "#+name: eg
| col |
|-----|
| a |
@ -63,30 +65,30 @@ return x
#+header: :colnames nil
#+header: :var x = eg
#+begin_src python
<point>#+begin_src python
return x
#+end_src"
(org-babel-next-src-block)
(should (equal '(("col") hline ("a") ("b"))
(org-babel-execute-src-block)))))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-no-header-argument-again ()
(org-test-with-temp-text "#+name: less-cols
(should
(equal '(("a*") ("b*") ("c*"))
(org-test-with-temp-text "#+name: less-cols
| a |
|---|
| b |
| c |
#+header: :colnames no
#+begin_src python :var tab=less-cols
<point>#+begin_src python :var tab=less-cols
return [[val + '*' for val in row] for row in tab]
#+end_src"
(org-babel-next-src-block)
(should (equal '(("a*") ("b*") ("c*"))
(org-babel-execute-src-block)))))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-no-header-argument ()
(org-test-with-temp-text "#+name: eg
(should
(equal '(("col") ("a") ("b"))
(org-test-with-temp-text "#+name: eg
| col |
|-----|
| a |
@ -94,19 +96,18 @@ return x
#+header: :colnames no
#+header: :var x = eg
#+begin_src python
<point>#+begin_src python
return x
#+end_src"
(org-babel-next-src-block)
(should (equal '(("col") ("a") ("b"))
(org-babel-execute-src-block)))))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/session-multiline ()
;; FIXME workaround to prevent starting prompt leaking into output
(run-python)
(sleep-for 0 10)
(org-test-with-temp-text "
#+begin_src python :session :results output
(should
(equal "20"
(org-test-with-temp-text "#+begin_src python :session :results output
foo = 0
for _ in range(10):
foo += 1
@ -115,26 +116,28 @@ return x
print(foo)
#+end_src"
(org-babel-next-src-block)
(should (equal "20" (org-babel-execute-src-block)))))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/insert-necessary-blank-line-when-sending-code-to-interpreter ()
(org-test-with-temp-text "#+begin_src python :session :results value
(should
(equal 2 (org-test-with-temp-text "#+begin_src python :session :results value
if True:
1
2
#+end_src"
;; Previously, while adding `:session' to a normal code block, also need to add extra blank lines
;; to end indent block or indicate logical sections. Now, the `org-babel-python-evaluate-session'
;; can do it automatically:
;; >>> if True:
;; >>> 1
;; >>> <insert_blank_line_here>
;; >>> 2
(org-babel-execute-maybe)
(should (equal 2 (org-babel-execute-src-block)))))
;; Previously, while adding `:session' to a normal code
;; block, also need to add extra blank lines to end
;; indent block or indicate logical sections. Now, the
;; `org-babel-python-evaluate-session' can do it
;; automatically:
;;
;; >>> if True:
;; >>> 1
;; >>> <insert_blank_line_here>
;; >>> 2
(org-babel-execute-maybe)
(org-babel-execute-src-block)))))
(provide 'test-ob-python)
;;; test-ob-python.el ends here

View File

@ -55,49 +55,48 @@
(ert-deftest test-ol/escape ()
"Test `org-link-escape' specifications."
;; No-op when there is no backslash or closing square bracket.
(should (string= "foo[" (org-link-escape "foo[")))
;; Escape closing square bracket at the end of the link.
(should (string= "[foo\\]" (org-link-escape "[foo]")))
;; Escape closing square brackets followed by another square
;; bracket.
(should (string= "foo\\][bar" (org-link-escape "foo][bar")))
(should (string= "foo\\]]bar" (org-link-escape "foo]]bar")))
;; However, escaping closing square bracket at the end of the link
;; has precedence over the previous rule.
(should (string= "foo]\\]" (org-link-escape "foo]]")))
;; No-op when there is no backslash or square bracket.
(should (string= "foo" (org-link-escape "foo")))
;; Escape square brackets at boundaries of the link.
(should (string= "\\[foo\\]" (org-link-escape "[foo]")))
;; Escape square brackets followed by another square bracket.
(should (string= "foo\\]\\[bar" (org-link-escape "foo][bar")))
(should (string= "foo\\]\\]bar" (org-link-escape "foo]]bar")))
(should (string= "foo\\[\\[bar" (org-link-escape "foo[[bar")))
(should (string= "foo\\[\\]bar" (org-link-escape "foo[]bar")))
;; Escape backslashes at the end of the link.
(should (string= "foo\\\\" (org-link-escape "foo\\")))
;; Escape backslashes that could be confused with escaping
;; characters.
(should (string= "foo\\\\\\]" (org-link-escape "foo\\]")))
(should (string= "foo\\\\\\][" (org-link-escape "foo\\][")))
(should (string= "foo\\\\\\]]bar" (org-link-escape "foo\\]]bar")))
(should (string= "foo\\\\\\]\\[" (org-link-escape "foo\\][")))
(should (string= "foo\\\\\\]\\]bar" (org-link-escape "foo\\]]bar")))
;; Do not escape backslash characters when unnecessary.
(should (string= "foo\\bar" (org-link-escape "foo\\bar")))
(should (string= "foo\\]bar" (org-link-escape "foo\\]bar")))
;; Pathological cases: consecutive closing square brackets.
(should (string= "[[[foo\\]]\\]" (org-link-escape "[[[foo]]]")))
(should (string= "[[[foo]\\]] bar" (org-link-escape "[[[foo]]] bar"))))
(should (string= "\\[\\[\\[foo\\]\\]\\]" (org-link-escape "[[[foo]]]")))
(should (string= "\\[\\[foo\\]\\] bar" (org-link-escape "[[foo]] bar"))))
(ert-deftest test-ol/unescape ()
"Test `org-link-unescape' specifications."
;; No-op if there is no backslash.
(should (string= "foo[" (org-link-unescape "foo[")))
(should (string= "foo" (org-link-unescape "foo")))
;; No-op if backslashes are not escaping backslashes.
(should (string= "foo\\bar" (org-link-unescape "foo\\bar")))
(should (string= "foo\\]bar" (org-link-unescape "foo\\]bar")))
;;
;; Unescape backslashes before square brackets.
(should (string= "foo]bar" (org-link-unescape "foo\\]bar")))
(should (string= "foo\\]" (org-link-unescape "foo\\\\\\]")))
(should (string= "foo\\][" (org-link-unescape "foo\\\\\\][")))
(should (string= "foo\\]]bar" (org-link-unescape "foo\\\\\\]]bar")))
(should (string= "foo\\]]bar" (org-link-unescape "foo\\\\\\]\\]bar")))
(should (string= "foo\\[[bar" (org-link-unescape "foo\\\\\\[\\[bar")))
(should (string= "foo\\[]bar" (org-link-unescape "foo\\\\\\[\\]bar")))
;; Unescape backslashes at the end of the link.
(should (string= "foo\\" (org-link-unescape "foo\\\\")))
;; Unescape closing square bracket at the end of the link.
(should (string= "[foo]" (org-link-unescape "[foo\\]")))
;; Unescape closing square bracket at boundaries of the link.
(should (string= "[foo]" (org-link-unescape "\\[foo\\]")))
;; Pathological cases: consecutive closing square brackets.
(should (string= "[[[foo]]]" (org-link-unescape "[[[foo\\]]\\]")))
(should (string= "[[[foo]]] bar" (org-link-unescape "[[[foo]\\]] bar"))))
(should (string= "[[[foo]]]" (org-link-unescape "\\[\\[\\[foo\\]\\]\\]")))
(should (string= "[[foo]] bar" (org-link-unescape "\\[\\[foo\\]\\] bar"))))
(ert-deftest test-ol/make-string ()
"Test `org-link-make-string' specifications."
@ -204,11 +203,11 @@
;; Store file link to non-Org buffer, with context.
(should
(let ((org-stored-links nil)
(org-context-in-file-links t))
(org-link-context-for-files t))
(org-test-with-temp-text-in-file "one\n<point>two"
(fundamental-mode)
(let ((file (buffer-file-name)))
(equal (format "[[file:%s::one]]" file)
(equal (format "[[file:%s::two]]" file)
(org-store-link nil))))))
;; Store file link to non-Org buffer, without context.
(should
@ -223,11 +222,11 @@
;; buffer.
(should
(let ((org-stored-links nil)
(org-context-in-file-links nil))
(org-link-context-for-files nil))
(org-test-with-temp-text-in-file "one\n<point>two"
(fundamental-mode)
(let ((file (buffer-file-name)))
(equal (format "[[file:%s::one]]" file)
(equal (format "[[file:%s::two]]" file)
(org-store-link '(4)))))))
;; A C-u C-u does *not* reverse `org-context-in-file-links' in
;; non-Org buffer.

View File

@ -576,129 +576,87 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
"Test \":link\" parameter in Clock table."
;; If there is no file attached to the document, link directly to
;; the headline.
(let (org-link-descriptive)
(should
(equal
"| Headline | Time |
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo
(should
(string-match-p "| +\\[\\[Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
"* Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t"))))
;; Otherwise, link to the headline in the current file.
(should
(equal
"| Headline | Time |
|-----------------------------+---------|
| *Total time* | *26:00* |
|-----------------------------+---------|
| [[file:filename::Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
(org-test-with-temp-text-in-file
"* Foo
(test-org-clock-clocktable-contents ":link t"))))
;; Otherwise, link to the headline in the current file.
(should
(string-match-p
"| \\[\\[file:filename::Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
(org-test-with-temp-text-in-file
"* Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(let ((file (buffer-file-name)))
(replace-regexp-in-string
(regexp-quote file) "filename"
(test-org-clock-clocktable-contents ":link t :lang en"))))
(org-table-align)
(buffer-substring-no-properties (point-min) (point-max)))))
;; Ignore TODO keyword, priority cookie, COMMENT and tags in
;; headline.
(should
(equal
"| Headline | Time |
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* TODO Foo
(let ((file (buffer-file-name)))
(replace-regexp-in-string
(regexp-quote file) "filename"
(test-org-clock-clocktable-contents ":link t :lang en"))))
(org-table-align)
(buffer-substring-no-properties (point-min) (point-max)))))
;; Ignore TODO keyword, priority cookie, COMMENT and tags in
;; headline.
(should
(string-match-p
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
"* TODO Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(equal
"| Headline | Time |
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* [#A] Foo
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(string-match-p
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
"* [#A] Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(equal
"| Headline | Time |
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* COMMENT Foo
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(string-match-p
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
"* COMMENT Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t"))))
(should
(equal
"| Headline | Time |
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo :tag:
(test-org-clock-clocktable-contents ":link t"))))
(should
(string-match-p
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
"* Foo :tag:
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en"))))
;; Remove statistics cookie from headline description.
(should
(equal
"| Headline | Time |
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo [50%]
(test-org-clock-clocktable-contents ":link t :lang en"))))
;; Remove statistics cookie from headline description.
(should
(string-match-p
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
"* Foo [50%]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(equal
"| Headline | Time |
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo [1/2]
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(string-match-p
"| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
(org-test-with-temp-text
"* Foo [1/2]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en"))))
;; Replace links with their description, or turn them into plain
;; links if there is no description.
(should
(equal
"| Headline | Time |
|-----------------------------------------------------------+---------|
| *Total time* | *26:00* |
|-----------------------------------------------------------+---------|
| [[Foo [[https://orgmode.org\\][Org mode]\\]][Foo Org mode]] | 26:00 |"
(org-test-with-temp-text
"* Foo [[https://orgmode.org][Org mode]]
(test-org-clock-clocktable-contents ":link t :lang en"))))
;; Replace links with their description, or turn them into plain
;; links if there is no description.
(should
(string-match-p
"| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\\\[Org mode\\\\]\\\\]]\\[Foo Org mode]] +| 26:00 +|"
(org-test-with-temp-text
"* Foo [[https://orgmode.org][Org mode]]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(equal
"| Headline | Time |
|-----------------------------------------------------------+---------|
| *Total time* | *26:00* |
|-----------------------------------------------------------+---------|
| [[Foo [[https://orgmode.org]\\]][Foo https://orgmode.org]] | 26:00 |"
(org-test-with-temp-text
"* Foo [[https://orgmode.org]]
(test-org-clock-clocktable-contents ":link t :lang en"))))
(should
(string-match-p
"| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\]]\\[Foo https://orgmode\\.org]] +| 26:00 +|"
(org-test-with-temp-text
"* Foo [[https://orgmode.org]]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en"))))))
(test-org-clock-clocktable-contents ":link t :lang en")))))
(ert-deftest test-org-clock/clocktable/compact ()
"Test \":compact\" parameter in Clock table."

View File

@ -2331,7 +2331,7 @@ SCHEDULED: <2014-03-04 tue.>"
;; Handle escape characters.
(should
(org-test-with-temp-text
"* H1\n:PROPERTIES:\n:CUSTOM_ID: [%]\n:END:\n* H2\n[[#[%\\]<point>]]"
"* H1\n:PROPERTIES:\n:CUSTOM_ID: [%]\n:END:\n* H2\n[[#\\[%\\]<point>]]"
(org-open-at-point)
(looking-at-p "\\* H1")))
;; Throw an error on false positives.
@ -2427,7 +2427,7 @@ Foo Bar
(looking-at "\\* TODO COMMENT Test")))
;; Correctly un-escape fuzzy links.
(should
(org-test-with-temp-text "* [foo]\n[[*[foo\\]][With escaped characters]]"
(org-test-with-temp-text "* [foo]\n[[*\\[foo\\]][With escaped characters]]"
(org-open-at-point)
(bobp)))
;; Match search strings containing newline characters, including

View File

@ -3555,7 +3555,7 @@ Another text. (ref:text)
(org-element-map tree 'link 'identity info t) info)))))
;; Handle escaped fuzzy links.
(should
(org-test-with-parsed-data "* [foo]\n[[[foo\\]]]"
(org-test-with-parsed-data "* [foo]\n[[\\[foo\\]]]"
(org-export-resolve-fuzzy-link
(org-element-map tree 'link #'identity info t) info))))