Skip to main content
added 133 characters in body
Source Link
tobiasBora
  • 515
  • 2
  • 12

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know! Note that by default I chosed to autocomplete if only one solution is available and if this solution does not need to "fuzzy-match".

Demo:

enter image description here

Code:

(setq xyz-keywords
      '( "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices &optional even-if-one-solution)
  "Choices must be a list of string that can be chosen.
Set 'even-if-one-solution' to 't' if you want to run ido even when only one solution is available."
  (interactive)
  (let*
      ((choices_ (cons "" choices))
       (enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start))
       (classic-completions (all-completions beginword choices_)))
    ;; Complete directly if one solution
    (if (and (not even-if-one-solution) (eq (length classic-completions) 1))
    (insert (car classic-completions))
      (insert (ido-completing-read
           (concat textbefore "")
           choices_ nil nil beginword)))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let ((minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know!

Demo:

enter image description here

Code:

(setq xyz-keywords
      '( "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices &optional even-if-one-solution)
  "Choices must be a list of string that can be chosen.
Set 'even-if-one-solution' to 't' if you want to run ido even when only one solution is available."
  (interactive)
  (let*
      ((choices_ (cons "" choices))
       (enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start))
       (classic-completions (all-completions beginword choices_)))
    ;; Complete directly if one solution
    (if (and (not even-if-one-solution) (eq (length classic-completions) 1))
    (insert (car classic-completions))
      (insert (ido-completing-read
           (concat textbefore "")
           choices_ nil nil beginword)))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let ((minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know! Note that by default I chosed to autocomplete if only one solution is available and if this solution does not need to "fuzzy-match".

Demo:

enter image description here

Code:

(setq xyz-keywords
      '( "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices &optional even-if-one-solution)
  "Choices must be a list of string that can be chosen.
Set 'even-if-one-solution' to 't' if you want to run ido even when only one solution is available."
  (interactive)
  (let*
      ((choices_ (cons "" choices))
       (enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start))
       (classic-completions (all-completions beginword choices_)))
    ;; Complete directly if one solution
    (if (and (not even-if-one-solution) (eq (length classic-completions) 1))
    (insert (car classic-completions))
      (insert (ido-completing-read
           (concat textbefore "")
           choices_ nil nil beginword)))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let ((minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))
update gif
Source Link
tobiasBora
  • 515
  • 2
  • 12

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know!

Demo:

dmoenter image description here

Code:

(setq xyz-keywords
      '( ""
     "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices &optional even-if-one-solution)
  "Choices must be a list of string that can be chosen"chosen.
Set 'even-if-one-solution' to 't' if you want to run ido even when only one solution is available."
  (interactive)
  (let*
      ((choices_ (cons "" choices))
       (enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start)))
       (messageclassic-completions (all-completions beginword choices_)))
    ;; Complete directly if one solution
    (if (and (not even-if-one-solution) (eq (length classic-completions) 1))
    (insert (car classic-completions))
      (insert (ido-completing-read
           (concat textbefore "")
          choices choices_ nil nil beginword)))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let (
      (minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know!

Demo:

dmo

Code:

(setq xyz-keywords
      '( ""
     "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices)
  "Choices must be a list of string that can be chosen"
  (interactive)
  (let*
      ((enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start)))
    (message beginword)
    (insert (ido-completing-read
         (concat textbefore "")
          choices nil nil beginword))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let (
      (minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know!

Demo:

enter image description here

Code:

(setq xyz-keywords
      '( "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices &optional even-if-one-solution)
  "Choices must be a list of string that can be chosen.
Set 'even-if-one-solution' to 't' if you want to run ido even when only one solution is available."
  (interactive)
  (let*
      ((choices_ (cons "" choices))
       (enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start))
       (classic-completions (all-completions beginword choices_)))
    ;; Complete directly if one solution
    (if (and (not even-if-one-solution) (eq (length classic-completions) 1))
    (insert (car classic-completions))
      (insert (ido-completing-read
           (concat textbefore "")
           choices_ nil nil beginword)))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let ((minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))
Add gif
Source Link
tobiasBora
  • 515
  • 2
  • 12

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know!

Demo:

dmo

Code:

(setq xyz-keywords
      '( ""
     "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices)
  "Choices must be a list of string that can be chosen"
  (interactive)
  (let*
      ((enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start)))
    (message beginword)
    (insert (ido-completing-read
         (concat textbefore "")
          choices nil nil beginword))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let (
      (completion-at-point-functions '(xyz-completion-at-point))
      (minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know!

(setq xyz-keywords
      '( ""
     "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices)
  "Choices must be a list of string that can be chosen"
  (interactive)
  (let*
      ((enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start)))
    (message beginword)
    (insert (ido-completing-read
         (concat textbefore "")
          choices nil nil beginword))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let (
      (completion-at-point-functions '(xyz-completion-at-point))
      (minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))

It's not exactly what I wanted before, but it's not too far away. The idea is to use recursive minibuffer and to run ido-completing-read with the good parameters each time the user type TAB. So you won't use exactly the keystrokes above, but it won't be too far since you will hit "tab" when you want to see what IDO can give you, and then you hit "Enter" when you are happy with the IDO proposition. If someone has another solution, please let me know!

Demo:

dmo

Code:

(setq xyz-keywords
      '( ""
     "touch"
     "touch_start"
     "touch_end"
     "for"
     "foreach"
     "forall"
     "chocolate"
     "banana"
     ))

(defun in-buffer-ido-replace (choices)
  "Choices must be a list of string that can be chosen"
  (interactive)
  (let*
      ((enable-recursive-minibuffers t)
       (bds (or (bounds-of-thing-at-point 'symbol) (cons (point) (point))))
       (start (car bds))
       (end (point))
       (beginword (buffer-substring start end))
       (textbefore (buffer-substring 1 start)))
    (message beginword)
    (insert (ido-completing-read
         (concat textbefore "")
          choices nil nil beginword))
    (delete-region start end)
  ))

(setq my-mode-map (copy-keymap minibuffer-local-map))
(define-key my-mode-map (kbd "TAB") (lambda () (interactive) (in-buffer-ido-replace xyz-keywords)))
(let (
      (minibuffer-setup-hook (lambda () (add-hook 'completion-at-point-functions 'xyz-completion-at-point nil 'local))))
  (read-from-minibuffer "Prompt: " nil my-mode-map))
Source Link
tobiasBora
  • 515
  • 2
  • 12
Loading