【分享】org-noter 高亮当前笔记

用 org-noter 的时候,如果一页中有多个笔记,或者笔记暂时没有内容,很不好定位当前笔记,最近忍无可忍,看了一下源码,发现很好解决,和大家分享一下。

(defun eli-org-noter-set-highlight (_arg)
    "Highlight current org-noter note."
    (save-excursion
      (switch-to-buffer "Notes of Notes")
      (remove-overlays (point-min) (point-max) 'org-noter-current-hl t)
      (goto-char (org-entry-beginning-position))
      (let* ((hl (org-element-context))
             (hl-begin (plist-get  (plist-get hl 'headline) :begin))
             (hl-end (1- (plist-get  (plist-get hl 'headline) :contents-begin)))
             (hl-ov (make-overlay hl-begin hl-end)))
        (overlay-put hl-ov 'face 'mindre-keyword)
        (overlay-put hl-ov 'org-noter-current-hl t))
      (org-cycle-hide-drawers 'all)))
  (advice-add #'org-noter--focus-notes-region :after #'eli-org-noter-set-highlight)

效果如下: Peek 2022-09-06 15-46

7 个赞

更新下代码

(defun eli/org-noter-set-highlight (&rest _arg)
    "Highlight current org-noter note."
    (save-excursion
      (with-current-buffer (org-noter--session-notes-buffer org-noter--session)
        (remove-overlays (point-min) (point-max) 'org-noter-current-hl t)
        (goto-char (org-entry-beginning-position))
        (let* ((hl (org-element-context))
               (hl-begin (plist-get  (plist-get hl 'headline) :begin))
               (hl-end (1- (plist-get  (plist-get hl 'headline) :contents-begin)))
               (hl-ov (make-overlay hl-begin hl-end)))
          (overlay-put hl-ov 'face 'mindre-keyword)
          (overlay-put hl-ov 'org-noter-current-hl t))
        (org-cycle-hide-drawers 'all))))
    
  (advice-add #'org-noter--focus-notes-region
              :after #'eli/org-noter-set-highlight)
  (advice-add #'org-noter-insert-note
              :after #'eli/org-noter-set-highlight)
3 个赞

这个是用来记 pdf 对应的笔记的吗,感觉 emacs 看 pdf 一直是一个痛点

对应的插件是 org-noter ,我只是稍微修改下默认行为,能够高亮当前页面的笔记和隐藏 drawer。

这个见仁见智吧,pdf-tool + org-noter + org-anki 这三个结合起来我用的很舒服。

1 个赞

最近也在用org-noter+pdf-tools,用起来确实是很舒服,有一问题就是文件超过30m,emacs就会变卡,动不了。大佬有这问题么?