Commit Graph

427 Commits

Author SHA1 Message Date
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
Nicolas Goaziou 7d35d46494 Fix :package-version values
* lisp/ol.el (org-link-email-description-format):
* lisp/org-src.el (org-src-tab-acts-natively):
* lisp/org-table.el (org-table-header-line-p):
* lisp/org.el (org-loop-over-headlines-in-active-region):
(org-fontify-done-headline): Use correct (PACKAGE . VERSION-STRING)
value.  Remove :version keyword since :package-version overrides it.
2020-05-06 02:12:23 +02:00
Bastien e360cd8f3a Change the default values for several options
* doc/org-manual.org (Execute commands in the active region):
Update the manual given the new defaults.

* etc/ORG-NEWS (New default settings for some options): New
section.

* lisp/org.el (org-loop-over-headlines-in-active-region):
Change the default value to `t'.
(org-fontify-done-headline): Ditto.

* lisp/org-agenda.el
(org-agenda-loop-over-headlines-in-active-region): Ditto.

* lisp/org-src.el (org-src-tab-acts-natively): Ditto.
2020-02-21 16:35:56 +01:00
Bastien 5dd7721242 Use `org-switch-to-buffer-other-window' in a few places
* lisp/org-src.el (org-src-switch-to-buffer):
* lisp/org-attach.el (org-attach):
* lisp/ob-lilypond.el (org-babel-lilypond-execute-tangled-ly)
(org-babel-lilypond-mark-error-line): Use
`org-switch-to-buffer-other-window' instead of
`switch-to-buffer-other-window'.
2020-02-17 09:04:19 +01:00
Bastien eace60ad39 Merge branch 'maint' 2020-02-03 18:24:35 +01:00
Bastien 77968ce3a3 Revert "org-src.el: Enhance `org-edit-src-code'"
This reverts commit cad2a6a588.
2020-02-03 18:21:26 +01:00
Bastien 5922dab4b9 Merge branch 'maint' 2020-02-03 13:12:05 +01:00
Bastien cad2a6a588 org-src.el: Enhance `org-edit-src-code'
* lisp/org-src.el (org-edit-src-code): Don't throw an error
when trying to find the source language in a non-interactive
call, typically when called for template expansion.

Thanks to Tyler Smith and Jack Kamm for reporting a related bug.
2020-02-03 13:09:34 +01:00
Jack Kamm cd1014a75a org-src: Add call to quit-restore-window in org-src-switch-to-buffer
* lisp/org-src.el (org-src-switch-to-buffer): Add call to
quit-restore-window in org-src-switch-to-buffer when
org-src-window-setup is other-window so that the popped up window is
closed on exit.
2020-01-24 23:12:22 -05:00
Jack Kamm 7d5e931f79 org-src: Add option `plain' to org-src-window-setup
* lisp/org-src.el (org-src-window-setup): Add option `plain' for
org-src-window-setup, that uses vanilla display-buffer to show the
source window.
2020-01-24 23:06:40 -05:00
Jack Kamm d833920def org-src: restore windows for some values of org-src-window-setup 2020-01-16 16:09:42 +01:00
Kyle Meyer ff5fc050d3 Update copyright year to 2020 2020-01-01 13:38:46 -05:00
Sebastian Miele 3649d95b13 Respect buffer-local value of `org-edit-src-content-indentation'
* lisp/org-src.el (org-src--content-indentation): Introduce
permanently buffer-local variable for storing away the potentially
buffer-local value of `org-edit-src-content-indentation' in the source
buffer.

(org-src--contents-for-write-back): Use `org-src--content-indentation'
instead of `org-edit-src-content-indentation' in the edit buffer.

(org-src--edit-element): Set `org-src--content-indentation' in editing
buffer.  For greater clarity and consistency, rename already existing
let-bound variable `ind' to `block-ind'.
2019-11-20 22:29:30 +01:00
Eric S Fraga cfe4598aa1 Add split-window-right option for editing source blocks
* org-src.el (org-src-window-setup, org-src-switch-to-buffer): Added
  new split-window-right option which splits horizontally.

This has been motivated by the increasing use of wide monitors.
2019-08-17 15:26:32 +02:00
Nicolas Goaziou c0218ea746 org-src: New `org-src-get-lang-mode' function
* lisp/org-src.el (org-src-get-lang-mode): New function.
(org-src--get-lang-mode): Rename to `org-src-get-lang-mode'.
(org-src-font-lock-fontify-block):
(org-edit-latex-environment):
(org-edit-export-block):
(org-edit-src-code):
(org-edit-inline-src-code): Use new function.
2019-04-07 09:16:36 +02:00