问题:当点位于视觉包装线的末尾(但不在线的最后)时,光标不尊重叠加层的cursor t
设置after-string
- 即光标出现在 next 视觉包装线的开头,而不是当前视觉包装线的最末端。
在此示例/问题中,我们假设变量word-wrap
为t
,变量truncate-lines
为nil
。它不一定是活跃的visual-line-mode
,但肯定可以。目标是将水平标尺从视线的末端延伸到右窗口边缘,并修复当点位于视觉包裹线的末端(但不在线的最末端)时发生的问题。
以下代码适用于除之外的每种情况,当光标位于视觉包装线的末尾时(但不在行的最后)。以编程方式,在这种情况下,如何将光标保持在视觉上位于叠加层after-string
的开头?
(defun example ()
(interactive)
(let* (
peovl
peovl+1
(col-eovl
(save-excursion
(let ((movement-indicator (vertical-motion 1)))
(when (= movement-indicator 1)
(backward-char 1)))
(setq peovl (point))
(setq peovl+1 (1+ peovl))
(- (current-column) (progn (vertical-motion 0) (current-column)))))
(current-underline-length (- (window-width) col-eovl))
(underline (propertize (char-to-string ?\u2009)
'display `(space :width ,current-underline-length)
'face '(:underline "blue")
'cursor t)))
(remove-overlays)
(unless (= peovl (point-at-eol))
(overlay-put (make-overlay peovl peovl+1) 'display ""))
(overlay-put (make-overlay peovl peovl) 'after-string underline)))
答案 0 :(得分:0)
当在视觉包装线的最后一个点处向空格字符(即数字32个字符代码)添加具有'after-string
属性的叠加层时,光标将跳过覆盖完全。 cursor t
属性将被忽略。
解决方法/解决方法是在尝试实现原始海报所描述的视觉效果时使用'display
属性。
(defun example ()
(interactive)
(remove-overlays)
(let* (
result
peovl
peovl+1
(opoint (point))
(peol (point-at-eol))
(underscore "_")
(col-eovl
(save-excursion
(let ((movement-indicator (vertical-motion 1)))
(when (= movement-indicator 1)
(backward-char 1)))
(setq peovl (point))
(setq peovl+1 (1+ peovl))
(- (current-column) (progn (vertical-motion 0) (current-column)))))
(current-underline-length (- (window-width) col-eovl))
(eol-underline (propertize (char-to-string ?\u2009)
'display `(space :width ,current-underline-length)
'face '(:underline "blue")
'cursor t))
(underscore-concatenated
(progn
(dotimes (i current-underline-length)
(setq result (concat underscore result))) result))
(wrapped-peovl-underline (propertize underscore-concatenated
'face '(:foreground "blue")
'cursor t)) )
(if
(and
(= opoint peovl)
(not (= peovl peol)))
(overlay-put (make-overlay peovl peovl+1) 'display wrapped-peovl-underline)
(unless (= peovl peol)
(overlay-put (make-overlay peovl peovl+1) 'display ""))
(overlay-put (make-overlay peovl peovl) 'after-string eol-underline))))