1

How to set it?

I tried

(add-hook 'ido-setup-hook
          (lambda ()
            (local-set-key (kbd "C-<RET>") 'ido-select-text)))

and

(define-key ido-common-completion-map (kbd "C-<RET>") 'ido-select-text)

Nothing worked.

EDIT:

I tried

(define-key ido-file-dir-completion-map (kbd "<C-return>") 'ido-select-text)

and

(define-key ido-common-completion-map (kbd "<C-return>") 'ido-select-text)

Not works again.

EDIT2:

Ultimatelly strange, even this not works.

(global-set-key  (kbd "<C-return>") 'ido-select-text) 

What's going on??? Actually, cua-select-rectangle is invoked regardles of my binding.

My emacs version GNU Emacs 24.5.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.18.9)\n of 2016-04-11 on buildvm-25.phx2.fedoraproject.org Using in GUI mode and CUA mode.

C-h k C-<return>

Returns (in standard buffer and IDO buffer)

<C-return> runs the command cua-set-rectangle-mark, which is an
interactive autoloaded compiled Lisp function in `cua-rect.el'.

It is bound to <C-return>.

(cua-set-rectangle-mark &optional REOPEN)

Set mark and start in CUA rectangle mode.
With prefix argument, activate previous rectangle if possible.
9
  • Your last expression works for me.
    – npostavs
    Commented Dec 2, 2017 at 1:44
  • what emacs version you have ? I have 24.5 and last expression definitelly not works for me.
    – dev1223
    Commented Dec 2, 2017 at 13:45
  • I was using 26, but I tried again now in 24.5 and it works there too.
    – npostavs
    Commented Dec 2, 2017 at 14:57
  • 2
    I still don't have 50rep needed to comment on the thread for Seraph's problems. I've played around with this, and I noticed C-return in a terminal does not work whereas it does in a gui. 1. Please respond with the output of "M-x emacs-version", and whether you are running in a terminal or as a gui. 2. Please run "C-h k C-return" to check whether the key combination works in your setup. 3. Please enter an ido-mode context and run "C-h k C-return"
    – Realraptor
    Commented Dec 2, 2017 at 17:07
  • 2
    In my experiments, the cua-global-map setting overrides the ido-common-completion-map setting. Removing the cua-global-map setting with (define-key cua-global-keymap (kbd "<C-return>") nil) works for me.
    – Realraptor
    Commented Dec 3, 2017 at 16:53

2 Answers 2

1

Not familiar with ido, but define-key appears to be something close to what you want. The following worked as a proof-of-concept for me:

(define-key ido-common-completion-map (kbd "C-j") (lambda() 
    (interactive) (message "C-j called")))

If this isn't exactly right, change the keymap to another value listed at https://github.com/emacs-mirror/emacs/blob/1ed8ff2aa9e1aaee54a6cad38f4c9a595d6c19ed/lisp/ido.el#L206

3
  • Actually, IDO is part of emacs, so I can not simply take its sources and modify it to make it work exactly as I want (I did this with paredit), what can I do with this?
    – dev1223
    Commented Dec 1, 2017 at 22:51
  • Emacs lisp is generally dynamically scoped. This means that you can put my define expression into your init files (typically, your .emacs file) and change the behaviour of your emacs on startup.
    – Realraptor
    Commented Dec 2, 2017 at 17:00
  • 1
    That's not what is usually meant by "dynamically scoped". I think you mean somthing like ImageBasedLanguage
    – npostavs
    Commented Dec 3, 2017 at 13:21
1

Solution for this problem is following, first null CUA map bind because it overrides everything and then bind <C-return> normally to IDO map.

(define-key cua-global-keymap (kbd "<C-return>") nil)  
(define-key ido-file-dir-completion-map (kbd "<C-return>") 'ido-select-text) 

Again, thank you Realraptor for this solution.

EDIT: Previous solution works only one time after set, so its not usable, this solution works well:

(defvar custom-ido-map
    (let ((map (make-sparse-keymap)))
      (define-key map (kbd "<C-return>") 'ido-select-text)
      ;; (define-key map (kbd "<M-return>") 'ido-magic-forward-char)
      map))
  (with-eval-after-load 'ido
    (define-key ido-common-completion-map (kbd "<C-return>") 'ido-select-text)
    ;; (define-key ido-common-completion-map (kbd "<M-return>") 'ido-magic-forward-char)
    )
  (add-to-ordered-list 'emulation-mode-map-alists
                       `((cua-mode . ,custom-ido-map))
                       0)

For more info how and why it works, visit linked answer in comment thread.

1

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.