Commit Graph

441 Commits

Author SHA1 Message Date
Ihor Radchenko 8eb3f93748
Fix wide docstring warnings
* lisp/ob-core.el (org-babel-expand-noweb-references--cache-buffer):
* lisp/org-src.el (org-edit-comment-block): Update docstrings.
2022-08-20 14:27:17 +08:00
Ihor Radchenko 00adad9357
org-src: Fix invisible text in src block fontification
* lisp/org-src.el (org-src-font-lock-fontify-block): If fontified text
has `invisible' text property, avoid interfering with Org folding
making the invisibility of lower priority compared to folding.

Fixes https://orgmode.org/list/87zgghrsd2.fsf@gmail.com
2022-08-07 18:33:11 +08:00
Ihor Radchenko a303a794f8
Support interactive editing of comment blocks
* lisp/org-src.el (org-edit-comment-block): New command to edit
comment block elements.  The command auto-escapes Org markup inside.
(org-src--contents-area):
* lisp/org.el (org-insert-structure-template):
(org-edit-special): Support comment blocks.
* etc/ORG-NEWS (Interactive commands now support escaping text inside
comment blocks):
(New command ~org-edit-comment-block~ to edit comment block at point):
Document the new features.

See https://orgmode.org/list/87y1wc3ruw.fsf@mat.ucm.es
2022-08-07 17:39:08 +08:00
Paul Eggert 6013cb161d Fix doc string quoting problems with '
The Emacs doc string convention is to document values as-is when that
is clear, and surrounded by `single quotes' otherwise. For example, a
doc string "(a b c)" stands for a list of symbols, and the doc string
"`a'" stands for a single symbol. The doc string "\\=`a" is typically
not correct for that single symbol, because that is equivalent to
"(quote a)" and the typical intent is to talk about the symbol, not
about the Lisp quoting construct.  One needs "\\=`X" only when talking
about something intended to be equivalent to "(quote X)", as in the
doc string "(provide \\='org-xyz)".
2022-07-25 13:10:29 -07:00
Ihor Radchenko 03543e17dd
org-src-font-lock-fontify-block: Transfer 'font-lock-face property
* lisp/org-src.el (org-src-font-lock-fontify-block): Copy
'font-lock-face text property in addition to 'face.  This is required
because Emacs does not enable `font-lock-mode' inside buffers with
names starting from space character (Org fontification buffers are
such).  Without `font-lock-mode' 'font-lock-face is not being remapped
to 'face text property and we may sometimes lose the information in
the major modes that do fontification by directly setting
'font-lock-face.

Reported in https://teddit.net/r/orgmode/comments/w2b0tw/syntax_highlighting_in_orgsource_blocks/igqdx18/
2022-07-19 12:19:57 +08:00
Matt Rudary a7cc95c60c
org-src.el: Add plain to org-src-window-setup customization
* lisp/org-src.el (org-src-window-setup): Add plain to the list of
valid choices for `org-src-window-setup'.

A previous change added it to the documentation and to the pcase that
process this variable in `org-src-switch-to-buffer', but the defcustom
did not include it as a valid option.

TINYCHANGE
2022-07-09 12:04:07 +08:00
Stefan Kangas 0ed0dea229
Delete some Emacs 24 compat code
Org mode supports Emacs 26 or newer:
https://orgmode.org/worg/org-maintenance.html#emacs-compatibility

* lisp/org-compat.el (org-set-transient-map)
(org-font-lock-ensure): Delete compat aliases.  Update callers.
(org-define-error): Redefine as obsolete function alias for
`define-error'.  Update callers.
(string-suffix-p): Delete compatibility definition.

* lisp/org-fold-core.el (org-fold-core--seq-partition): Delete private
function and update callers to use `seq-partition'.

