Create new org-roam node ignoring pre selected existing nodes

I am not sure if this is org-roam related or if it is about ivy or counsel or something else.
At the bottom you find a minimal init.el and a screen recording illustrating the problem.

I am using Emacs27 on Debian 11; usually with evil, ivy, counsel, org-roam.

C-c n f is bind to org-roam-node-find in my setup.
A search field (ivy?) and a search result list comes up.

I can search existing nodes or create a new one if it does not exist yet. Assume that there still is a node with the title Foobar in summer and I want to create a new node with title summer.

This is not possible because when I type summer (after C-c n f) the existing node Foobar in summer is pre selected in the search list. When I hit ENTER (or TAB) the existing node opens in a new buffer instead of a new created node (capture buffer?) with title summer.

How can I create a new node preventing pre selection of existing nodes.

I illustrated the problem with a GIF-recording
C-c_n_f_preselect_problem

The used (minimal) init.el for that recording

;; -*- lexical-binding: t; -*-

;; === Package setup ===
(require 'package)

(setq package-archives '(("melpa" . "https://melpa.org/packages/")
			 ("org" . "https://orgmode.org/elpa/")
			 ("elpa" . "https://elpa.gnu.org/packages/")))
;; Initializes the package infrastructure
(package-initialize)

;; === use-package ==
;; use-package to simplify the config file
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(require 'use-package)
(setq use-package-always-ensure 't)

;; === Improved search field
; M-o opens "context menu" of a search item
(use-package ivy
  :diminish
  :bind (("C-s" . swiper))
  :config
  (ivy-mode 1))

;; === Add docstring column to function search results
(use-package ivy-rich
    :init
    (ivy-rich-mode 1))

(use-package org-roam
  :init  ; is called before the package is loaded
  (setq org-roam-v2-ack t)  ; do not show migration warning after startup
  :custom
  (org-roam-directory "~/tab-cloud/my.org-roam")
  :bind (("C-c n l" . org-roam-buffer-toggle)
	 ("C-c n f" . org-roam-node-find)
	 ("C-c n i" . org-roam-node-insert)
	 )
  :config
  (org-roam-db-autosync-mode)
  )

Sidenode: There is an open issue (from me) in the ivy repo.

press up arrow, move cursor up one line in minibuffer. Then you can create a new one.

1 Like

Yes. It’s an Ivy quark. If what @Jousimies does not work, see this FAQ section in Ivy README.

Q: How do I enter an input that matches one of the candidates instead of this candidate? Example: create a file bar when a file barricade exists in the current directory.

A: Press C-M-j. Alternatively, you can make the prompt line selectable with (setq ivy-use-selectable-prompt t) .

2 Likes

press up arrow, move cursor up one line in minibuffer. Then you can create a new one.
Have you tested that with my minimal working example? It does not work for me. But maybe I misunderstand you.

Is this a workaround, or there are better solutions?

C-M-j is default-indent-new-line on my device.

EDIT:

I find the correct way to do it:

vertico: vertico-exit-input
ivy: ivy-immediate-done

It’s good that you are thorough. Thanks for following up.

It’s the same solution for Ivy.
This line of code:

(ivy-define-key map (kbd "C-M-j") 'ivy-immediate-done)

For the record, the above comes directly from Ivy’s README.

Yeah, I have no doubt. I think this is not for your minibuffer, though, is it? Then it’s not relevant.

1 Like

:laughing: We have different packages and keybindings for the same function.

Well, I don’t use Ivy any more. I am referencing the default from the package and its official documentation.

1 Like