Skip to content

Commit

Permalink
add org-xlatex-position-indicator
Browse files Browse the repository at this point in the history
Directly stolen from mafty (on emacs-china)
Originally from tecosaur
  • Loading branch information
ksqsf committed Jul 3, 2023
1 parent 321bf22 commit 0956919
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions org-xlatex.el
Expand Up @@ -42,6 +42,10 @@
"The height of the preview window."
:type 'integer
:group 'org-xlatex)
(defcustom org-xlatex-position-indicator nil
"Display an indicator for the current poisition in the preview."
:type 'bool
:group 'org-xlatex)

(defvar org-xlatex-timer nil)
(defvar org-xlatex-frame nil
Expand Down Expand Up @@ -168,10 +172,14 @@ the point is at a formula."
(let ((context (org-element-context)))
(when (or (eq 'latex-fragment (org-element-type context))
(eq 'latex-environment (org-element-type context)))
(buffer-substring-no-properties
(org-element-property :begin context)
(- (org-element-property :end context)
(org-element-property :post-blank context))))))
(let ((beg (org-element-property :begin context))
(end (- (org-element-property :end context)
(org-element-property :post-blank context))))
(if org-xlatex-position-indicator
(concat (buffer-substring-no-properties beg (point))
"{\\color{red}|}"
(buffer-substring-no-properties (point) end))
(buffer-substring-no-properties beg end))))))

(defun org-xlatex--escape (latex)
"Escape LaTeX code so that it can be used as JS strings."
Expand Down

10 comments on commit 0956919

@weitongdao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error running timer ‘org-xlatex--timer-function’: (void-function pixel-line-height) [4 times]
spacemacs 中出现这个错误是啥原因,没有增加光标版本之前是可用的,加了之后就出现这个错误了。

@ksqsf
Copy link
Owner Author

@ksqsf ksqsf commented on 0956919 Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weitongdao 可否试一下 (require 'pixel-scroll) 然后回报结果?谢谢。

@weitongdao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以了,解决。
VagrantJoker 的方案:https://emacs-china.org/t/xwidget-webkit-wysiwyg-latex/24859/6
'加上这两句就可以正常工作了,也有红标指示了了
(require 'pixel-scroll)
(setq org-xlatex-position-indicator t)

@weitongdao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提一个简单的需求:
增加一个开头模式,比如不需要即显了,它能关闭掉预览窗口。 org-xlatex-mode 好像只能打开。

@ksqsf
Copy link
Owner Author

@ksqsf ksqsf commented on 0956919 Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weitongdao 抱歉,没太理解你具体想要什么样的行为……
如果你说的是「一段时间内禁止 org-xlatex 显示任何预览窗口」,可以临时关闭掉 org-xlatex-mode,在需要的时候再打开。
如果还需要快速切换minor mode,可以考虑把切换命令绑定到一个快捷键上。

@weitongdao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一段时间内禁止 org-xlatex 显示任何预览窗口」,可以临时关闭掉 org-xlatex-mode,

一段时间内禁止 org-xlatex 显示任何预览窗口」,可以临时关闭掉 org-xlatex-mode,这个怎么实现,因为emacs 命令行只有 org-xlatex-mode这一个命令。
所以要自己写一个取消minor mode的命令或者 toggle的命令吗。

@ksqsf
Copy link
Owner Author

@ksqsf ksqsf commented on 0956919 Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weitongdao M-x org-xlatex-mode 切换

@weitongdao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weitongdao M-x org-xlatex-mode 切换

运行再次M-x org-xlatex-mode,会得到两个这个预览窗口。这个窗口如果能手动关闭的话就好了,相当于一个重置功能。
image

@ksqsf
Copy link
Owner Author

@ksqsf ksqsf commented on 0956919 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weitongdao 这应该是之前的一个bug,在没有干净关闭的情况下timer没有被重置,目前已经修复了。你可以重启一下emacs或者M-x list-timers删除多余的timer。

@weitongdao
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

谢谢,现在好了,我使用一段时间再看看哈

Please sign in to comment.