Compare commits

...

5 Commits

Author SHA1 Message Date
TEC 28bfdb6b78
---END PERSONAL NOPUSH DIVIDER---
--
2.42.0
2024-02-20 16:58:05 +08:00
TEC a7a0c945c5
NOPUSH org: Don't fill displayed equations in text
* list/org.el (org-fill-element): If a displayed equation (\[ ... \])
starts on its own line, it should not be filled into the rest of the
text. I.e.,

some nice text
\[
  1+1=2
\]
more text.

should not become,

some nice text \[ 1+1=3 \] more text.

While the above example may not look bad, with non-trivial equations
this can become quite messy.
2024-02-20 16:58:05 +08:00
TEC 4e498564c8
NOPUSH org-src: Prettify inline results
* lisp/org.el (org-inline-src-prettify-results):

* lisp/org-src.el (org-fontify-inline-src-blocks-1):
2024-02-20 16:58:05 +08:00
TEC 3ee9efdf8f
---NOPUSH PERSONAL DIVIDER---
--
2.42.0
2024-02-20 16:58:05 +08:00
Karthik Chikmagalur 0c2073f4f9
org-latex-preview: Fix bug when checking previews
*
lisp/org-latex-preview.el (org-latex-preview--check-all-fragments-produced):
When the first fragment in a preview run silently fails to render,
this function tries to cache a nil value as a fragment.  Fix by
checking that the fragment that fails to render is valid as a
fragment.
2024-02-20 16:58:05 +08:00
3 changed files with 57 additions and 5 deletions

View File

@ -2376,11 +2376,10 @@ fragments are regenerated."
;; If output ends prematurely, this is most likely due to an issue with
;; the last "succesfully" produced fragment, and so we mark it as erronious
;; and attempt to re-generate the rest.
(let ((bad-fragment (car fragments))
(bad-fragment-err (plist-get (car fragments) :errors)))
(when-let ((bad-fragment (car fragments)))
(plist-put bad-fragment :errors
(concat bad-fragment-err
(and bad-fragment-err "\n\n")
(concat (when-let ((current-error (plist-get bad-fragment :errors)))
(concat current-error "\n\n"))
"Preview generation catastrophically failed after this fragment."))
(org-latex-preview--remove-cached
(plist-get bad-fragment :key))

View File

@ -809,9 +809,42 @@ as `org-src-fontify-natively' is non-nil."
(1+ pt) (1- (point)) 'face 'org-inline-src-block)))
(font-lock-append-text-property
(1- (point)) (point) 'face '(org-inline-src-block shadow))
(setq pt (point)))))
(setq pt (point)))
(when (and org-inline-src-prettify-results
(re-search-forward "\\= {{{results(" limit t))
(font-lock-append-text-property pt (1+ pt) 'face 'org-inline-src-block)
(goto-char pt))))
t)))
(defun org-fontify-inline-src-results (limit)
"Apply prettify-symbols modifications to inline results blocks.
Performed according to `org-inline-src-prettify-results'."
(when (and org-inline-src-prettify-results
(re-search-forward "{{{results(\\(.+?\\))}}}" limit t))
(remove-list-of-text-properties (match-beginning 0) (point)
'(composition
prettify-symbols-start
prettify-symbols-end))
(font-lock-append-text-property (match-beginning 0) (match-end 0)
'face 'org-block)
(let ((start (match-beginning 0)) (end (match-beginning 1)))
(with-silent-modifications
(compose-region start end (if (eq org-inline-src-prettify-results t)
"(" (car org-inline-src-prettify-results)))
(add-text-properties start end `(prettify-symbols-start ,start prettify-symbols-end ,end))))
(let ((start (match-end 1)) (end (point)))
(with-silent-modifications
(compose-region start end (if (eq org-inline-src-prettify-results t)
")" (cdr org-inline-src-prettify-results)))
(add-text-properties start end `(prettify-symbols-start ,start prettify-symbols-end ,end))))
t))
(defun org-toggle-inline-results-display ()
"Toggle the literal or contracted display of inline src blocks results."
(interactive)
(setq org-inline-src-prettify-results (not org-inline-src-prettify-results))
(org-restart-font-lock))
;;; Escape contents

View File

@ -5213,6 +5213,15 @@ by a #."
:version "24.1"
:group 'org-appearance)
(defcustom org-inline-src-prettify-results t
"Whether to use (ab)use prettify-symbols-mode on {{{results(...)}}}.
Either t or a cons cell of strings which are used as substitutions
for the start and end of inline results, respectively."
:type '(choice boolean (cons string string))
:package-version '(Org . "9.5")
:group 'org-appearance
:group 'org-babel)
(defun org-fontify-meta-lines-and-blocks (limit)
(condition-case-unless-debug nil
(org-fontify-meta-lines-and-blocks-1 limit)
@ -19196,12 +19205,23 @@ a footnote definition, try to fill the first paragraph within."
(save-excursion
(goto-char beg)
(let ((cuts (list beg)))
;; Cut fill on line breaks.
(while (re-search-forward "\\\\\\\\[ \t]*\n" end t)
(when (org-element-type-p
(save-excursion (backward-char)
(org-element-context))
'line-break)
(push (point) cuts)))
;; Cut fill on displayed equations.
(while (re-search-forward "^[ \t]*\\\\\\[" end t)
(let ((el (org-element-context)))
(when (eq 'latex-fragment (org-element-type el))
(setf cuts (append
(list (org-element-property :end el)
(- (org-element-property :end el) 2)
(+ (org-element-property :begin el) 2)
(org-element-property :begin el))
cuts)))))
(dolist (c (delq end cuts))
(fill-region-as-paragraph c end justify)
(setq end c))))