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
|
(setq-local org-latex-preview-live--generator
|
||||||
(thread-first
|
(thread-first
|
||||||
(lambda (&rest _)
|
(lambda (&rest _)
|
||||||
(let* ((content
|
(when (eq (current-buffer) src-buf)
|
||||||
(string-trim (buffer-substring-no-properties
|
(let* ((content
|
||||||
(point-min) (point-max)))))
|
(string-trim (buffer-substring-no-properties
|
||||||
(with-current-buffer org-buf
|
(point-min) (point-max)))))
|
||||||
(org-latex-preview-place
|
(with-current-buffer org-buf
|
||||||
org-latex-preview-process-default
|
(org-latex-preview-place
|
||||||
(list (list (overlay-start orig-ov)
|
org-latex-preview-process-default
|
||||||
(overlay-end orig-ov)
|
(list (list (overlay-start orig-ov)
|
||||||
content))
|
(overlay-end orig-ov)
|
||||||
numbering-offsets))))
|
content))
|
||||||
|
numbering-offsets)))))
|
||||||
(org-latex-preview-live--throttle)
|
(org-latex-preview-live--throttle)
|
||||||
(org-latex-preview-live--debounce
|
(org-latex-preview-live--debounce
|
||||||
org-latex-preview-live-debounce)))
|
org-latex-preview-live-debounce)))
|
||||||
(add-hook 'after-change-functions org-latex-preview-live--generator 90 'local))
|
(add-hook 'after-change-functions org-latex-preview-live--generator 90 'local))
|
||||||
|
|
||||||
;; Source Org buffer not visible: display live previews in org-src buffer
|
;; 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
|
;; 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
|
(add-hook 'org-latex-preview-overlay-update-functions
|
||||||
#'org-latex-preview-live--update-overlay
|
#'org-latex-preview-live--update-overlay nil 'local)
|
||||||
nil 'local)
|
|
||||||
(setq-local org-latex-preview-live--generator
|
(setq-local org-latex-preview-live--generator
|
||||||
(thread-first
|
(thread-first
|
||||||
(lambda (&rest _)
|
(lambda (&rest _)
|
||||||
(org-latex-preview-place
|
(when (eq (current-buffer) src-buf)
|
||||||
org-latex-preview-process-default
|
(org-latex-preview-place
|
||||||
(list (list (save-excursion (goto-char (point-min))
|
org-latex-preview-process-default
|
||||||
(skip-chars-forward "\n \t\r")
|
(list (list (save-excursion (goto-char (point-min))
|
||||||
(point))
|
(skip-chars-forward "\n \t\r")
|
||||||
(save-excursion (goto-char (point-max))
|
(point))
|
||||||
(skip-chars-backward "\n \t\r")
|
(save-excursion (goto-char (point-max))
|
||||||
(point))))
|
(skip-chars-backward "\n \t\r")
|
||||||
numbering-offsets preamble))
|
(point))))
|
||||||
|
numbering-offsets preamble)))
|
||||||
(org-latex-preview-live--throttle)
|
(org-latex-preview-live--throttle)
|
||||||
(org-latex-preview-live--debounce
|
(org-latex-preview-live--debounce
|
||||||
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 'after-change-functions org-latex-preview-live--generator 90 'local)
|
||||||
(add-hook 'org-latex-preview-overlay-close-functions #'org-latex-preview-live--clearout nil 'local)
|
;; Show live preview if available
|
||||||
(add-hook 'after-change-functions org-latex-preview-live--generator 90 'local)))
|
(org-latex-preview-live--ensure-overlay ov)))
|
||||||
;; Turn on auto-mode behavior in the org-src buffer
|
;; 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 '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)))))
|
(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
|
(font-lock-append-text-property
|
||||||
(1+ pt) (1- (point)) 'face 'org-inline-src-block)))
|
(1+ pt) (1- (point)) 'face 'org-inline-src-block)))
|
||||||
(add-face-text-property (1- (point)) (point) '(org-inline-src-block shadow))
|
(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)))
|
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
|
;;; Escape contents
|
||||||
|
|
||||||
|
|
20
lisp/org.el
20
lisp/org.el
|
@ -5243,6 +5243,15 @@ by a #."
|
||||||
:version "24.1"
|
:version "24.1"
|
||||||
:group 'org-appearance)
|
: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)
|
(defun org-fontify-meta-lines-and-blocks (limit)
|
||||||
(condition-case-unless-debug nil
|
(condition-case-unless-debug nil
|
||||||
(org-fontify-meta-lines-and-blocks-1 limit)
|
(org-fontify-meta-lines-and-blocks-1 limit)
|
||||||
|
@ -19392,12 +19401,23 @@ a footnote definition, try to fill the first paragraph within."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char beg)
|
(goto-char beg)
|
||||||
(let ((cuts (list beg)))
|
(let ((cuts (list beg)))
|
||||||
|
;; Cut fill on line breaks.
|
||||||
(while (re-search-forward "\\\\\\\\[ \t]*\n" end t)
|
(while (re-search-forward "\\\\\\\\[ \t]*\n" end t)
|
||||||
(when (org-element-type-p
|
(when (org-element-type-p
|
||||||
(save-excursion (backward-char)
|
(save-excursion (backward-char)
|
||||||
(org-element-context))
|
(org-element-context))
|
||||||
'line-break)
|
'line-break)
|
||||||
(push (point) cuts)))
|
(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))
|
(dolist (c (delq end cuts))
|
||||||
(fill-region-as-paragraph c end justify)
|
(fill-region-as-paragraph c end justify)
|
||||||
(setq end c))))
|
(setq end c))))
|
||||||
|
|
Loading…
Reference in New Issue