Commit Graph

1979 Commits

Author SHA1 Message Date
Vasilij Schneidermann 5082e436a7 org-datetree.el: Respect `org-blank-before-new-entry'
* lisp/org-datetree.el (org-datetree-insert-line): Respect
`org-blank-before-new-entry'.

* testing/lisp/test-org-datetree.el
(test-org-datetree/find-date-create)
(test-org-datetree/find-month-create)
(test-org-datetree/find-iso-week-create): Update tests.

TINYCHANGE

See <https://orgmode.org/list/20200903085054.GA21638@odonien.localdomain/>
2020-09-09 10:07:29 +02:00
Bastien 07c6b11258 ob-shell.el: New option `org-babel-shell-results-defaults-to-output'
* lisp/ob-shell.el (org-babel-shell-results-defaults-to-output):
New option.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline): Fix test.

See <https://orgmode.org/list/CA+A2iZaziAfMeGpBqL6qGrzrWEVvLvC0DUw++T4gCF3NGuW-DQ@mail.gmail.com>
2020-09-07 19:30:04 +02:00
Bastien 9f0af69dd2 Skip archived headings when tangling and exporting
* lisp/org.el (org-in-archived-heading-p): New function.

* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/ob-tangle.el (org-babel-tangle-collect-blocks): Use
`org-in-archived-heading-p' to skip archived headings when tangling
and exporting.