* lisp/org-macs.el (org-without-partial-completion): Move from here...
* lisp/org-compat.el (org-without-partial-completion): ...to here.
Redefine as obsolete function alias for `progn'.
2022-07-02 12:10:00 +08:00
Stefan Kangas 41e19f1d7a
; Fix typos 2022-07-01 17:42:52 +08:00
Stefan Kangas 13d97ee18c
Prefer "website" to "homepage"
Emacs now advises using "website" (instead of "homepage") and
consequently to use the "URL" comment header instead of "Homepage".

* README:
* README_ELPA:
* doc/org-guide.org (Creating Footnotes):
* doc/org-manual.org (Creating Footnotes):
* etc/styles/README (URL): Prefer "website" to "homepage".

* lisp/*.el:
* mk/org-fixup.el: Replace the "Homepage" header comment with "URL".
2022-06-26 10:10:48 +08:00
Ihor Radchenko 66528468a1
org-src-font-lock-fontify-block: Do not transfer non-existing properties
* lisp/org-src.el (org-src-font-lock-fontify-block): Never set
font-lock properties when `get-text-property' returns nil.  This
usually means that the property is not present in the position
property list.  The old behavior could, for example, set 'invisible
property to nil explicitly and prevent folding completely.

Fixes https://list.orgmode.org/CA+G3_PN6RvcRcvN2fM=vfK1K6UsT=nNPJ7SUucmA1Ypc=Emorg@mail.gmail.com/T/#u
2022-05-28 09:35:32 +08:00
Marco Wahl 4f0f244477 Revert "org-src: Add RET to go from overlay to edit buffer"
This reverts commit 0d39ea6ef3.
2022-05-19 12:20:31 +02:00
Marco Wahl 0d39ea6ef3 org-src: Add RET to go from overlay to edit buffer
* lisp/org-src.el (org-edit-src-goto): org-edit-src-goto factors out
the functionality from org-edit-src-continue.  The latter needs an event.

The return key is bound to org-edit-src-goto for the overlay.
2022-05-18 22:50:33 +02:00
Ihor Radchenko fa7530c7b4
Rename old function call to use org-fold 2022-04-25 19:39:53 +08:00
TEC cbe3f2d697
org-src: add toml and desktop lang aliases
* lisp/org-src.el (org-src-lang-modes): It is reasonable to assume that
src blocks with the "toml" and "desktop" lang should use
`conf-toml-mode' and `conf-desktop-mode', respectively.
2022-04-03 01:01:04 +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
Ihor Radchenko 7ac37478ca
org-src.el: Fix nativecomp warnings
* lisp/org-src.el: Declare `org-element--parse-paired-brackets'
function.  Declare `org-src-fontify-natively' variable.
2021-12-08 10:29:39 +08:00
TEC 521c534101
org-src: Refactor inline src block fontify lines
* lisp/org-src.el (org-fontify-inline-src-blocks-1): Refactor
`org-fontify-inline-src-blocks-1' to bring down the maximum line
length.  While we're at it, get rid of the debugging `message' call that
somehow made its way in, and an unused variable in the `let' statement.
2021-12-02 19:33:28 +08:00
TEC bb6f328847
org-src: Implement native inline src fontification
* lisp/org-src.el (org-fontify-inline-src-blocks,
org-fontify-inline-src-blocks-1): Create a function to search the buffer
up to a limit for inline src blocks.  Light fontification is applied to
matched inline src blocks.  When `org-src-fontify-natively' is
set, `org-src-font-lock-fontify-block' is applied to the content.

* lisp/org.el (org-set-font-lock-defaults): Add
`org-fontify-inline-src-blocks' to `org-font-lock-extra-keywords', which
is locally bound inside `org-set-font-lock-defaults'.

* lisp/org-faces.el: Introduce a new face `org-inline-src-block' which
inherits from `org-block' by default.
2021-11-30 12:14:11 +08:00
Clément Pit-Claudel ebd06c15b5
org-src: Reset buffer-modified-p after fontifying
* lisp/org-src.el (org-src-font-lock-fontify-block): Reset the
modification flag of the temporary fontification buffer after
fontifying.

Without this some modes cause Emacs to prompt about unsaved buffers
when exiting: "Save buffer *org-src-fontification:...-mode*?".
2021-11-21 14:59:43 +08:00
Ihor Radchenko 004ac14a5b
Fix compatibility with Emacs 26
* lisp/org-compat.el (org-file-name-concat): Do not use
`string-empty-p'.
(combine-change-calls): Create a stub when `combine-change-calls' were
not yet available.
(org-replace-buffer-contents): Add compatibility function for
`replace-buffer-contents'.

