Commit Graph

2039 Commits

Author SHA1 Message Date
Ian Martins ce02d52bc4 ob-java.el: Change the default back to scripting mode
* lisp/ob-java.el (org-babel-default-header-args:java): Change the
default to scripting mode.

* testing/lisp/test-ob-java.el: Modify the first test to use the
default for `:results' and all others to specify it.

A recent commit added functional mode and made it default, but this
would break java source blocks for anyone that relied on the old
default.  This sets the default back to scripting mode.
2020-11-02 06:26:54 -05:00
Kyle Meyer 3b382e9d9e Merge branch 'maint' into master 2020-11-01 18:38:24 -05:00
Kyle Meyer 20374f69e8 ob-exp: Restore evaluation query for lob calls during export
* lisp/ob-exp.el (org-babel-exp-results): Fix a regression from v9.0
that led to silently executing lob calls on export despite a non-nil
value of org-confirm-babel-evaluate.
* testing/lisp/test-ob-lob.el (test-ob-lob/confirm-evaluate): New test.

56bf3d789 (Babel: avoid superfluous confirmation for internal wrapper,
2013-04-10) let-bound org-confirm-babel-evaluate to nil in two spots
to prevent double querying for lob calls.  These overrides were no
longer needed following the refactoring in dbb375fdf (Simplify Babel
calls evaluation, 2016-06-16).  However, that commit dropped only one
of the spots, and, as a result, disabled confirmation unconditionally
when exporting lob calls.

Drop the remaining org-confirm-babel-evaluate override.

Reported-by: 吴锐扬 <ywwry66@gmail.com>
Ref: https://orgmode.org/list/5362C0A0-632F-4C87-8FA1-915F0F53D8B8@gmail.com
2020-11-01 18:34:16 -05:00
Ian Martins 5a41c62c26 ob-java.el: Use customizable commands, avoid incompatability
* lisp/ob-java.el: Use customizable variables for java compiler and
runtime commands.  Move variable declarations to fix byte-compile
warnings.  Change Author.  Change tabs to spaces.

A recent patch replaced `defcustom' with `defvar' for variables that
point to the java compiler and runtime commands, which would break
functionality for anyone who had customized the variable.  This
reverts that change.

ob-java is using features not available on older versions of emacs
which org supports.  This replaces them with alternatives.
2020-10-25 15:24:08 -04:00
Ian Martins 5b6d774ba1 ob-java.el: Allow non-public classes
* lisp/ob-java.el: Don't require class definitions to be declared
public.

