imenu-list如何高亮当前function

嗨,请教下imenu-list如何高亮当前function? 默认的显示不是很明显,有的时候看不清. 比如可以换种颜色高亮吗?

另外我用的spacemacs默认主题, 是否可以修改相关参数来达到目的.

imenu是用hl-line-mode 高亮的,只是你这个高亮不太明显,可以自定义一个font,比如

(defface hl-highlight
  '((((class color) (min-colors 88) (background light))
     :background "darkseagreen2")
    (((class color) (min-colors 88) (background dark))
     :background "darkolivegreen")
    (((class color) (min-colors 16) (background light))
     :background "darkseagreen2")
    (((class color) (min-colors 16) (background dark))
     :background "darkolivegreen")
    (((class color) (min-colors 8))
     :background "green" :foreground "black")
    (t :inverse-video t))
  "Basic face for highlighting."
  :group 'hl-line)
(setq-default hl-line-face 'hl-highlight)

最后刷新一下 imenu的buffer

(with-current-buffer (get-buffer "*Ilist*")
  (hl-line-mode -1)
  (setq hl-line-overlay nil)
  (hl-line-mode 1))

当然也可以直接修改highlight,因为原有的hl-line face是继承自highlight

多谢, 不过我这里添加了上面代码似乎会报一些错误

这个不用添加在配置里,只是为了更新一下imenu buffer中的face

了解, 多谢. BTW, 有办法只修改imemu-list的highlight, 而不改变其他buffer的highlight吗?(比如当前代码buffer)

可以用这个


(defface hl-highlight
  '((((class color) (min-colors 88) (background light))
     :background "darkseagreen2")
    (((class color) (min-colors 88) (background dark))
     :background "darkolivegreen")
    (((class color) (min-colors 16) (background light))
     :background "darkseagreen2")
    (((class color) (min-colors 16) (background dark))
     :background "darkolivegreen")
    (((class color) (min-colors 8))
     :background "green" :foreground "black")
    (t :inverse-video t))
  "Basic face for highlighting."
  :group 'hl-line)
(add-hook 'imenu-list-major-mode-hook
          (lambda ()
            (hl-line-mode -1)
            (setq hl-line-overlay
                  (let ((ol (make-overlay (point) (point))))
                    (overlay-put ol 'priority -50)           ;(bug#16192)
                    (overlay-put ol 'face 'hl-highlight)
                    ol))
            (hl-line-mode 1)))
1 个赞

嗯, 这样可以, 谢谢.