Commit Graph

118 Commits

Author SHA1 Message Date
Ihor Radchenko 6652ee7be9
Merge branch 'bugfix' 2024-03-24 19:18:11 +03:00
Ihor Radchenko 003ddacf1c
org-macro--set-templates: Prevent code evaluation
* lisp/org-macro.el (org-macro--set-templates): Get rid of any
risk to evaluate code when `org-macro--set-templates' is called as a
part of major mode initialization.  This way, no code evaluation is
ever triggered when user merely opens the file or when
`mm-display-org-inline' invokes Org major mode to fontify mime part
preview in email messages.
2024-03-24 17:11:05 +03:00
Kyle Meyer 72a2db86d9 Merge branch 'bugfix' 2024-01-06 16:02:02 -05:00
Po Lu 9f1d6dfd73 Backport commit 8e1c56ae4 from Emacs
; Add 2024 to copyright years
8e1c56ae46754dd7baedff49a464f078f0e9912d
Po Lu
Tue Jan 2 09:47:10 2024 +0800
2024-01-06 15:48:23 -05:00
Ihor Radchenko cb71bde7cb
lisp/org-macro.el (org-macro--get-property): Ignore narrowing
It is implied that we ignore narrowing when searching for property
value.  But `org-link-search' does not.  Widen around its call.
2023-12-15 13:52:07 +01:00
Ihor Radchenko bc29f5de41
org-element: New `org-element-*property*' functions
* lisp/org-element.el (org-element-begin):
(org-element-end):
(org-element-contents-begin):
(org-element-contents-end):
(org-element-post-affiliated):
(org-element-post-blank): New functions for fast access to frequently
used element properties.  The functions are `setf'-able.

Update all the relevant code in Org to use the new functions instead
of genetic property queries.
2023-07-01 14:35:43 +03:00
Ihor Radchenko a7d1dfa171
Use `org-element-type-p'
Use `org-element-type-p' across Org source, except some tests, where `eq' can
produce more meaningful failure explanations.
2023-07-01 14:35:35 +03:00
Ihor Radchenko a8286a5a9e
org-element: Record origin buffer when parsing
* lisp/org-element.el (org-element-parse-buffer): Resolve all the
deferred values in the string.  If not, we might leave pointers to
killed buffer.
(org-element--parse-elements): Resolve deferred in objects.
(org-element--object-lex): Store :buffer property.
* lisp/org-macro.el (org-macro--find-date): Do not try to print
:buffer property.
* lisp/org-element.el (org-element--cache-persist-before-write):
(org-element--cache-persist-after-read): Clear and restore
non-printable buffer objects in :buffer property.
2023-07-01 14:35:26 +03:00
Eli Zaretskii e0815d7545 Backport commit cae528457 from Emacs
; Add 2023 to copyright years.
cae528457cb862dc886a34240c9d4c73035b6659
Eli Zaretskii
Sun Jan 1 05:31:12 2023 -0500
2023-01-01 12:44:47 -05:00
Ihor Radchenko e3a7c01874
Refactor `org-time-stamp-custom-formats' and `org-time-stamp-formats'
* lisp/org.el (org-time-stamp-formats):
* lisp/org.el (org-time-stamp-custom-formats): Change the default
values stripping leading "<" and trailing ">".  Update the docstring
explaining the format and that leading and trailing brackets are now
ignored.  Update the :type specification to more precise.
(org-time-stamp-format): Update the argument list and docstring
allowing to use the function more flexibly to find the time stamp
format for both `org-time-stamp-formats' and
`org-time-stamp-custom-formats'.  Rename `long' argument to more
accurate `with-time'.  Ignore brackets in the `org-time-stamp-formats'
and `org-time-stamp-custom-formats'.  Allow `inactive' argument to be
`no-brackets'
(org-format-timestamp):
(org-read-date-display):
(org-insert-time-stamp):
(org-display-custom-time):
(org-timestamp-translate):
* lisp/org-compat.el (org-timestamp-format): Rename
`org-timestamp-format' to `org-format-timestamp'.  The old variant is
too similar with other `org-time-stamp-format' function.  Also, use
`org-time-stamp-format' to determine the timestamp format instead of
using `org-time-stamp-formats' directly.
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps):
(org-agenda-get-progress):
* lisp/org-archive.el (org-archive-subtree):
(org-archive-to-archive-sibling):
* lisp/org-clock.el (org-clock-special-range):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--find-date):
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/date):
* lisp/ox-odt.el (org-odt--format-timestamp):
(org-odt-template):
* lisp/ox.el (org-export-get-date):
* testing/lisp/test-org.el (test-org/timestamp-format): Use
`org-time-stamp-format' instead of directly examining
`org-time-stamp-custom-formats' and `org-time-stamp-formats'.  Use the
new function name `org-format-timestamp'.
* etc/ORG-NEWS (Default values and interpretations of ~org-time-stamp-formats~ and ~org-time-stamp-custom-formats~ are changed):
(~org-timestamp-format~ is renamed to ~org-format-timestamp~):
(Updated argument list in ~org-time-stamp-format~): Document the
user-facing changes.

This commit documents and unifies previously undocumented assumptions
about the values of `org-time-stamp-formats' and
`org-time-stamp-custom-formats'.  Instead of fiddling with
leading/trailing brackets in the values, expedite the time format
calculation to `org-time-stamp-format'.  The undocumented assumption
about brackets in user option `org-time-stamp-custom-formats' is not
relaxed making the docstring correct.

Reported-by: Uwe Brauer <oub@mat.ucm.es>
Link: https://orgmode.org/list/87k04ppp1t.fsf@localhost
2022-11-07 15:05:37 +08:00
Kyle Meyer 42c418693f Merge branch 'km/from-emacs-master' 2022-10-04 18:37:42 -04:00
Lars Ingebrigtsen 9b62bcc9c6 Backport commit 8dacd8cd9 from Emacs
* lisp/org/org-macro.el (vc-exec-after): Update declaration.

Add a new command vc-pull-and-push
8dacd8cd914fdbe0f6f17ca57915611d48e9124d
Lars Ingebrigtsen
Sat Sep 24 15:19:03 2022 +0200
2022-10-04 17:18:04 -04:00
Paul Eggert 723af4afae Backport commit 8ef37913d from Emacs
* lisp/ol.el (org-store-link):
* lisp/org-clock.el (org-clock-sum)
(org-clock-update-time-maybe):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-2ft, org-matcher-time):
* lisp/org-table.el (org-table-eval-formula):
* lisp/org.el (org-read-date, org-display-custom-time)
(org-time-string-to-time, org-timestamp-change):
Don’t assume Emacs 27 encode-time, since standalone Org still
works with Emacs 25 and it’s easier if we minimize differences
from standalone Org.  Problem reported by Max Nikulin (Bug#54731).
This reverts much of 2021-12-16T17:40:21Z!eggert@cs.ucla.edu.

Port Org encode-time usage back to Emacs 25
8ef37913d3be5ff518018acb6b0144d6e559b5ba
Paul Eggert
Tue Apr 5 17:52:34 2022 -0700

[ km: See main's 8908a1bda (org-macs.el: Introduce a helper for
  `encode-time', 2022-07-17). ]