* testing/lisp/test-ob-java.el: Add test with non-public class.
2020-10-25 15:24:08 -04:00
Ian Martins 6edfc2b57c ob-java.el: Add support for variables, return values, tramp
* lisp/ob-java.el: Add support for variables and return values.  Write
tempfiles to the `org-babel-temporary-directory'.  Make package,
class, and main method definitions optional.

* testing/lisp/test-ob-java.el: Add tests.

ob-java was missing features common to many other org-babel
implementations, such as the ability to accept variables and return a
value. This brings those features to ob-java, making the experience
more consistent across org-babel languages, and expanding the ways
java source blocks interact with org mode buffers.

A simple java program requires boilerplate code to declare a class and
main method.  This boilerplate code makes java source blocks more
tedious to write and more effort to read.  This is more evident in an
org buffer where there may be many small source blocks.  This change
makes that code optional.  If it is not provided, the source block
will be wrapped in the boilerplate code just before compilation.

Most org babel implementation write temporary files to the
`org-babel-temporary-directory'.  That avoids polluting the current
directory and provides built-in support for tramp.  ob-java would
write source files and binaries to the directory containing the org
file by default.  This may be unexpected and unwanted, and didn't work
with tramp.  This change writes all tempfiles to the
`org-babel-temporary-directory'.

Executing an ob-java source block would always try to compile and run
the code in the source block, so a source block that wasn't
runnable (didn't contain a main method) would error during run.  This
change adds a generic main method just before compilation if one isn't
included in the source block so that the run will succeed.

There were no tests for ob-java.  This adds tests.
2020-10-25 15:24:08 -04:00
Matt Huszagh d9884cfa70 lisp/ob-core.el: Allow passing empty vector to :file-desc to omit description
* doc/org-manual.org (Type): Document empty vector argument for
file-desc.
* etc/ORG-NEWS (New argument for ~file-desc~ babel header): Add entry
to NEWS.
* lisp/ob-core.el (org-babel--file-desc): Add new function to evaluate
file description value.
(org-babel-execute-src-block): Correctly evaluate file description
when executing src block.
(org-babel-insert-result): Correctly evaluate file description value
when inserting the result of src block execution into the buffer.
* testing/lisp/test-ob.el (test-ob/file-desc-header-argument): Add
test case for new behavior.
2020-10-06 23:13:12 -04:00
Kyle Meyer 6676a97d27 org-tags-expand: Fix handling of downcased group tags
* lisp/org.el (org-tags-expand): Support using an upper- or mix-case
tag as MATCH when SINGLE-AS-LIST and DOWNCASED are non-nil, fixing a
regression from v9.2.
* testing/lisp/test-org.el (test-org/tags-expand): Add test.

org-agenda-filter-by-tag reads a case-sensitive tag from the user, and
downstream code passes this tag as is to org-tags-expand along with
non-nil values for SINGLE-AS-LIST and DOWNCASED.  As of 9df82be07 (Fix
tag groups expansion as a regexp, 2018-11-08), org-tags-expand fails
to return the group tags in this scenario for queries that contains an
uppercase letter, breaking org-agenda-filter-by-tag.

Downcase MATCH if SINGLE-AS-LIST and DOWNCASED are non-nil.

Reported-by: Leon Weber <leon.weber@net2.ch>
Ref: https://orgmode.org/list/c1f8cc32-dc16-697c-c24d-e5e05124bd66@net2.ch
2020-09-28 00:04:53 -04:00
Kyle Meyer 3eccc537cd org.el: Fix regression in handling of empty #+TAGS
* lisp/org.el (org-set-regexps-and-options): Allow an empty #+TAGS
value to override org-tag-alist, as it did before v9.4.
* testing/lisp/test-org.el (test-org/set-regexps-and-options): Add
test.

As of b4e91b7e9 (New function: org-collect-keywords, 2020-04-26), a
"#+TAGS" header can no longer be used to override a value of
org-tag-alist.  This breaks the workflow where a set of tags for most
files is defined via org-file-tags and then, in a particular file, an
empty #+TAGS header is used to ignore org-file-tags and trigger
collecting tags from the buffer instead.  Rework the handling to
restore this behavior.

Reported-by: Allen Li <darkfeline@felesatra.moe>
Ref: https://orgmode.org/list/80y2laly9v.fsf@felesatra.moe
2020-09-20 00:59:09 -04:00
Kyle Meyer 469ee63401 ob-core: Fix handling of multiple noweb refs in same line
* lisp/ob-core.el (org-babel-expand-noweb-references): Don't anchor
noweb regexp at start of line to allow multiple matches per line.
* testing/lisp/test-ob-tangle.el (ob-tangle/multiple-noweb-in-line):
Add test.

This fixes a regression introduced by c1aed9f80 (ob-core: Refactor
`org-babel-expand-noweb-references', 2020-01-12), which was part of
the 9.4 release.