* testing/lisp/test-org.el (test-org/in-archived-heading-p): Add
test for `org-in-archived-heading-p'.

Reported-by: flare <gabrielxaviersmith@gmail.com>
See https://orgmode.org/list/877dt9ey2c.fsf@gmail.com/
2020-09-07 06:51:06 +02:00
Jack Kamm 5d289d2b3e ob-python: fix startup messages leaking into output
* lisp/ob-python.el (org-babel-python-initiate-session-by-key): Remove
workaround for emacs<24.1.  Sleep after starting Python, to prevent
startup messages leaking into output results.
* testing/lisp/test-ob-python.el (test-ob-python/session-multiline):
Remove workaround for startup message leaking into results.
2020-09-06 18:15:04 -07:00
Bastien 74b6860b76 Merge branch 'maint' 2020-09-06 23:36:50 +02:00
Bastien ba2405b12e testing/lisp/test-org-inlinetask.el: Fix test
* testing/lisp/test-org-inlinetask.el
(test-org-inlinetask/folding-directly-consecutive-tasks/1): Fix
test.

This test was broken by ee3c3b55.
2020-09-06 23:35:32 +02:00
Bastien 3e191242dc Fix tests wrt 2f53429413
* testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1)
(test-ob/just-one-results-block)
(test-ob/org-babel-remove-result--results-default)
(test-ob/specific-colnames): Fix tests.

* testing/lisp/test-ob-tangle.el (ob-tangle/comment-links-at-left-margin): Ditto.

* testing/lisp/test-ob-shell.el (ob-shell/generic-uses-no-arrays)
(ob-shell/bash-uses-arrays)
(ob-shell/generic-uses-no-assoc-arrays)
(ob-shell/bash-uses-assoc-arrays, ob-shell/simple-list): Ditto.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline)
(ob-exp/exports-inline-code): Ditto.

* testing/examples/ob-shell-test.org (Generic shell: no arrays)
(Bash shell: support for arrays)
(Generic shell: no special handing)
(Bash shell: support for associative arrays)
(Generic shell: no special handing)
(Bash shell: support for associative arrays with lists): Ditto.
2020-09-06 22:37:32 +02:00
Kyle Meyer d4f48821c1 Merge branch 'maint' into master 2020-09-05 23:41:50 -04:00
Kyle Meyer f24c3d11cc ob-core: Test that org-confirm-babel-evaluate does not see coderefs
* testing/lisp/test-ob.el (test-ob/check-eval-noweb-expanded): Add
test.

With df5a83637 (ob-core: Call org-confirm-babel-evaluate with expanded
noweb refs, 2020-08-02), org-confirm-babel-evaluate gets called with
an expanded body and coderefs.  As of the last commit, the coderefs
are stripped.

Cf: https://orgmode.org/list/CA+G3_PPYS2KAaXiBDeujTTpswCTzTuJRQsXwaji1MuRoc8N7vw@mail.gmail.com
2020-09-05 23:38:43 -04:00
Jack Kamm b5709ddc98 ob-python: Fix session blocks not waiting for value result
* lisp/ob-python.el (py-shell-send-string): Remove unneeded
declare-function.
(org-babel-python-eoe-indicator): Add back this const.
(org-babel-python--eval-ast): Fix spacing so the block can be entered
line by line into the interpreter.
(org-babel-python-evaluate-session): Revert previous changes to
evaluation for value results.
* testing/lisp/test-ob-python.el (test-ob-python/session-value-sleep):
New test for session blocks that don't return immediately.

632ceabb1 introduced a bug where session blocks don't wait for value
results if not returned immediately.  This reverts part of that
commit, specifically for evaluation of session blocks with value
results.  It leaves other parts of that commit alone, for example the
changes to session output results, which is more robust handling
prompts from ipython interpreter.

A downside of reverting the session value implementation is that the
ugly code from org-babel-python--eval-ast is again printed in the
console, but this is less bad than the new bug that was introduced by
the change, hence reverted.
2020-09-04 17:51:37 -07:00
Kyle Meyer 7bc18ebbed ob-core: Avoid table conversion warning for empty results
* lisp/ob-core.el (org-babel-import-elisp-from-file): Don't try to
convert empty file to a table.
* testing/lisp/test-ob.el (test-ob/import-elisp-from-file): Add tests.

If org-babel-import-elisp-from-file is called with an empty file
(which many ob- libraries do when there are no results), feeding that
to org-table-import leads to a beginning-of-buffer error.  Before
14878f3f9 (ob-core: Display warning on failure to read results,
2020-05-21), this error was hard to notice because, after catching it,
it was reported as a quickly buried message.  After that commit, it is
displayed as a warning, which is not appropriate for the common and
unproblematic case of empty results.

Avoid the warning by only doing the table conversion if the file has
content.  Another option would be to do the table conversion but add a
beginning-of-buffer arm to the surrounding condition-case.  However,
that risks swallowing other sources of that error.

Reported-by: Colin Baxter <m43cap@yandex.com>
<https://orgmode.org/list/878se3nhbj.fsf@yandex.com>
2020-09-01 00:02:49 -04:00
Nicolas Goaziou 66537267eb org-num: Add tests
* testing/lisp/test-org-num.el (test-org-num/skip-numbering): Add
tests. This is a followup to 40474827ea.
2020-08-28 08:45:41 +02:00
Kyle Meyer cdfc404bed Merge branch 'maint' into master 2020-08-23 22:39:44 -04:00
Allen Li 76da93aa86 org.el: Don't exclude local tags that are also inherited
This fixes a bug in set-tags-command excluding a tag that is both set
locally and inherited from the initial minibuffer input by modifying
org-get-tags to prefer keeping the locally set tag over the inherited
tag, as this behavior is more intuitive for org-get-tags anyway.

* lisp/org.el (org-get-tags): Keep local tags over inherited.
* testing/lisp/test-org.el (test-org/set-tags-command): Add test.
2020-08-23 22:38:20 -04:00
Nicolas Goaziou 567662d5b0 list: Fix item insertion when split point is near blanks
* lisp/org-list.el (org-list-insert-item): Ignore blanks around cut
position.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add test.

Reported-by: Samuel Wales <samologist@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-08/msg00065.html>
2020-08-16 11:42:53 +02:00
John Herrlin ea946353aa ob-core: file-mode option in source code block arguments
* ob-core.el (org-babel-execute-src-block): Source code block header
argument `:file-mode' can set file permissions if `:file' argument is
provided.
(org-babel-common-header-args-w-values): Add `:file-mode' to common
header arguments.

TINYCHANGE
2020-08-02 22:59:25 -04:00
Kyle Meyer a103f3f3ee Merge branch 'maint' 2020-08-02 22:56:03 -04:00
Nicholas Vollmer 093b474e6a org-list: Operate on single line if no active region
* lisp/org-list.el (org-toggle-item): Operate on single line if no
active region.
2020-08-02 22:55:47 -04:00
Kyle Meyer df5a836375 ob-core: Call org-confirm-babel-evaluate with expanded noweb refs
* lisp/ob-core.el (org-babel-check-confirm-evaluate): Expand noweb
references in the body passed to org-confirm-babel-evaluate.
* testing/lisp/test-ob.el (test-ob/check-eval-noweb-expanded): New
test.

When noweb references are set to be expanded for evaluation,
org-confirm-babel-evaluate should receive the expanded body so that it
can make its decision based on what actually will be evaluated
(without resorting to calling org-babel-get-src-block-info itself).

Note that this results in up to three calls to
org-babel-expand-noweb-references.  Possible ways to avoid this are
discussed at the thread referenced below.

Reported-by: Tom Gillespie <tgbugs@gmail.com>
https://orgmode.org/list/CA+G3_PNi3uMvBiWgBdKuC3C6VJt1T1j-RKH43LRqYbr+4NS8ZA@mail.gmail.com/
2020-08-02 22:55:16 -04:00
Nicolas Goaziou 91b2398293 Do not fill paragraph before region
* lisp/org.el (org-fill-paragraph): Do not fill paragraph before
region.
* testing/lisp/test-org.el (test-org/fill-paragraph): Add test.

Reported-by: Matt Lundin <mdl@imapmail.org>
<http://lists.gnu.org/r/emacs-orgmode/2020-07/msg00164.html>
2020-07-14 11:46:38 +02:00
Nick Dokos bc4fa8a008 org: add property names from #+PROPERTY keywords to completion list
* lisp/org.el (org-buffer-property-keys): Enhance the completion list
with property names from #+PROPERTY keywords, not just property
drawers. Also, for each xxx_ALL property, make sure that the bare xxx
property is added too.

* testing/lisp/test-org.el (test-org/buffer-property-keys): Add test
cases for #+PROPERTY keywords and also for xxx_ALL --> xxx properties.

See https://emacs.stackexchange.com/questions/59448/ for details.

Modified-by: Kyle Meyer <kyle@kyleam.com>
  Cosmetic tweaks to _ALL stripping.
2020-07-07 23:37:54 -04:00
Nicolas Goaziou 353e8cc2b7 Fix paragraph filling
* lisp/org.el (org-fill-paragraph): Fix regression introduced in
e2b62b4da8.
* testing/lisp/test-org.el (test-org/fill-paragraph): New test.

Reported-by: stardiviner <numbchild@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-07/msg00065.html>
2020-07-07 10:37:35 +02:00
Nicolas Goaziou 07a4a72862 list: Fix regression when inserting items
* lisp/org-list.el (org-list-insert-item): Fix splitting item.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add test.

Reported-by: Duianto - <otnaiud@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-07/msg00061.html>
2020-07-06 12:05:18 +02:00
Nicolas Goaziou b0bbe512b4 src: Do not undo edit buffers back to empty state
* lisp/org-src.el (org-src--edit-element): Clear undo information once
the initial contents have been inserted.
* testing/lisp/test-org-src.el (test-org-src/undo): New test.
2020-07-02 19:30:14 +02:00
mfrasca 73e367fca4 table: Allow collapsing header into single line
* lisp/org-table.el (org-table-collapse-header): New function.

* lisp/org-plot.el (org-plot/gnuplot): Use org-table-collapse-header
and trust there will be no more leading `hline' symbols in lisp table.

