Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2016-02-05 23:01:32 +01:00
commit aee808987d
1 changed files with 33 additions and 44 deletions

View File

@ -18898,28 +18898,38 @@ looks only before point, not after."
(org-in-regexp (org-in-regexp
"\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*"))) "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")))
(defvar-local org-latex-fragment-image-overlays nil (defun org--format-latex-make-overlay (beg end image)
"List of overlays carrying the images of latex fragments.") "Build an overlay between BEG and END using IMAGE file."
(let ((ov (make-overlay beg end)))
(overlay-put ov 'org-overlay-type 'org-latex-overlay)
(overlay-put ov 'evaporate t)
(overlay-put ov
'modification-hooks
(list (lambda (o _flag _beg _end &optional _l)
(delete-overlay o))))
(if (featurep 'xemacs)
(progn
(overlay-put ov 'invisible t)
(overlay-put ov 'end-glyph (make-glyph (vector 'png :file image))))
(overlay-put ov
'display
(list 'image :type 'png :file image :ascent 'center)))))
(defun org--list-latex-overlays (&optional beg end)
"List all Org LaTeX overlays in current buffer.
Limit to overlays between BEG and END when those are provided."
(cl-remove-if-not
(lambda (o) (eq (overlay-get o 'org-overlay-type) 'org-latex-overlay))
(overlays-in (or beg (point-min)) (or end (point-max)))))
(defun org-remove-latex-fragment-image-overlays (&optional beg end) (defun org-remove-latex-fragment-image-overlays (&optional beg end)
"Remove all overlays with LaTeX fragment images in current buffer. "Remove all overlays with LaTeX fragment images in current buffer.
When optional arguments BEG and END are non-nil, remove all When optional arguments BEG and END are non-nil, remove all
overlays between them instead. Return t when some overlays were overlays between them instead. Return a non-nil value when some
removed, nil otherwise." overlays were removed, nil otherwise."
(let (removedp) (let ((overlays (org--list-latex-overlays beg end)))
(setq org-latex-fragment-image-overlays (mapc #'delete-overlay overlays)
(let ((beg (or beg (point-min))) overlays))
(end (or end (point-max))))
(cl-remove-if
(lambda (o)
(cond ((not (overlay-buffer o)) (delete-overlay o) t)
((and (>= (overlay-start o) beg)
(<= (overlay-end o) end))
(delete-overlay o)
(unless removedp (setq removedp t)))
(t nil)))
org-latex-fragment-image-overlays)))
removedp))
(define-obsolete-function-alias (define-obsolete-function-alias
'org-preview-latex-fragment 'org-toggle-latex-fragment "24.4") 'org-preview-latex-fragment 'org-toggle-latex-fragment "24.4")
@ -18999,27 +19009,6 @@ for all fragments in the buffer."
(set-window-start nil window-start) (set-window-start nil window-start)
(message (concat msg "done"))))))) (message (concat msg "done")))))))
(defun org--format-latex-make-overlay (beg end image)
"Build an overlay between BEG and END using IMAGE file.
Register new overlay in `org-latex-fragment-image-overlays'."
(let ((ov (make-overlay beg end)))
(overlay-put ov 'org-overlay-type 'org-latex-overlay)
(overlay-put ov 'evaporate t)
(overlay-put ov
'modification-hooks
(list (lambda (o after _beg _end &optional _l)
(unless after
(org-remove-latex-fragment-image-overlays
(overlay-start o) (overlay-end o))))))
(if (featurep 'xemacs)
(progn
(overlay-put ov 'invisible t)
(overlay-put ov 'end-glyph (make-glyph (vector 'png :file image))))
(overlay-put ov
'display
(list 'image :type 'png :file image :ascent 'center)))
(push ov org-latex-fragment-image-overlays)))
(defun org-format-latex (defun org-format-latex
(prefix &optional dir overlays msg forbuffer processing-type) (prefix &optional dir overlays msg forbuffer processing-type)
"Replace LaTeX fragments with links to an image, and produce images. "Replace LaTeX fragments with links to an image, and produce images.
@ -22440,11 +22429,11 @@ and :keyword."
(when (looking-at org-radio-target-regexp) (when (looking-at org-radio-target-regexp)
(push (org-point-in-group p 0 :radio-target) clist)) (push (org-point-in-group p 0 :radio-target) clist))
(goto-char p)) (goto-char p))
((setq o (car (delq nil ((setq o (cl-some
(mapcar (lambda (o)
(lambda (x) (and (eq (overlay-get o 'org-overlay-type) 'org-latex-overlay)
(when (memq x org-latex-fragment-image-overlays) x)) o))
(overlays-at (point)))))) (overlays-at (point))))
(push (list :latex-fragment (push (list :latex-fragment
(overlay-start o) (overlay-end o)) clist) (overlay-start o) (overlay-end o)) clist)
(push (list :latex-preview (push (list :latex-preview