From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: on helm substantial differences Date: Wed, 18 Nov 2020 21:21:07 +0200 Organization: LINKOV.NET Message-ID: <87k0uifp3w.fsf@mail.linkov.net> References: <87wnymda5g.fsf@mail.linkov.net> <87ima5he8j.fsf@mail.linkov.net> <87mtzfzt9a.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38276"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: spacibba@aol.com, Jean Louis , andreyk.mad@gmail.com, emacs-devel@gnu.org, rudalics@gmx.at, Gregory Heytings , Eli Zaretskii , Drew Adams To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 18 21:01:29 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfTdx-0009rv-8Z for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 21:01:29 +0100 Original-Received: from localhost ([::1]:42936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfTdw-0005tg-9M for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 15:01:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfTcZ-0004wb-8S for emacs-devel@gnu.org; Wed, 18 Nov 2020 15:00:03 -0500 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:47899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfTcW-0006o6-SR; Wed, 18 Nov 2020 15:00:02 -0500 X-Originating-IP: 91.129.97.46 Original-Received: from mail.gandi.net (m91-129-97-46.cust.tele2.ee [91.129.97.46]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 792B5E0004; Wed, 18 Nov 2020 19:59:47 +0000 (UTC) In-Reply-To: <87mtzfzt9a.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 17 Nov 2020 21:18:57 +0200") Received-SPF: pass client-ip=217.70.183.196; envelope-from=juri@linkov.net; helo=relay4-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/18 14:59:58 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259383 Archived-At: --=-=-= Content-Type: text/plain > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > index 9d57a817b2..b98033753d 100644 > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -83,7 +80,6 @@ > > ;; - add support for ** to pcm. > ;; - Add vc-file-name-completion-table to read-file-name-internal. > -;; - A feature like completing-help.el. > > ;;; Code: > BTW, there is another TODO item in minibuffer.el: ;; - indicate how to display the completions in *Completions* (turn ;; \n into something else, add special boundaries between ;; completions). E.g. when completing from the kill-ring. Such pre-processing can be performed by the caller. For a long time I used the command 'yank-from-kill-ring' bound to 'C-M-y' that relies on query-replace-descr to display newlines as ^J and displays long completions with an ellipsis at the end and an ellipsis on leading whitespace. These pre-processed completions also needed to display shorter strings in the minibuffer in icomplete-mode, so this is usable in icomplete-mode as well: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=yank-from-kill-ring.patch Content-Transfer-Encoding: 8bit diff --git a/lisp/simple.el b/lisp/simple.el index bb28145502..076469b3d2 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5449,6 +5449,55 @@ rotate-yank-pointer "With ARG, rotate that many kills forward (or backward, if negative)." (interactive "p") (current-kill arg)) + +(defvar yank-from-kill-ring-history) +(defun yank-from-kill-ring (string) + "Insert the kill-ring item selected from the minibuffer history. +Use minibuffer navigation and search commands to browse the kill-ring +in the minibuffer history before typing RET to insert the item, +or use completion on the elements of the kill-ring." + (interactive + (list (let* ((history-add-new-input nil) + ;; Remove keymaps from text properties of copied string, + ;; because typing RET in the minibuffer might call + ;; an irrelevant command from the map of copied string. + (yank-from-kill-ring-history + (mapcar (lambda (s) + (remove-list-of-text-properties + 0 (length s) + '( + keymap local-map action mouse-action + button category help-args) + s) + s) + kill-ring)) + (completions + (mapcar (lambda (s) + (let* ((s (query-replace-descr s)) + (b 0)) + ;; Add ellipsis on leading whitespace + (when (string-match "\\`[[:space:]]+" s) + (setq b (match-end 0)) + (add-text-properties 0 b `(display "…") s)) + (when (> (length s) (- 40 b)) + (add-text-properties + (min (+ b 40) (length s)) (length s) + `(display "…") s)) + s)) + yank-from-kill-ring-history))) + (completing-read "Yank from kill-ring: " + (lambda (string pred action) + (if (eq action 'metadata) + ;; Keep sorted by recency + '(metadata (display-sort-function . identity)) + (complete-with-action action completions string pred))) + nil nil nil + 'yank-from-kill-ring-history)))) + (setq yank-window-start (window-start)) + (push-mark) + (insert-for-yank string)) + +(global-set-key "\M-\C-y" 'yank-from-kill-ring) ;; Some kill commands. --=-=-=--