* lisp/org-element.el (org-element--current-element): Do not use
`if-let'.
* lisp/org-persist.el (org-persist-gc): Do not use `when-let'.
* lisp/org-plot.el (org-plot/gnuplot): Do not use `if-let'.
* lisp/org-src.el (org-edit-src-save, org-edit-src-exit): Use
`org-replace-buffer-contents'.

* lisp/org.el (org-narrow-to-subtree, org--property-local-values,
org-entry-get-with-inheritance, org-in-commented-heading-p,
org-up-heading-safe, org-goto-first-child): Do not use
`if-let'/`when-let'.

* testing/org-test.el (org-test-at-time): Fallback to old
`decode-time' specification in older Emacs.
2021-10-17 14:34:10 +08:00
Nicholas Vollmer aa6f8ed877 org-src.el: Fix checkdoc warnings
* org-src.el: Fix checkdoc warnings.
2021-10-02 17:10:15 +02:00
Kyle Meyer 8bc222bce6 org-src: Silence byte-compiler under 'make single'
This warning shows up when compiling in the Emacs repo, too.
2021-09-30 21:27:41 -04:00
Sébastien Miquel e1c49af76d org-src.el: Fix special editing of LaTeX fragments
* lisp/org-macs.el (org-do-remove-indentation): Add optional argument
to skip the first line.
* lisp/org-src.el (org-src--coordinates): Fix coordinates for inline
LaTeX fragments.
(org-src--contents-for-write-back): Do not indent first line for LaTeX
fragments.
(org-src--edit-element): Compute block-indentation according to parent
for LaTeX fragments.  Skip first line when removing common indentation
for LaTeX fragments.
2021-09-30 16:16:52 +02:00
Bastien 806ac1b7f6 *el: Fix indentation 2021-09-29 09:22:47 +02:00
Sébastien Miquel 70e65a2028 org-src.el: Do not indent blank lines, except current one
* lisp/org-src.el (org-src--contents-for-write-back): Do not indent blank lines, except for the
current line maybe.
(org-src--preserve-blank-line): New variable, whether to preserve
indentation of the current blank line.
(org-src--edit-element): Set `org-src--preserve-blank-line'.
* lisp/org.el (org-indent-line): When tab acts natively, do some
preindentation, which signals `org-src--edit-element' to
preserve the indentation of current blank line.

Removing all the whitespace was the original behaviour for all blank lines, before `857ae366b3`.
2021-09-26 07:47:40 +02:00
Bastien ee0fd1ec31 Revert "org-src.el (org-src--contents-for-write-back): Do not indent blank lines"
This reverts commit 35690cd04f.
2021-09-26 07:47:24 +02:00
Sébastien Miquel 35690cd04f org-src.el (org-src--contents-for-write-back): Do not indent blank lines
* lisp/org-src.el (org-src--contents-for-write-back): Do not indent
blank lines, except for the current line.

This was the original behaviour for all blank lines, before `857ae366b3`.
2021-09-26 07:46:42 +02:00
Stefan Kangas 51cdd6e30f Various minor docfixes found by checkdoc 2021-09-16 21:24:59 +02:00
Sébastien Miquel e2550506eb src: Use `replace-buffer-contents' only for emacs >= 27
* lisp/org-src.el (org-edit-src-save):
(org-edit-src-exit): Use `replace-buffer-contents' only for emacs >=
27.

It was introduced in emacs 26.1, but earlier versions made no
guarantees of correctness.
2021-06-27 15:53:22 +02:00
Bastien 0c85c8d7ed Merge branch 'maint' 2021-05-18 16:06:39 +02:00
Sébastien Miquel 857ae366b3 org.el (org-src--contents-for-write-back): Indent blank lines
* lisp/org.el (org-src--contents-for-write-back): Indent blank lines.
* lisp/org-src.el (org-return): Revert part of commit bfda3cc7df.
2021-05-18 16:06:27 +02:00
Bastien b2be3dd0e0 Merge branch 'maint' 2021-05-16 21:53:05 +02:00
Sébastien Miquel a9af1faaa1 org-src.el (org-edit-src-exit): Fix write-back-buf not getting killed
* lisp/org.el (org-edit-src-exit): Fix write-back-buf not getting
killed
2021-05-16 21:52:15 +02:00
Bastien e738211f73 Merge branch 'maint' 2021-05-16 14:11:08 +02:00
Sébastien Miquel d65ae82f4b lisp/org-src.el: Continue the previous fix (d02ad1f2)
* lisp/org-src.el (org-src--contents-for-write-back): Shorten the
first line of the docstring.
(org-edit-src-exit): Conditionnally kill the write-back buffer.
2021-05-16 14:10:04 +02:00
Bastien aac4a2d597 Merge branch 'maint' 2021-05-16 14:02:07 +02:00
Sébastien Miquel d02ad1f207 lisp/org-src.el: Use `replace-buffer-contents'
* lisp/org-src.el (org-src--contents-for-write-back): Use a write
back buffer.