* testing/lisp/test-org-table.el (test-org-table/to-lisp):
Adding tests to already existing to-lisp function.
(test-org-table/collapse-header): Adding tests to new
collapse-header function.

* testing/lisp/test-ox.el (test-org-export/has-header-p): Testing
exporting table with multi-line header.
2020-06-28 23:02:26 +02:00
Kyle Meyer 15029c8abb Merge branch 'maint' 2020-06-28 02:29:12 -04:00
Kyle Meyer 8a2eb7d1bc org.el: Fix org-todo argument handling when looping over region
* lisp/org.el (org-todo): Replace backquote construct, which did not
properly quote argument, with closure.

Using "',arg" instead of ",arg" would also work.

Reported-by: Mario Frasca <mario@anche.no>
https://orgmode.org/list/ea64d98c-d7bf-eea0-40d4-00a1515bdb98@anche.no
2020-06-28 02:13:58 -04:00
Nicolas Goaziou e3a7247b68 table: Gracefully align hrule-only tables
* lisp/org-table.el (org-table-align): Try to align the table even
when it only consists of horizontal rules.
* testing/lisp/test-org-table.el (test-org-table/align): Add test.
2020-06-15 21:34:00 +02:00
Nicolas Goaziou e2b62b4da8 Rewrite `org-forward-paragraph' and `org-backward-paragraph'
* lisp/org.el (org-forward-paragraph):
(org-backward-paragraph): Rewrite functions.  Add repeat argument.
Mimic more closely regular `forward|backward-paragraph' functions.
(org--forward-paragraph-once):
(org--backward-paragraph-once):
(org--paragraph-at-point): New functions.
* testing/lisp/test-org.el (test-org/forward-paragraph):
(test-org/backward-paragraph): Update tests.  Add some.

Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
2020-06-13 17:22:48 +02:00
Jack Kamm 3cec17cde5 ob-python.el: Fix multiline strings in non-session :results value
* lisp/ob-python.el (org-babel-python-evaluate-external-process): Use
functions from python.el to indent lines, avoiding multiline strings.
* testing/lisp/test-ob-python.el (test-ob-python/multiline-var): Set
test as expected to succeed.
(test-ob-python/multiline-str): Add test for multiline string in body.
(test-ob-python/header-var-assignment): Test that :var is in correct
scope and can be assigned to.

cf. https://orgmode.org/list/87tv009l9a.fsf@gmail.com/#t
2020-06-09 21:01:12 -07:00
Kyle Meyer 8d731ad256 Merge branch 'maint' 2020-06-08 20:28:03 -04:00
Kyle Meyer 3ebee03310 ob-tangle: Restore handling of relative file links
* lisp/ob-tangle.el (org-babel-tangle-single-block): Fix regression
from v9.0.2 that resulted in org-babel-tangle-use-relative-file-links
being ignored.
* testing/lisp/test-ob-tangle.el
(ob-tangle/comment-links-relative-file): Add test.

As of 7b148e2d0 (ob-tangle: Respect buffer local variables,
2016-12-10), the condition in org-babel-tangle-single-block that
checks whether to return a file link with a relative target always
returns nil because the full org-link-types-re match, including the
final colon, is compared with "file" (no colon).  Also, were this
condition to succeed, "file:" would be used as the file name.

Adjust the condition and fix the extracted file name.

Reported-by: Jeremias Gonzalez <jgonzalez49@ucmerced.edu>
https://orgmode.org/list/6fb12326-52d3-7177-eff5-62603261b388@ucmerced.edu
2020-06-08 20:25:22 -04:00
Nicolas Goaziou b68090e0be Another fix to `org-next-visible-heading'
* lisp/org.el (org-next-visible-heading): There is no guarantee that
a `outline' overlay begins on the same line as a headline.
* testing/lisp/test-org.el (test-org/previous-visible-heading): New
test.

Reported-by: Kevin Liu <kevin@nivekuil.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-06/msg00092.html>
2020-06-04 16:08:40 +02:00
Kévin Le Gouguec c8f7e89d7e Make tests robust with respect to mailcap entries
When /etc/mailcap specifies a program for text/plain
files (e.g. less(1)), org-open-file will run this program instead of
visiting the file.  This throws off some tests which expect
extension-less temporary files to be visited.

* testing/lisp/test-ob-tangle.el (ob-tangle/jump-to-org):
* testing/lisp/test-org-attach.el (test-org-attach/dir): Rig
org-file-apps so that temporary files are visited inside Emacs.
2020-06-03 00:11:46 -04:00
Nicolas Goaziou fe7830b4f3 Merge branch 'maint' 2020-05-31 13:57:05 +02:00
Nicolas Goaziou 65fdf2be16 Fix `org-mark-element' in narrowed buffers
* lisp/org.el (org-mark-element): Do not set mark past narrowed part
of the buffer.
* testing/lisp/test-org.el (test-org/mark-element): New test.