Reported-by: Tom Gillespie <tgbugs@gmail.com>
Ref: https://orgmode.org/list/CA+G3_PO2yO1jMMpdrkc39BGQQ2eU5X4FzTEJVotjDJo-50dsqQ@mail.gmail.com
2020-09-15 23:45:16 -04:00
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
Kyle Meyer 7684b59c78 colview: Display active time stamps as inactive
* lisp/org-colview.el (org-columns--displayed-value): Convert active
time stamp values to inactive time stamps to avoid duplicate entries
in the agenda.
* testing/lisp/test-org-colview.el (test-org-colview/dblock): Add
tests.
2020-05-12 22:44:57 -04:00
Kyle Meyer b0fb4599c7 Merge branch 'maint' 2020-05-09 15:54:44 -04:00
Matt Lundin 6e50b22ff0 Fix bug that placed cursor incorrectly when setting tags
* lisp/org.el (org-set-tags-command): Only fix cursor position in very
specific circumstances (i.e., when cursor is on an empty headline).
* testing/lisp/test-org.el (test-org/set-tags-command): Add tests
related to point position.

Modified-by: Kyle Meyer <kyle@kyleam.com>
  Adjusted for review comments and added tests.
2020-05-09 15:50:37 -04:00
Nicolas Goaziou ed0e75d241 Fix typo
* lisp/org.el (org-at-property-drawer-p): Fix typo.
* testing/lisp/test-org.el (test-org/at-property-drawer-p): Update
name and function calls.  Add a test.
2020-05-09 12:58:09 +02:00
Nicolas Goaziou a3d23b3a97 Add test for `org-find-property'
* testing/lisp/test-org.el (test-org/find-property): Add test.
2020-05-08 00:50:16 +02:00
Nicolas Goaziou 0edd9aee38 Merge branch 'maint' 2020-05-07 22:37:02 +02:00
Nicolas Goaziou 09086b7e75 Fix capturing plain text with :unnarrowed property and no "%?" marker
* lisp/org-capture.el (org-capture-narrow): Remove undocumented point
move.
(org-capture--position-cursor): New function.
(org-capture-place-entry):
(org-capture-place-item):
(org-capture-place-table-line):
(org-capture-place-plain-text): Use new function.
* testing/lisp/test-org-capture.el (test-org-capture/plain): Add test.

Reported-by: No Wayman <iarchivedmywholelife@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00095.html>
2020-05-07 22:35:13 +02:00
Kévin Le Gouguec d3e6b58004 Make RET and C-j obey `electric-indent-mode'
* lisp/org-compat.el (org-return-indent): Deprecate this command.
* lisp/org-keys.el (org-mode-map): Rebind C-j to a command emulating
`electric-newline-and-maybe-indent'.
* lisp/org.el (org-cdlatex-environment-indent): Stop using the now
obsolete function.
(org--newline): New helper function.
(org-return): Use it to transparently handle `electric-indent-mode'.
(org-return-and-maybe-indent): New command to emulate
`electric-newline-and-maybe-indent' while taking care of Org special
cases (tables, links, timestamps).
* testing/lisp/test-org.el (test-org/with-electric-indent,
test-org/without-electric-indent): New tests.
* testing/org-test.el (org-test-with-minor-mode): New helper to set a
minor mode to a specific state, and reset it afterward.
2020-05-07 12:14:30 +02:00
Nicolas Goaziou 271f5a6829 Insert planning in visible part of narrowed buffer
* lisp/org.el (org-add-planning-info): Make sure planning info appears
in the visible part of a narrowed buffer.
* testing/lisp/test-org.el (test-org/deadline):
(test-org/schedule): Update tests.

Reported-by: Michaël Cadilhac <michael@cadilhac.name>
<http://lists.gnu.org/r/emacs-orgmode/2019-09/msg00091.html>
2020-05-06 02:43:42 +02:00
Nicolas Goaziou 4a27b67fd2 org-element: Fix property drawers parsing
* lisp/org-element.el (org-element--next-mode): Properly handle first section.
* lisp/org-lint.el (org-lint-obsolete-properties-drawer): Ignore
document-level property drawers.
* testing/lisp/test-org-lint.el (test-org-lint/obsolete-properties-drawer):
Add tests.
2020-04-22 16:06:43 +02:00
Nicolas Goaziou b4f77b1f9a Deprecate `org-flag-drawer'
* testing/lisp/test-org.el (test-org/flag-drawer): Remove tests.
* lisp/org-clock.el (org-clock-jump-to-current-clock):
* lisp/org.el (org-cycle-hide-drawers): Use `org-hide-drawer-toggle'
instead.
(org-insert-drawer)
(org-hide-drawer-toggle): Use `org-flag-region' instead.
(org-flag-drawer): move...
* lisp/org-compat.el (org-flag-drawer): ... here.
2020-04-18 18:34:55 +02:00
Nicolas Goaziou e6cd5a50d1 Drawer visibility tooling mimics blocks'
* lisp/org.el (org-hide-drawer-toggle): New function.
(org-flag-drawer): Assume either a parser drawer or buffer positions
are provided.  Remove unnecessary checks, since this is a low-level function.
* testing/lisp/test-org.el (test-org/hide-drawer-toggle): New test.
(test-org/flag-drawer):
(test-org/show-set-visibility): Update tests.
2020-04-18 18:34:55 +02:00
Nicolas Goaziou e515a7cec8 Merge branch 'maint' 2020-04-18 18:34:24 +02:00
Nicolas Goaziou 756ddff9e3 table: Small fix to column deletion
* lisp/org-table.el (org-table-delete-column): Do not assume row ends
right after the last vertical line.  Do not use `looking-back'.
* testing/lisp/test-org-table.el (test-org-table/delete-column): Add
test.
2020-04-18 18:33:07 +02:00
Marco Wahl 6f38fe24a3 Merge branch 'maint' 2020-04-18 16:17:12 +02:00
Marco Wahl bb9dfdafeb org-table: Make column delete consistent with row delete
* lisp/org-table.el (org-table-delete-column): Stay in the column at
delete.  Exceptionally allow column delete when point is at eol
immediately to the right of a cell seperator.

A hint by Eric S Fraga led to this commit.
https://lists.gnu.org/archive/html/emacs-orgmode/2020-04/msg00283.html
2020-04-18 16:16:02 +02:00
Marco Wahl 0e5be8a656 Merge branch 'maint' 2020-04-18 00:21:39 +02:00
Marco Wahl 22d2b0ac84 org-table: Insert column at point
* lisp/org-table.el (org-table-insert-column): Adjust the function to
insert the column at point (and not to the right.)

Org-manual, ORG-NEWS and testing are changed accordingly.
2020-04-18 00:13:24 +02:00
Nicolas Goaziou b49aabdba4 Merge branch 'maint' 2020-04-10 16:06:57 +02:00
Nicolas Goaziou 8b988ee3a5 org-list: Another fix to item insertion
* lisp/org-list.el (org-list-insert-item): Fix typos. Add a check to
determine if an item really belongs to the part being split.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add test.
2020-04-10 16:06:05 +02:00
Nicolas Goaziou d61631bb19 Merge branch 'maint' 2020-04-10 15:11:29 +02:00
Nicolas Goaziou 8eef99306a org-list: Fix last commit
* lisp/org-list.el (org-list-insert-item): This is a followup to
1ae1f8f2df.  It fixes an error when
insertion happens after the last item in the list.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add test.
2020-04-10 15:09:49 +02:00
Nicolas Goaziou a2281ea9fe Merge branch 'maint' 2020-04-09 15:43:58 +02:00
Nicolas Goaziou 1ae1f8f2df org-list: Fix infloop when inserting item in post sub-list area
* lisp/org-list.el (org-list-insert-item): Do not infloop when
insertion happens in an item, after a sub-list.  Small refactoring.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add
tests.
2020-04-09 15:42:36 +02:00
Nicolas Goaziou 06fe9d6b05 ob: Improve handling of :wrap header
* lisp/ob-core.el (org-babel-insert-result): Improve handling of :wrap
header.
* testing/lisp/test-ob.el (test-ob/inline-src_blk-wrap): New test.
(test-ob/preserve-comma-escape): Add test.
2020-04-07 01:42:35 +02:00
Nicolas Goaziou 0a7e382c27 Merge branch 'maint' 2020-04-07 01:22:18 +02:00
Nicolas Goaziou e3373f4beb ob-core: Properly replace results in special blocks
* lisp/ob-core.el (org-babel-result-end): Handle results in special
blocks.
* testing/lisp/test-ob.el (test-ob/replace-special-block-result): New
test.
2020-04-07 01:21:33 +02:00
Nicolas Goaziou fb593f7556 Handle ".+" repeater with hours step
* doc/org-manual.org (Repeated tasks): Document new feature.
* lisp/org.el (org-auto-repeat-maybe): Repeat from now when ".+" is
used in conjunction of hours increment.
* testing/lisp/test-org.el (test-org/auto-repeat-maybe): Add tests.
2020-04-06 15:18:48 +02:00
Marco Wahl 31d1bf86a3 Merge branch 'maint' 2020-03-30 23:23:33 +02:00
Marco Wahl dc53b59a25 test-org-table: Test insert column with formula in place
*
testing/lisp/test-org-table.el (test-org-table/insert-column-with-formula):
New test.
2020-03-30 23:21:45 +02:00
Kyle Meyer ba685555c4 org-clock: Mention semimonth step in manual and add test
* doc/org-manual.org (The clock table): Mention new semimonth :step
value.
* testing/lisp/test-org-clock.el (test-org-clock/clocktable/step):
Test :step semimonth.

Add a NEWS entry as well.
2020-03-26 21:04:00 -04:00
Nicolas Goaziou 7a78eb1be0 ol: Fix some corner cases when normalizing context in links
* lisp/ol.el (org-link--normalize-string): Handle blanks between
special characters.
(org-link-heading-search-string): Small refactoring.
* testing/lisp/test-ol.el (test-ol/store-link): Add tests.
2020-03-26 22:57:16 +01:00
Nicolas Goaziou 965cdbfd4b org-macro: Fix {{{author}}} expansion without AUTHOR keyword
* lisp/org-macro.el (org-macro--set-template): Allow setting a nil
value, which becomes an empty template.
* testing/lisp/test-org-macro.el (test-org-macro/author):
(test-org-macro/email):
(test-org-macro/title): New tests.

Reported-by: "Dauer, Michael" <michael.dauer@smartpm.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-03/msg00094.html>
2020-03-11 16:24:26 +01:00
Nicolas Goaziou 4cf8ffdba6 org-macro: Fix {{{author}}} expansion without AUTHOR keyword
* lisp/org-macro.el (org-macro--set-template): Allow setting a nil
value, which becomes an empty template.
* testing/lisp/test-org-macro.el (test-org-macro/author):
(test-org-macro/email):
(test-org-macro/title): New tests.

Reported-by: "Dauer, Michael" <michael.dauer@smartpm.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-03/msg00094.html>
2020-03-11 16:21:49 +01:00
Nicolas Goaziou e18415d02c ob: Fix case when replacing Noweb reference
* lisp/ob-core.el (org-babel-expand-noweb-references): Use FIXEDCASE.
* testing/lisp/test-ob.el (test-ob/noweb-expansion): Add test.

Reported-by: Sebastian Miele <sebastian.miele@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-03/msg00070.html>
2020-03-09 23:10:04 +01:00
Nicolas Goaziou 97e415c5df ol: Do not save tags when storing a link from a headline
* lisp/ol.el (org-link-heading-search-string): Assume optional
argument is already valid.  Remove TODO keyword, priority cookie,
COMMENT keyword, and tags.
(org-link-search): Remove COMMENT keyword.
* testing/lisp/test-ol.el (test-ol/store-link): Add tests.
2020-03-09 22:23:11 +01:00
Nicolas Goaziou 041138e47c Remove `org-export-link-as-file'
* lisp/ol.el (org-link-parameters): Remove reference to the function.
* lisp/ox.el (org-export-link-as-file): Remove function.
* testing/lisp/test-ox.el (test-org-export/link-as-file): Remove test.

