forked from mirrors/org-mode
Compare commits
5 Commits
8ab7c2814a
...
8f1d75ae1b
Author | SHA1 | Date |
---|---|---|
TEC | 8f1d75ae1b | |
TEC | 2a78c11a96 | |
TEC | 8d3909de66 | |
TEC | 9183d8e6ff | |
Karthik Chikmagalur | f8c1678317 |
|
@ -1223,54 +1223,62 @@ This is meant to be called via `org-src-mode-hook'."
|
|||
(setq-local org-latex-preview-live--generator
|
||||
(thread-first
|
||||
(lambda (&rest _)
|
||||
(let* ((content
|
||||
(string-trim (buffer-substring-no-properties
|
||||
(point-min) (point-max)))))
|
||||
(with-current-buffer org-buf
|
||||
(org-latex-preview-place
|
||||
org-latex-preview-process-default
|
||||
(list (list (overlay-start orig-ov)
|
||||
(overlay-end orig-ov)
|
||||
content))
|
||||
numbering-offsets))))
|
||||
(when (eq (current-buffer) src-buf)
|
||||
(let* ((content
|
||||
(string-trim (buffer-substring-no-properties
|
||||
(point-min) (point-max)))))
|
||||
(with-current-buffer org-buf
|
||||
(org-latex-preview-place
|
||||
org-latex-preview-process-default
|
||||
(list (list (overlay-start orig-ov)
|
||||
(overlay-end orig-ov)
|
||||
content))
|
||||
numbering-offsets)))))
|
||||
(org-latex-preview-live--throttle)
|
||||
(org-latex-preview-live--debounce
|
||||
org-latex-preview-live-debounce)))
|
||||
(add-hook 'after-change-functions org-latex-preview-live--generator 90 'local))
|
||||
|
||||
;; Source Org buffer not visible: display live previews in org-src buffer
|
||||
;; Set the element type ahead of time since we cannot call
|
||||
;; org-element-context in the org-src buffer
|
||||
(setq org-latex-preview-live--element-type
|
||||
(with-current-buffer org-buf
|
||||
(or (and (string-prefix-p
|
||||
"\\[" (org-element-property :value element))
|
||||
'latex-environment)
|
||||
(org-element-type element))))
|
||||
;; Show live preview if available
|
||||
(org-latex-preview-live--ensure-overlay ov)
|
||||
;; Set up hooks for live preview updates in the org-src buffer
|
||||
(let* ((element-type
|
||||
(with-current-buffer org-buf
|
||||
(or (and (string-prefix-p
|
||||
"\\[" (org-element-property :value element))
|
||||
'latex-environment)
|
||||
(org-element-type element))))
|
||||
(preview-clearout-func
|
||||
(lambda (ov)
|
||||
(org-latex-preview-live--clearout ov)
|
||||
(setq org-latex-preview-live--element-type element-type))))
|
||||
;; Set the element type ahead of time since we cannot call
|
||||
;; org-element-context in the org-src buffer
|
||||
(setq org-latex-preview-live--element-type element-type)
|
||||
(add-hook 'org-latex-preview-overlay-close-functions
|
||||
preview-clearout-func nil 'local))
|
||||
(add-hook 'org-latex-preview-overlay-open-functions
|
||||
#'org-latex-preview-live--ensure-overlay nil 'local)
|
||||
(add-hook 'org-latex-preview-overlay-update-functions
|
||||
#'org-latex-preview-live--update-overlay
|
||||
nil 'local)
|
||||
#'org-latex-preview-live--update-overlay nil 'local)
|
||||
(setq-local org-latex-preview-live--generator
|
||||
(thread-first
|
||||
(lambda (&rest _)
|
||||
(org-latex-preview-place
|
||||
org-latex-preview-process-default
|
||||
(list (list (save-excursion (goto-char (point-min))
|
||||
(skip-chars-forward "\n \t\r")
|
||||
(point))
|
||||
(save-excursion (goto-char (point-max))
|
||||
(skip-chars-backward "\n \t\r")
|
||||
(point))))
|
||||
numbering-offsets preamble))
|
||||
(when (eq (current-buffer) src-buf)
|
||||
(org-latex-preview-place
|
||||
org-latex-preview-process-default
|
||||
(list (list (save-excursion (goto-char (point-min))
|
||||
(skip-chars-forward "\n \t\r")
|
||||
(point))
|
||||
(save-excursion (goto-char (point-max))
|
||||
(skip-chars-backward "\n \t\r")
|
||||
(point))))
|
||||
numbering-offsets preamble)))
|
||||
(org-latex-preview-live--throttle)
|
||||
(org-latex-preview-live--debounce
|
||||
org-latex-preview-live-debounce)))
|
||||
(add-hook 'org-latex-preview-overlay-open-functions #'org-latex-preview-live--ensure-overlay nil 'local)
|
||||
(add-hook 'org-latex-preview-overlay-close-functions #'org-latex-preview-live--clearout nil 'local)
|
||||
(add-hook 'after-change-functions org-latex-preview-live--generator 90 'local)))
|
||||
(add-hook 'after-change-functions org-latex-preview-live--generator 90 'local)
|
||||
;; Show live preview if available
|
||||
(org-latex-preview-live--ensure-overlay ov)))
|
||||
;; Turn on auto-mode behavior in the org-src buffer
|
||||
(add-hook 'pre-command-hook #'org-latex-preview-auto--handle-pre-cursor nil 'local)
|
||||
(add-hook 'post-command-hook #'org-latex-preview-auto--handle-post-cursor nil 'local)))))
|
||||
|
|
|
@ -805,9 +805,42 @@ as `org-src-fontify-natively' is non-nil."
|
|||
(font-lock-append-text-property
|
||||
(1+ pt) (1- (point)) 'face 'org-inline-src-block)))
|
||||
(add-face-text-property (1- (point)) (point) '(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
|
||||
|
||||
|
|
20
lisp/org.el
20
lisp/org.el
|
@ -5243,6 +5243,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)
|
||||
|
@ -19392,12 +19401,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))))
|
||||
|
|
Loading…
Reference in New Issue