Reported-by: Kevin Liu <kevin@nivekuil.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00812.html>
2020-05-31 13:55:47 +02:00
Nicolas Goaziou 1596113512 Fix `org-next-visible-heading'
* lisp/org.el (org-next-visible-heading): Fix function when
`org-cycle-separator-lines' is different from 0.
* testing/lisp/test-org.el (test-org/next-visible-heading): New test.
2020-05-31 12:55:08 +02:00
Kévin Le Gouguec e9163591ae Add test case for symbol coercion in C Babel blocks
The ORG-NEWS entry for version 9.1 suggests that this coercion was
always intended, though AFAICT there was no test case for it.

* testing/lisp/test-ob-C.el (ob-C/symbol-include): Check explicitly
that :includes <iostream> (with no double-quotes around <iostream>)
will be parsed correctly.
(ob-D/simple-program, ob-C/integer-var, ob-D/integer-var,
ob-C/two-integer-var, ob-D/two-integer-var, ob-C/string-var,
ob-D/string-var, ob-C/preprocessor): Adjust block indices.

* testing/examples/ob-C-test.org (Simple tests): Add input for the new
test.
2020-05-28 22:32:31 -04:00
Jack Kamm d73fd145c0 ob-python.el: Revert fix for multiline var
* lisp/ob-python.el (org-babel-execute:python,
org-babel-python-evaluate): Move variable assignment back to body from
preamble.
* testing/lisp/test-ob-python.el (test-ob-python/multiline-var): Mark
unit test for multiline-variable as expected to fail.

