1

I configured org-capture with below elisp in init.el:

(define-key global-map "\C-cc" 'org-capture)
(setq my-org-capture-file (concat org-directory "/capture.org"))
(setq my/line "%(with-current-buffer (org-capture-get :original-file-nondirectory) (thing-at-point 'line t))")
(setq org-capture-templates
      `(
        ("n" "Review Notes"
         entry (file+headline ,my-org-capture-file "Code Review")
         ,(format "* TODO %%?\n %%l\n  %s" my/line))
      ))

Then when I review code to take notes with 'n', I got below results:

** TODO 
 [[file:/tmp/linux-4.14-rc8/drivers/video/fbdev/geode/video_cs5530.c::static%20int%20cs5530_blank_display(struct%20fb_info%20*info,%20int%20blank_mode)]]
  static int cs5530_blank_display(struct fb_info *info, int blank_mode)

It works perfect but the link description is too long. I wish to display the file name without path and line info, e.g. video_cs5530.c for this case.

I try to use %a to replace %l, results is the same.

1 Answer 1

2

Maybe making it a link with an annotation of the current file name would work:

(setq org-capture-templates
  `(
    ("n" "Review Notes"
     entry (file+headline ,my-org-capture-file "Code Review")
     ,(format "* TODO %%?\n [[%%l][%%f]]\n  %s" my/line))
  ))
1
  • That's awesome! I am thinking about use elisp replace things before but sounds like not so easy!
    – beetlej
    Commented Nov 10, 2017 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.