* lisp/org-src.el (org-edit-src-exit, org-edit-src-save): Use
`replace-buffer-contents'.

Reported-by: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
Link: https://orgmode.org/list/603f9c4e-c621-7592-5b20-a7354c11d5d2@posteo.eu/
2021-05-16 14:01:57 +02:00
Bastien 0f2ece647b Update Carsten's email address in some files 2021-05-07 16:50:57 +02:00
Bastien Guerry c1f576a7e5 Merge branch 'maint' 2021-05-01 11:57:37 +02:00
TEC 400d2d9fd7 org-src: Use point instead of column for coords
* lisp/org-src.el (org-src--coordinates)
(org-src--goto-coordinates): Use point instead of column.

Using a column-based approach fails to account for invisible regions
or display overlays that change the number of columns: for example,
showing a LaTeX \alpha as α.  In src edits which involve such
structures, this causes the point to be shifted undesirably.  By using
a point-based approach this issue does not occur.
2021-05-01 11:57:27 +02:00
Stefan Monnier 8c29cbdef7 Backport commit c45bfd3c4 from Emacs
* lisp/ox-beamer.el (org-beamer-mode-map): Move initialization
into declaration.
(org-beamer-mode):
* lisp/org.el (org-cdlatex-mode):
* lisp/org-table.el (org-table-header-line-mode)
(org-table-follow-field-mode, orgtbl-mode):
* lisp/org-src.el (org-src-mode):
* lisp/org-list.el (org-list-checkbox-radio-mode):
* lisp/org-indent.el (org-indent-mode):
* lisp/org-capture.el (org-capture-mode):
Avoid old-style positional args to `define-minor-mode`.

* lisp/**/*.el: Avoid positional args to `define-minor-mode`
c45bfd3c4abbfa585c9199f4866b6b8046945117
Stefan Monnier
Sun Apr 11 23:47:14 2021 -0400
2021-04-18 02:11:35 -04:00
Kyle Meyer 99eafe3787 Update copyright year to 2021 2021-01-01 14:59:01 -05:00
Kyle Meyer d7d714c7d5 Silence byte-compiler in Emacs repo
These show up in the Emacs repo (before and after the latest sync in
f22856a5c5), but for an unknown reason do not show up with `make
compile' or `make single' in the Org repo.

All of these functions are autoloaded.
2020-12-13 13:56:29 -05: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
Nicolas Goaziou b51d129f3f src: Fix typo
* lisp/org-src.el (org-edit-latex-fragment): Fix typo.
2020-05-26 23:09:52 +02:00
TEC f5c47d857c Extend org-edit-special to editing LaTeX fragments
* lisp/org-src.el (org-src--contents-area): Handle `latex-fragment'.
(org-edit-latex-fragment): New function.
* lisp/org.el (org-edit-special): Use new function.
2020-05-26 23:03:11 +02:00
Nicolas Goaziou 5454312dbf Merge branch 'maint' 2020-05-25 12:37:44 +02:00
Nicolas Goaziou 784054bc94 src: Replace newline with blanks when editing inline source code
* lisp/org-src.el (org-edit-footnote-reference): Do not remove newline
completely.
2020-05-25 12:36:35 +02:00