Reverts 6149b6cb6 which fixed multiline vars in ob-python, but caused
a new bug (https://lists.gnu.org/archive/html/emacs-orgmode/2020-05/msg00719.html).
2020-05-28 07:29:31 -07:00
Nicolas Goaziou 516c038e5f lint: Catch misleading drawers within drawers
* lisp/org-lint.el (org-lint-incomplete-drawer): Catch misleading
drawers within drawers.
* testing/lisp/test-org-lint.el (test-org-lint/incomplete-drawer): Add
test.
2020-05-27 14:55:04 +02:00
Kevin J. Foley 7a2b785d6a test-ob-tangle.el: Fix dirty repo state caused by testing
* testing/lisp/test-ob-tangle.el (ob-tangle/detangle-false-positive):
Kill modified buffer after test.

Another test is causing the modifications to be saved which leaves the
repo in a dirty state after testing.

Modified-by: Kyle Meyer <kyle@kyleam.com>
  Changed to kill a let-bound buffer rather than a buffer name.
2020-05-26 21:51:47 -04:00
Nicolas Goaziou 266ad1e134 list: Fix cycle indentation
* lisp/org-list.el (org-cycle-item-indentation): Do not stop at
initial indentation before outdenting items.  Implement more robust
algorithm.
* testing/lisp/test-org-list.el (test-org-list/cycle-item-identation):
New test.
* testing/lisp/test-org-list.el (test-org-list/move-item-down): Small
reformatting.

Reported-by: lamaglama@posteo.net
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00573.html>
2020-05-24 23:43:24 +02:00
Jack Kamm eecee22665 test-ob-python.el: Add test for multiline-string variables
* testing/lisp/test-ob-python.el (test-ob-python/multiline-var): Add
test for multiline-string variable issue that was fixed in 6149b6cb6.
2020-05-24 08:14:03 -07:00
Kevin J. Foley 010d1e3b6e Fix `org-babel-detangle' handling of false positives
* lisp/ob-tangle.el (org-babel-detangle): Handle false positive
matches of `org-link-bracket-re'.

* testing/examples/babel.el: New file for Babel detangle false
positive test.

* testing/examples/babel.org (detangle): Add detangle/false positive
example.

* testing/lisp/test-ob-tangle.el (ob-tangle/detangle-false-positive):
Add test for detangle false positive.
2020-05-24 15:40:21 +02:00
Kyle Meyer 962b8e765c org.el: Fix regression in collecting empty-value keywords
* lisp/org.el (org--collect-keywords-1): Don't replace space-only
values with nil because that leads to the option's default being used.
* testing/lisp/test-ox.el (test-org-export/get-inbuffer-options):
Add test.

This restores the behavior to what it was before b4e91b7e9 (New
function: org-collect-keywords, 2020-04-26).

Reported-by: Kaushal Modi <kaushal.modi@gmail.com>
<CAFyQvY2ZGJPv=Ajx2_1xR0otv=VQYHcrUwzS46PmnyJ2Co1KVg@mail.gmail.com>
2020-05-19 20:33:15 -04:00
Nicolas Goaziou 48b223d45d Fix test
* testing/lisp/test-org.el (test-org/return): Use `call-interactively'
so that `interactive' arguments are also checked.
2020-05-15 00:48:26 +02:00
Nicolas Goaziou 99bb514f7f Follow links with RET even in read-only buffers
* lisp/org.el (org-return): Fix `interactive' arguments.
* testing/lisp/test-org.el (test-org/return): Add test.

Reported-by: Gregor Zattler <telegraph@gmx.net>
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00247.html>
2020-05-14 23:28:10 +02:00
stardiviner 1abf4f600a pcomplete: improve header arguments completion
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src): Make it
complete all available header arguments.

* testing/lisp/test-org-pcomplete.el (test-org-pcomplete/src-block):
New test.
2020-05-14 14:52:30 +02:00
Nicolas Goaziou 89c759f3ad ob: Replace angle brackets with parenthesis in Babel hashes
* lisp/ob-core.el (org-babel-hash-show-time): Remove
unnecessary :version keyword.
(org-babel-result-regexp):
(org-babel--insert-results-keyword): Remove angle brackets from time
stamp in hash.
* testing/lisp/test-ob.el (test-ob/where-is-src-block-result): Update
test.

Reported-by: stardiviner <numbchild@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00198.html>
2020-05-13 15:35:56 +02:00
Kyle Meyer 4349402f3f Merge branch 'maint' 2020-05-12 22:47:05 -04:00