The current implementation is not satisfactory, and not useful in the
code base. Using a pre-export hook turning custom link type into
"file" is enough for now. See "attachement" links for an example.
2020-02-28 01:30:30 +01:00
Nicolas Goaziou 12c09be3a6 Refactor context part in file links
* lisp/ol.el (org-link--context-from-region):
(org-link--squeeze-white-spaces): New functions.
(org-link-heading-search-string): Refactor code. Always start with an asterisk.
(org-store-link): Use new functions.
* lisp/org-pcomplete.el (pcomplete/org-mode/searchhead):
* testing/lisp/test-org-clock.el (test-org-clock/clocktable/link):
Update tests.
2020-02-19 18:42:50 +01:00
Nicolas Goaziou f4bed78a19 Move custom links to new tooling
* contrib/lisp/ol-bookmark.el (org-bookmark-open):
* contrib/lisp/ol-elisp-symbol.el (elisp-symbol-open):
* contrib/lisp/ol-git-link.el (org-gitbare-open):
(org-git-open):
* contrib/lisp/ol-man.el (org-man-open):
* contrib/lisp/ol-mew.el (org-mew-open):
* contrib/lisp/ol-notmuch.el (org-notmuch-open):
(org-notmuch-search-open):
(org-notmuch-tree-open):
* contrib/lisp/ol-vm.el (org-vm-open):
(org-vm-imap-open):
* contrib/lisp/ol-wl.el (org-wl-open):
* contrib/lisp/org-mac-link.el (org-mac-together-item-open):
(org-mac-addressbook-item-open):
(org-mac-skim-open):
(org-mac-acrobat-open):
(org-mac-outlook-message-open):
(org-mac-evernote-note-open):
(org-devonthink-item-open):
(org-mac-message-open):
* contrib/lisp/org-mairix.el (org-mairix-open):
* lisp/ol-bbdb.el (org-bbdb-export):
(org-bbdb-open):
* lisp/ol-bibtex.el (org-bibtex-open):
* lisp/ol-docview.el (org-docview-open):
* lisp/ol-eshell.el (org-eshell-open):
* lisp/ol-eww.el ("eww"):
* lisp/ol-gnus.el (org-gnus-open):
* lisp/ol-info.el (org-info-open):
* lisp/ol-irc.el (org-irc-visit):
* lisp/ol-mhe.el (org-mhe-open):
* lisp/ol-rmail.el ("rmail"):
(org-rmail-open):
* lisp/ol.el (org-link--open-doi):
(org-link--open-elisp):
(org-link--open-help):
(org-link--open-shell):
* lisp/org-id.el (org-id-open):
* testing/lisp/test-ox.el (test-org-export/custom-protocol-maybe): Use
new tooling.
* doc/org-manual.org (Adding Hyperlink Types): Adapt example.
2020-02-19 18:42:50 +01:00
Nicolas Goaziou ab9166ad29 Extend export tooling in link parameters
* lisp/ol.el (org-link-parameters): Allow a fourth "info" argument for
`:export' property.  Expound docstring.
* lisp/ox.el (org-export-custom-protocol-maybe): Accept a fourth
optional argument.
* lisp/ox-ascii.el (org-ascii--describe-links):
(org-ascii-link):
* lisp/ox-beamer.el (org-beamer-link):
* lisp/ox-html.el (org-html-link):
* lisp/ox-latex.el (org-latex-link):
* lisp/ox-man.el (org-man-link):
* lisp/ox-md.el (org-md-link):
* lisp/ox-odt.el (org-odt-link):
* lisp/ox-org.el (org-org-link):
* lisp/ox-texinfo.el (org-texinfo-link):
* contrib/lisp/ox-groff.el (org-groff-link): Provide expected fourth
argument.
* lisp/ox.el (org-export-link-as-file): New function.
* lisp/ol.el (org-link-parameters): Add reference to new function in docstring.
* testing/lisp/test-ox.el (test-org-export/link-as-file): Add tests.
(test-org-export/custom-protocol-maybe): Update tests.
2020-02-19 18:41:37 +01:00