Create a file which title match marked text

I am new to EMACS, so perhaps I am not using the best vocabulary here. Let’s start with an example to highlight what I mean:


Given the selection “Ava DuVernay”, I’m looking for a feature which:

  • Prompt me to select an org-roam template ;
  • Launch capture mode and the title prefilled with “Ava DuVernay” ;
  • When I quit capture mode, replace selection with a link to the newly created note.

Is there already such a feature builtin? And if not, is it easy to implement?

I believe this works as you’re expecting with org-roam-insert (C-c n i) when you have something highlighted. At least, it does for me.

Well, doesn’t work for me unfortunately… the selected text is not extracted to fill title when I launch org-roam-insert. Perhaps this is a bug caused by evil or doom emacs, I have no clue. I am using org-roam version 1.2.0.

Yes normally it should work with org-roam-insert.
Could you give some details about your configuration by putting here the concerned block in your config file?

Because doom-emacs handles emacs config on its own, I did a search in .emacs.d and found one file with references to org-roam-insert, in evil mode, see ./modules/config/default/+evil-bindings.el#L504

         :desc "Insert"           "i" #'org-roam-insert
         :desc "Org Roam"         "r" #'org-roam
         (:prefix ("d" . "by date")
          :desc "Arbitrary date" "d" #'org-roam-dailies-date
          :desc "Today"          "t" #'org-roam-dailies-today
          :desc "Tomorrow"       "m" #'org-roam-dailies-tomorrow
          :desc "Yesterday"      "y" #'org-roam-dailies-yesterday)))

My serparate doom config file (config.el) does declare custom templates as such:

;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-

;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;;   presentations or streaming.
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
;;       doom-variable-pitch-font (font-spec :family "sans" :size 13))

;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-dracula)

;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/knowledge")

;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type t)

;; Here are some additional functions/macros that could help you configure Doom:
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;;   this file. Emacs searches the `load-path' when you load packages with
;;   `require' or `use-package'.
;; - `map!' for binding new keys
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.

;; Auto hard-wrap lines in org-mode files
(add-hook 'org-mode-hook 'turn-on-auto-fill)

;; Display inline images in org-mode
(setq org-startup-with-inline-images t)

;; Auto scan folders to flag as projects
(setq projectile-project-search-path '("~/Programmation"))

;; Org-roam templates
(setq org-roam-capture-templates
    '(("d" "default" plain (function org-roam--capture-get-point)
       :file-name "%<%Y%m%d%H%M%S>-${slug}"
       :head "#+TITLE: ${title}\n#+ROAM_TAGS: "
       :unnarrowed t)
      ("b" "book" plain (function org-roam--capture-get-point)
       :file-name "%<%Y%m%d%H%M%S>-book-${slug}"
       :head "#+TITLE: ${title}\n#+ROAM_TAGS: book\n#+ROAM_KEY: "
       :unnarrowed t)
      ("t" "topic" plain (function org-roam--capture-get-point)
       :file-name "%<%Y%m%d%H%M%S>-topic-${slug}"
       :head "#+TITLE: ${title}\n#+ROAM_TAGS: topic\n#+ROAM_KEY:${slug}"
       :unnarrowed t)
      ("i" "individual" plain (function org-roam--capture-get-point)
       :file-name "%<%Y%m%d%H%M%S>-individual-${slug}"
       :head "#+TITLE: ${title}\n#+ROAM_TAGS: individual\n#+ROAM_KEY:${slug}"
       :unnarrowed t)
      ("e" "entity" plain (function org-roam--capture-get-point)
       :file-name "%<%Y%m%d%H%M%S>-entity-${slug}"
       :head "#+TITLE: ${title}\n#+ROAM_TAGS: entity\n#+ROAM_KEY:${slug}"
       :unnarrowed t)
      ("a" "article" plain (function org-roam--capture-get-point)
       :file-name "%<%Y%m%d%H%M%S>-article-${slug}"
       :head "#+TITLE: ${title}\n#+ROAM_TAGS: entity\n#+ROAM_KEY: "
       :unnarrowed t)

;; Configure org-journal integration with Roam.
;; Journal entries are created for each week.
(use-package org-journal
      (org-journal-dir "~/knowledge/roam")
      (org-journal-file-header "#+TITLE: %Y-%m-%d\n#+ROAM_TAGS: journal\n\n[[][Journal]]\n\nWeek %V, %Y\n\n")
      (org-journal-file-format "")
      (org-journal-file-type 'weekly)
;; Configure org-journal integration with agenda.
(setq org-journal-enable-agenda-integration t)