Function: denote--with-conditional-completion

denote--with-conditional-completion is a macro defined in denote.el.

Signature

(denote--with-conditional-completion FN PROMPT HISTORY &optional INITIAL-VALUE DEFAULT-VALUE)

Documentation

Produce body of FN that may perform completion.

Use PROMPT, HISTORY, INITIAL-VALUE, and DEFAULT-VALUE as arguments for the given minibuffer prompt.

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defmacro denote--with-conditional-completion (fn prompt history &optional initial-value default-value)
  "Produce body of FN that may perform completion.
Use PROMPT, HISTORY, INITIAL-VALUE, and DEFAULT-VALUE as arguments for
the given minibuffer prompt."
  `(if (denote--prompt-with-completion-p ,fn)
       ;; NOTE 2023-10-27: By default SPC performs completion in the
       ;; minibuffer.  We do not want that, as the user should be able to
       ;; input an arbitrary string, while still performing completion
       ;; against their input history.
       (minibuffer-with-setup-hook
           (lambda ()
             (use-local-map
              (let ((map (make-composed-keymap nil (current-local-map))))
                (define-key map (kbd "SPC") nil)
                map)))
         (completing-read ,prompt ,history nil nil ,initial-value ',history ,default-value))
     (read-string ,prompt ,initial-value ',history ,default-value)))