2022-10-04 16:59:15 -04:00
Paul Eggert 772c44779c Backport commit dd0727e1e from Emacs
* lisp/ol.el (org-store-link):
* lisp/org-clock.el (org-clock-sum)
(org-clock-update-time-maybe):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-2ft, org-matcher-time):
* lisp/org-table.el (org-table-eval-formula):
* lisp/org.el (org-read-date, org-display-custom-time)
(org-time-string-to-time, org-timestamp-change):
Prefer (encode-time L) to (apply #'encode-time L) where either will do.
* lisp/org-clock.el (org-clocktable-steps):
Prefer (encode-time S M ...) to (apply #'encode-time (list S M ...)).

encode-time simplifications
dd0727e1ec1f535b9b06be88173b4d3ccd55abcb
Paul Eggert
Thu Dec 16 11:17:25 2021 -0800

[ km: Note that these changes will be reverted by the port of Emacs's
  8ef37913d. ]
2022-10-04 16:55:56 -04:00
Ihor Radchenko e81a094383
Assert all the Org files to load the same Org version
* lisp/org-compat.el (org-assert-version): New macro comparing Org
version at compile time and laod time.

Add `org-assert-version' call to all files:

* lisp/org-macs.el:
* lisp/org-crypt.el:
* lisp/org-ctags.el:
* lisp/org-cycle.el:
* lisp/org-datetree.el:
* lisp/org-duration.el:
* lisp/org-element.el (avl-tree):
* lisp/org-entities.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-footnote.el:
* lisp/org-goto.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-keys.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-macro.el:
* lisp/org-mobile.el:
* lisp/org-mouse.el:
* lisp/org-num.el:
* lisp/org-pcomplete.el:
* lisp/org-persist.el:
* lisp/org-plot.el:
* lisp/org-protocol.el:
* lisp/org-refile.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-tempo.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-beamer.el:
* lisp/ox-html.el:
* lisp/ox-icalendar.el:
* lisp/ox-koma-letter.el:
* lisp/ox-latex.el:
* lisp/ox-man.el:
* lisp/ox-md.el:
* lisp/ox-odt.el:
* lisp/ox-org.el:
* lisp/ox-publish.el:
* lisp/ox-texinfo.el:
* lisp/ox.el:
2022-09-04 12:24:55 +08:00
TEC 394f494935
org-macro: Require vc in vc-modified-time
* lisp/org-macro.el (org-macro--vc-modified-time): Not all the vc
components needed are autoloaded, allowing for the error:
"vc-call-backend: Symbol’s value as variable is void: vc-log-view-type".
To prevent this issue from cropping up, vc is now required at the start
of `org-macro--vc-modified-time'.
2022-07-25 18:36:12 +08:00
Max Nikulin ae1db7df39
Use `org-encode-time' helper macro
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps)
(org-agenda-get-progress, agenda-bulk-action):
* lisp/org-capture.el (org-capture-fill-template):
* lisp/org-clock.el (org-clock-get-sum-start)
(org-clock-special-range, org-clocktable-shift)
(org-clocktable-steps):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-datetree.el (org-datetree-find-iso-week-create)
(org-datetree-insert-line):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-matcher-time):
* lisp/org.el (org-current-time, org-current-effective-time)
(org-add-planning-info, org-read-date, org-read-date-display)
(org-read-date-analyze, org-eval-in-calendar)
(org-calendar-select, org-display-custom-time)
(org-calendar-select-mouse, org-time-string-to-time)
(org-time-from-absolute, org-at-clock-log-p)
(org-date-from-calendar, org-get-cursor-date)
(org-timestamp-to-time):
* testing/lisp/test-org-clock.el (org-test-clock-create-timestamp):
* lisp/ox-icalendar.el (org-icalendar-convert-timestamp):
Avoid direct calls of `encode-time', use `org-encode-time' instead.

Org supports Emacs-26, but the recommended way to call `encode-time'
changed in Emacs-27.  In Emacs-29 DST and TZ elements of the single list
arguments became optional.  In Org it is still convenient to call the
function with separate arguments without explicit DST and TZ arguments.
The `org-encode-time' should mitigate attempts to modernize Org code
directly in the Emacs repository.
2022-07-17 16:40:18 +08:00
Ihor Radchenko e273fa96e5
Fix function declarations
* lisp/org-macro.el (org-file-contents):
* lisp/ob-exp.el (org-in-commented-heading-p):
(org-in-archived-heading-p): Add missing argument to function
declarations.
2022-06-16 12:35:52 +08:00
Mark A. Hershberger 1537bb4029
Fix signature for org-element-at-point 2022-01-12 22:26:10 +08:00
Kyle Meyer aae2ac3a68 Merge branch 'bugfix' 2022-01-01 15:21:37 -05:00
Kyle Meyer 5a229cbc44 Update copyright year to 2022 2022-01-01 15:17:08 -05:00
Nicolas Goaziou e6c7ea3a36 Merge branch 'bugfix' 2021-12-11 17:21:45 +01:00
TAKAHASHI Yoshio 888689f2ba org-macro: Adjust for compatibility with latest vc (bug#51365)
* lisp/org-macro.el (org-macro--vc-modified-time): Wrap file in a list
when passing to vc-call to avoid a type error starting with Emacs 28.

Before Emacs's 3572613550f (Fix vc-git-state for filenames with
wildcards, 2021-08-15), a string could be given to vc-git-print-log as
the FILES argument because the argument was passed directly as
vc-git-command's FILE-OR-LIST, which as the name suggests, accepts
either a string or a list.  After 3572613550f, passing a string leads
to a type error.

TINYCHANGE
2021-12-11 11:14:03 -05:00
Nicolas Goaziou 266a151d08 Merge branch 'bugfix' 2021-11-02 15:08:37 +01:00
Vinicius f135889ca1 macro: Fix keyword macro with multiple keywords
* lisp/org-macro.el (org-macro-initialize-templates): Properly collect
multiple keywords' values with "keyword" macro.
2021-11-02 15:07:53 +01:00
Nicolas Goaziou d2f4d4b457 Merge branch 'bugfix' 2021-10-23 14:33:18 +02:00
Nicolas Goaziou 52e6f1cf57 macro: Properly collect multiple authors
* lisp/org-macro.el (org-macro--collect-macros): Multiple lines are
allowed for AUTHOR keyword (per `org-export-options-alist') so make
sure we collect all of them.
* testing/lisp/test-org-macro.el (test-org-macro/author): Add test.

Reported-by: Vinicius Vinicius <vinicius.vin@yandex.com>
<http://lists.gnu.org/r/emacs-orgmode/2021-10/msg00727.html>
2021-10-23 14:32:00 +02:00
Ihor Radchenko abe7222ed8
Add declares to suppress compiler warnings 2021-10-17 00:01:56 +08:00
Ihor Radchenko fc80d052db
Re-implement org-element-cache and add headline support
* lisp/org-element.el (org-element-with-disabled-cache): New macro.

(org-element-greater-elements): Add new org-data element.  It
functions like a virtual headline containing the whole buffer.  The
org-data properties are like headlie properties, but according to the
top-level drawer.  org-data's category is the buffer's category as
defined by top-level property drawer, #+CATEGORY keyworsd, and the
buffer file name.

(org-element--cache-element-properties, org-element-set-element): New
variable containing properties to be transferred when updating changed
element in cache in `org-element-set-element'.

(org-element--get-node-properties): Allow parsing node propreties in
top-level drawer when new optional argument is passed.  Respect
PROPERTY+ syntax.

(org-element--get-global-node-properties): New function.  It returns
node properties for top-level property drawer.

(org-element-org-data-parser, org-element-org-data-interpreter):
Implement the new org-data element.

(org-element-headline-parser, org-element-section-parser): Add new
:robust-begin and :robust-end
properties delimiting safe changes that do not modify headline
element.

(org-element--list-struct): Fix cache update when adding a headline
inside list.

(org-element--current-element): Implement cache support.  Record
parsing mode (:mode) and parsing granularity (:granularity) in the
element properties.

(org-element-parse-buffer, org-element--next-mode): Support new
org-data element.

(org-element--parse-elements): Record parsing granularity in the
returned tree

(org-element-use-cache): Enable cache by default.

(org-element-cache-persistent): New variable controlling cache
persistance across sessions.  Enabled by default.

(org-element--cache-self-verify,
org-element--cache-self-verify-frequency,
org-element--cache-diagnostics, org-element--cache-map-statistics,
org-element--cache-map-statistics-threshold,
org-element--cache-diagnostics-level,
org-element--cache-diagnostics-ring,
org-element--cache-diagnostics-ring-size): New variables controlling
cache diagnostics and self-diagnostics.  Greatly simplifies cache
debugging.

(org-element--cache, org-element--cache-sync-requests,
org-element--cache-sync-timer): Make cache buffer-local by default.

(org-element--headline-cache): Implement separate cache storing only
headlines and inlinetasks.

(org-element--cache-size, org-element--headline-cache-size): New
variables containing cache sizes.  This is much faster than
`avl-tree-size'.

(org-element--cache-sync-requests): Update docstring explaning the
request list structure.

(org-element--cache-sync-keys-value): New variable replacing
`org-element--cache-sync-keys' hash table.  The hash table was not
reliable because it was using elements as keys.  Upon any cached
element update/shift, the keys were invalidated making cache ordering
incorrect and breaking the cache badly.  Now, the cache keys are
stored as :org-element--cache-sync-key element property and the new
variable stores marker value indicating the current sync request
cycle.  See `org-element--cache-key' for more details.

(org-element--cache-change-tic): New variable controlling buffer
modification count that is registered in cache.  This variable allows
catching "stealth" edits.

(org-element--cache-non-modifying-commands): New variable listing
commands that will not be slown down if we fill cache on the fly.

(org-element--request-key, org-element--request-beg,
org-element--request-end, org-element--request-offset,
org-element--request-parent, org-element--request-phase): New macros.
They improve code readability (especially when using nameless-mode).

(org-element--format-element, org-element--cache-log-message,
org-element--cache-warn): New macros implementing generic logging
functionality.

(org-element--cache-key): Add section and org-data element support.
Change cache key storage from hash map to :org-element--cache-sync-key
element property + `org-element--cache-sync-keys-value'.  We use the
latter to group all the cache keys during a single cache request
sequence.  Once sync request is fully complete, the
`org-element--cache-sync-keys-value' is updated making all the old
sync keys obsolete (they will still be store as element properties).

(org-element--headline-cache-root): New function returning headline
cache root.

(org-element--cache-active-p): Prevent cache updates when
`inhibit-modification-hooks' is non-nil, unless non-nil optional
argument is provided.

(org-element--cache-find): Share cache between indirect buffers and
the base buffer.  We have to do it because after-change hooks for
indirect buffer are not called in the base buffer and vice versa.  Add
support for section and org-data elements.

(org-element--cache-put): Implement new approach for cache key
storage.  Add diagnostics.  Indicate cached elements using :cached
element property.  Support cache size calculation.

(org-element--cache-remove): Invalidate parent contents when removing
element.  Support cache size calculation.  Detect cache corruption due
to misordered elements.

(org-element--cache-shift-positions): Support :robust-begin and
:robust-end element properties.

(org-element--cache-sync): Add diagnostics.  Add detailed comments.
Prevent slowdown when large cache chunks need to be deleted forcing
O(N) complexity cutoff.  In phase 2, fix cases when next request
contains deleted cache key.  In phase 2, fix scenario when newly
inserted element intersects with existing elements in cache.  In phase
2, detect obsolete parents removed from cache.

(org-element--open-end-p): New function checking if an element can
have blank lines right after its :contents-end.

(org-element--parse-to): Do not alter match data.  Process complex
parsing mode changes correctly.  Support headlines in cache.  Support
org-data parsing.  Add detailed comments.  Add diagnostics.

(org-element--cache-sensitive-re): Make list lines sensitive.

(org-element--cache-change-warning): Update docstring.  Now, the
variable can have t, nil, and number values.  Numbers are used to
provide more details about changed headlines.

(org-element--cache-before-change, org-element--cache-after-change):
Handle headline hierarchy.  Properly handle cache in indirect
buffers.

(org-element--cache-after-change): Update docstring clarifying the
return values.  Add special handling for headline and org-data
elements updating them in-place instead of removing together with the
whole contents when possible.  Use :robust-begin/:robust-end element
properties to detect robust changes.

(org-element--cache-submit-request): Add detailed comments.  Correctly
handle cache in indirect buffers.  Delegate element modifications to
`org-element--cache-for-removal'.

(org-element--cache-verify-element): New function for cache
self-verification.

(org-element--cache-persist-before-write,
org-element--cache-persist-before-read,
org-element--cache-persist-after-read): Implement cache persistance.

(org-element-cache-reset): Correctly handle cache in indirect
buffers.  Support cache persistance.  Support new cache size
calculation and new cache key schema.

(org-element-cache-map): New function analagous to `org-element-map',
but much faster.  The function overperforms org-ql written by Adam
Porter aka alphapapa [1] and reuses some ideas from there (namely,
fast element skipping via regexps).

[1] https://github.com/alphapapa/org-ql/

(org-element-at-point): The returned elements are now guaranteed to
have correct parents up to org-data.  New optional argument
CACHED-ONLY limits element search to current cache---if element is not
in cache and current command is not in cache
`org-element--cache-non-modifying-commands', the cache is not updated
and the function returns nil.  Also, support cache verification.

(org-element-at-point-no-context): New function.  It is analogous of
older `org-element-at-point' with no guarantee that :parent properties
are correct beyond direct parent heading.  This function does not
update cache and can be useful when cache updates should be avoided
for performance reasons.

* lisp/ob-core.el (org-babel-where-is-src-block-result): Support
section and org-data elements in cache.

* lisp/org-macro.el (org-macro-replace-all,
org-macro--find-keyword-value): Support org-element-cache.

* lisp/org-table.el (orgtbl-to-generic): Support org-element-cache.

* lisp/org.el (org-mode): Add cache persistance.

(org-up-element): Preserve old behaviour when error is returned for
section and org-data element.

*
testing/lisp/test-org-archive.el (test-org-archive/update-status-cookie):
Fix test when cache is active.

* testing/lisp/test-org-colview.el (test-org-colview/columns-update):
Fix test.

* testing/lisp/test-org-element.el (test-org-element/extract-element):
Add suport for new org-data element.

* testing/lisp/test-org-element.el (test-org-element/parent-property):
Fix equality check.  Parents returned by cache and `org-element-map'
may not be `eq' now.  Just `equal'.

* testing/lisp/test-org-element.el (test-org-element/context): Support
section and headline parents.
2021-10-16 23:22:18 +08:00
Stefan Kangas 51cdd6e30f Various minor docfixes found by checkdoc 2021-09-16 21:24:59 +02:00
Nicolas Goaziou 6de34f2891 Move `org-file-url-p' to "org-macs.el", rename it to `org-url-p'
* lisp/org-macs.el (org-url-p): New function.
* lisp/org-compat.el (org-file-url-p): Make obsolete alias for
function above.
* lisp/org-lint.el (org-lint-non-existent-setupfile-parameter):
* lisp/org.el (org--collect-keywords-1):
(org-file-contents):
(org-edit-special): Use new function.
2021-05-18 16:31:39 +02:00
Nicolas Goaziou 772f7acb65 macro: Fix modification-time macro
* lisp/org-macro.el (org-macro-initialize-templates): Make second
argument optional for modification-time macro.
2021-04-19 01:11:37 +02:00
Stefan Monnier 8e68eac0bd macro: Do not generate macros with (&optional &rest _) signature
* lisp/org-macro.el (org-macro--makeargs): Fix Emacs-26 burping
because of a bug when functions are declared with 0 optional arguments
like (&optional &rest x).
2021-04-17 11:45:40 +02:00
Stefan Monnier 8abdbbee39 macro: Improve speed for `eval' macros
* lisp/org-macro.el (org-macro--makeargs): New function.
(org-macro--set-templates): New function.
(org-macro--set-template): Remove function.
(org-macro-initialize-templates): Add optional argument to
signature. Add macro definitions as functions.
(org-macro-expand): Allow functions as macro definitions.
(org-macro--counter-increment): Handle nil argument.
* lisp/ox.el (org-export-as): Apply signature change for
`org-initialize-templates'.

The main difference with the previous behaviour is that missing
arguments are now treated as nil instead of the empty string.

See <http://lists.gnu.org/r/emacs-orgmode/2021-04/msg00219.html>.
2021-04-16 16:37:22 +02:00
Kyle Meyer 99eafe3787 Update copyright year to 2021 2021-01-01 14:59:01 -05:00
Nicolas Goaziou 3e44ddbe78 macro: Small refactoring.
* lisp/org-macro.el (org-macro--collect-macros): Use
`org-collect-keywords'.
2020-04-26 22:57:47 +02:00
Nicolas Goaziou 7e38f69178 Merge branch 'maint' 2020-03-11 21:53:25 +01:00
Nicolas Goaziou 685b2c4410 org-macro: Fix last commit
* lisp/org-macro.el (org-macro--set-template): Do not override value
with an empty one.

This is a followup to 965cdbfd4b.
2020-03-11 21:52:19 +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
Bastien 6a1f6ee1f8 Tiny formatting fixes
* lisp/ox.el (org-export-table-dimensions):
* lisp/ox-texinfo.el (org-texinfo-template):
* lisp/ox-md.el (org-md-link):
* lisp/ox-icalendar.el (org-icalendar-use-UTC-date-time-p):
* lisp/ox-ascii.el (org-ascii-fixed-width):
* lisp/org.el (org-context):
* lisp/org-table.el (org-table-eval-formula)
(org-table-export):
* lisp/org-refile.el:
* lisp/org-plot.el (org-plot/gnuplot-to-grid-data):
* lisp/org-num.el (org-num):
* lisp/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org-macro.el (org-macro):
* lisp/org-lint.el (org-lint):
* lisp/org-keys.el (org-keys):
* lisp/org-duration.el:
* lisp/org-clock.el (org-clock-get-last-clock-out-time)
(org-clock-update-mode-line, org-find-open-clocks):
* lisp/org-agenda.el (org-diary)
(org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)
(org-agenda-highlight-todo, org-cmp-alpha)
(org-agenda-filter-by-category):
* lisp/ol.el (org-link-expand-abbrev, ol):
* lisp/ol-docview.el (ol-docview):
* lisp/ol-bibtex.el (org-execute-file-search-in-bibtex)
(org-bibtex, org-bibtex-read):
* lisp/ol-bbdb.el (org-bbdb-anniversary-description):
* lisp/ob-tangle.el (org-babel-tangle-jump-to-org):
* lisp/ob-table.el (org-babel-table-truncate-at-newline):
* lisp/ob-stan.el:
* lisp/ob-sqlite.el (org-babel-sqlite-table-or-scalar):
* lisp/ob-sql.el:
* lisp/ob-shen.el:
* lisp/ob-shell.el (org-babel-prep-session:shell)
(org-babel-prep-session:shell):
* lisp/ob-sed.el (org-babel-execute:sed)
(org-babel-execute:sed):
* lisp/ob-screen.el:
* lisp/ob-sass.el:
* lisp/ob-ruby.el (org-babel-prep-session:ruby)
(org-babel-prep-session:ruby):
* lisp/ob-ref.el (org-babel-ref-resolve, ob-ref):
* lisp/ob-python.el (org-babel-prep-session:python)
(org-babel-prep-session:python):
* lisp/ob-plantuml.el:
* lisp/ob-picolisp.el:
* lisp/ob-perl.el:
* lisp/ob-org.el:
* lisp/ob-octave.el (org-babel-prep-session:octave)
(org-babel-prep-session:octave)
(org-babel-octave-evaluate-session):
* lisp/ob-ocaml.el:
* lisp/ob-mscgen.el (org-babel-execute:mscgen)
(org-babel-execute:mscgen):
* lisp/ob-maxima.el:
(ob-maxima):
* lisp/ob-matlab.el:
* lisp/ob-makefile.el:
* lisp/ob-lua.el (org-babel-prep-session:lua)
(org-babel-prep-session:lua):
* lisp/ob-lisp.el:
* lisp/ob-ledger.el:
* lisp/ob-latex.el (org-babel-expand-body:latex)
(org-babel-expand-body:latex, ob-latex):
* lisp/ob-js.el:
* lisp/ob-java.el:
* lisp/ob-io.el (org-babel-prep-session:io)
(org-babel-prep-session:io):
* lisp/ob-hledger.el:
* lisp/ob-haskell.el:
* lisp/ob-groovy.el (org-babel-groovy-wrapper-method)
(org-babel-groovy-evaluate):
* lisp/ob-gnuplot.el:
* lisp/ob-fortran.el (org-babel-expand-body:fortran)
(org-babel-expand-body:fortran):
* lisp/ob-forth.el (org-babel-forth-session-execute):
* lisp/ob-exp.el (ob-exp):
* lisp/ob-eval.el:
* lisp/ob-emacs-lisp.el:
* lisp/ob-ebnf.el:
* lisp/ob-dot.el:
* lisp/ob-ditaa.el:
* lisp/ob-css.el:
* lisp/ob-core.el (org-babel-put-rownames):
* lisp/ob-coq.el:
* lisp/ob-comint.el:
* lisp/ob-calc.el:
* lisp/ob-awk.el:
* lisp/ob-asymptote.el:
* lisp/ob-abc.el:
* lisp/ob-R.el (org-babel-prep-session:R): Formatting fixes.
2020-02-18 22:57:37 +01:00
Kyle Meyer ff5fc050d3 Update copyright year to 2020 2020-01-01 13:38:46 -05:00
Nicolas Goaziou 9bbae3ce8f Merge branch 'maint' 2019-04-29 20:49:09 +02:00
Nicolas Goaziou 727c3f442b org-macro: Exit early when looking for keywords
* lisp/org-macro.el (org-macro--find-keyword-value): Change signature.
* testing/lisp/test-org-macro.el (test-org-macro/keyword): Remove
  a test.
2019-04-29 20:48:00 +02:00
Nicolas Goaziou 14132a356a Collect buffer-specific built-in macros in setup files
* lisp/org-macro.el (org-macro--set-template): New function.
(org-macro--collect-macros): Also collect "author", "email", "title"
and "date" macros.
(org-macro-initialize-templates): Do not collect previous macros here,
when it is too late.
(org-macro--find-date): New function.
* testing/lisp/test-org-macro.el (test-org/macro-replace-all): Remove
  test, since we cannot guarantee anymore that user-defined macros can
  take precedence over built-in ones.

Reported-by: emsenn <emsenn@emsenn.net>
<http://lists.gnu.org/r/emacs-orgmode/2019-04/msg00234.html>
2019-04-29 20:35:23 +02:00
Nicolas Goaziou 7e58160367 Fix "File mode specification error"
This reverts "org-element: Do not require 'org", which does not seem
trivial at the moment.

Reported-by: Amin Bandali <bandali@gnu.org>
<http://lists.gnu.org/r/emacs-orgmode/2019-03/msg00117.html>
2019-03-12 10:43:25 +01:00
Paul Eggert d64c9a996b Backport commit 662bee7d7 from Emacs
* lisp/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org-attach.el (org-attach-commit):
* lisp/org-macro.el (org-macro-initialize-templates):
* lisp/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/ox-html.el (org-html-format-spec):
* lisp/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* lisp/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.

file-attributes cleanup
662bee7d70ccd3903e123b08c7ec9108a1a2ce0b
Paul Eggert
Sun Sep 23 18:32:59 2018 -0700
2019-01-13 12:43:04 -05:00
Bastien f584d37a67 Update copyright year 2019-01-01 11:50:56 +01:00
Nicolas Goaziou f5c2659bb8 Use `org-strip-quote' when possible
* lisp/org-macs.el (org-unbracket-string):
(org-strip-quotes): Allow nil values.
* lisp/org-lint.el (org-lint-wrong-include-link-parameter):
* lisp/org-macro.el (org-macro--collect-macros):
* lisp/org.el (org--setup-collect-keywords):
(org-edit-special):
* lisp/ox.el (org-export--get-inbuffer-options):
(org-export--list-bound-variables):
(org-export-expand-include-keyword): Use `org-strip-quote' instead of
`org-unbracket-string' whenever possible.
2018-11-10 08:58:31 +01:00
Nicolas Goaziou 3be2260806 Silence byte-compiler
* lisp/ob-emacs-lisp.el:
* lisp/org-macro.el: Silence byte-compiler.
2018-10-01 21:33:49 +02:00