From: Juri Linkov <juri@linkov.net>
To: 74694@debbugs.gnu.org
Subject: bug#74694: comint-complete-input-ring
Date: Wed, 04 Dec 2024 20:46:40 +0200 [thread overview]
Message-ID: <87cyi7i8vj.fsf@mail.linkov.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 151 bytes --]
Like discussed in
https://mail.gnu.org/archive/html/emacs-devel/2024-11/msg00094.html
here is the patch that implements completion on comint history:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: comint-complete-input-ring.patch --]
[-- Type: text/x-diff, Size: 1816 bytes --]
diff --git a/lisp/comint.el b/lisp/comint.el
index 6423e695430..9b8ea6869c2 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -543,6 +543,7 @@ comint-mode-map
(define-key map "\er" 'comint-history-isearch-backward-regexp)
(define-key map [?\C-c ?\M-r] 'comint-previous-matching-input-from-input)
(define-key map [?\C-c ?\M-s] 'comint-next-matching-input-from-input)
+ (define-key map [?\C-x up] 'comint-complete-input-ring)
(define-key map "\e\C-l" 'comint-show-output)
(define-key map "\C-m" 'comint-send-input)
(define-key map "\C-d" 'comint-delchar-or-maybe-eof)
@@ -1180,6 +1181,26 @@ comint-dynamic-list-input-ring
(set-window-configuration conf)
(push ch unread-command-events))))))
+(defun comint-complete-input-ring ()
+ "Complete a list of recent inputs entered into the current buffer.
+Like `minibuffer-complete-defaults' but completes on comint inputs.
+This function makes `comint-dynamic-list-input-ring' obsolete."
+ (interactive)
+ (let ((completions
+ (if (and (ring-p comint-input-ring)
+ (not (ring-empty-p comint-input-ring)))
+ (ring-elements comint-input-ring)
+ (user-error "No history available")))
+ (completion-in-region-mode-predicate
+ (lambda () (get-buffer-window "*Completions*" 0))))
+ (completion-in-region
+ (comint-line-beginning-position) (point-max)
+ (lambda (string pred action)
+ (if (eq action 'metadata)
+ '(metadata (category . comint-input)
+ (display-sort-function . identity)
+ (cycle-sort-function . identity))
+ (complete-with-action action completions string pred))))))
(defun comint-regexp-arg (prompt)
"Return list of regexp and prefix arg using PROMPT."
next reply other threads:[~2024-12-04 18:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 18:46 Juri Linkov [this message]
2024-12-16 18:15 ` bug#74694: comint-complete-input-ring Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cyi7i8vj.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=74694@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).