From unknown Sat Jun 21 03:22:20 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#67479 <67479@debbugs.gnu.org> To: bug#67479 <67479@debbugs.gnu.org> Subject: Status: [PATCH] Facilitate using Completion Preview with the mouse Reply-To: bug#67479 <67479@debbugs.gnu.org> Date: Sat, 21 Jun 2025 10:22:20 +0000 retitle 67479 [PATCH] Facilitate using Completion Preview with the mouse reassign 67479 emacs submitter 67479 Eshel Yaron severity 67479 normal tag 67479 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 02:42:19 2023 Received: (at submit) by debbugs.gnu.org; 27 Nov 2023 07:42:19 +0000 Received: from localhost ([127.0.0.1]:43164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7WG2-00047b-El for submit@debbugs.gnu.org; Mon, 27 Nov 2023 02:42:19 -0500 Received: from lists.gnu.org ([2001:470:142::17]:35560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7WFy-00047G-SQ for submit@debbugs.gnu.org; Mon, 27 Nov 2023 02:42:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7WFm-0006ay-Ef for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 02:42:02 -0500 Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7WFk-0004gq-Jn for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 02:42:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1701070918; bh=QOdYpr6x9KZKuOnwA8dsE79WHnJR1siccJKmq8hf5BY=; h=From:To:Subject:Date:From; b=ZyEtdRqTez6K7dqSewqvNwjTAxG3Od5xQUW/PcTFY5wd21oegIez8nJUo3+JeiRCG cgGZ2Jtdm/aaTG585w/ssbvappiHA7sA8Mf/xeQwBqj0EDCI1MOB7ZqcsOuw2x8BIY S2x3ejvDSDb6vzWbYFUYePQCKhcQXHgCE2ud/AfbkHgK7iXq2qBfCE5bXWw/lSJSGu mwY1UyUHul9bodQdZKNe42gEgmKgtdJH4EHenvNHyDwmGUtSrpV3T9asWsfwME+DVM lcKmW9v6LOhBfPz60s7InMrrsTB9q70kZJFGeJXSa1KC7PBlGjo65NKAYrN0VdbAnj BSuyp/K/sUSYQ== From: Eshel Yaron To: bug-gnu-emacs@gnu.org Subject: [PATCH] Facilitate using Completion Preview with the mouse X-Hashcash: 1:20:231127:bug-gnu-emacs@gnu.org::K+qdTGX1lZPDQ7MN:0S8f Date: Mon, 27 Nov 2023 08:41:56 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch This patch makes Completion Preview mode more convenient, and useful, when you're working with one hand on a mouse or similar device. Thanks, Eshel --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Facilitate-using-Completion-Preview-with-the-mouse.patch >From 2a1f17d183d1b72faf6a37a272c18a5766189006 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 26 Nov 2023 17:00:32 +0100 Subject: [PATCH] Facilitate using Completion Preview with the mouse Allow users to accept the completion suggestion by clicking on it, and to cycle between completion suggestions by scrolling (with a mouse wheel or a trackpad) over the preview. Also display a message by default when cycling to inform the user about the index of the current suggestion out of the available total. * lisp/completion-preview.el (completion-preview-highlight): New face. (completion-preview-message-format): New user option. (completion-preview--mouse-map): New keymap. (completion-preview--try-table, completion-preview--show) (completion-preview-next-candidate): Apply 'keymap' and 'mouse-face' properties to completion preview string. (completion-preview--internal-commands): Add 'mwheel-scroll'. This prevents incidental scrolls outside of the preview from dismissing the preview when you actually want to cycle it. (completion-preview--active-p): New function. Use it as a 'completion-predicate' symbol property for commands that should only be used when the preview is shown to otherwise exclude these commands from M-x completion candidates. --- lisp/completion-preview.el | 66 ++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 039a330bc84..1d5f1253702 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -83,6 +83,22 @@ completion-preview-minimum-symbol-length :type 'natnum :version "30.1") +(defcustom completion-preview-message-format + "Completion suggestion %i out of %n" + "Message to show after cycling the completion preview suggestion. + +If the value is a string, `completion-preview-next-candidate' and +`completion-preview-prev-candidate' display this string in the +echo area, after substituting \"%i\" with the 1-based index of +the completion suggestion that the preview is showing, and \"%n\" +with the total number of available completion suggestions for the +text around point. + +If this option is nil, these commands do not display any message." + :type '(choice (string :tag "Message format") + (const :tag "No message" nil)) + :version "30.1") + (defvar completion-preview-sort-function #'minibuffer--sort-by-length-alpha "Sort function to use for choosing a completion candidate to preview.") @@ -100,6 +116,11 @@ completion-preview-exact "Face for exact completion preview overlay." :version "30.1") +(defface completion-preview-highlight + '((t :inherit highlight)) + "Face for highlighting the completion preview when the mouse is over it." + :version "30.1") + (defvar-keymap completion-preview-active-mode-map :doc "Keymap for Completion Preview Active mode." "C-i" #'completion-preview-insert @@ -107,11 +128,26 @@ completion-preview-active-mode-map ;; "M-p" #'completion-preview-prev-candidate ) +(defvar-keymap completion-preview--mouse-map + :doc "Keymap for mouse clicks on the completion preview." + "" #'completion-preview-insert + "C-" #'completion-at-point + "" #'completion-at-point + (format "<%s>" mouse-wheel-up-event) #'completion-preview-prev-candidate + (format "<%s>" mouse-wheel-up-alternate-event) #'completion-preview-prev-candidate + (format "<%s>" mouse-wheel-down-event) #'completion-preview-next-candidate + (format "<%s>" mouse-wheel-down-alternate-event) #'completion-preview-next-candidate) + (defvar-local completion-preview--overlay nil) (defvar completion-preview--internal-commands - '(completion-preview-next-candidate completion-preview-prev-candidate) - "List of commands that manipulate the completion preview.") + '(completion-preview-next-candidate + completion-preview-prev-candidate + ;; Don't dismiss or update the preview when the user scrolls. + mwheel-scroll) + "List of commands that manipulate the completion preview. + +Completion Preview mode avoids updating the preview after these commands.") (defsubst completion-preview--internal-command-p () "Return non-nil if `this-command' manipulates the completion preview." @@ -194,7 +230,9 @@ completion-preview--try-table (list (propertize (substring (car sorted) (length prefix)) 'face (if (cdr sorted) 'completion-preview - 'completion-preview-exact)) + 'completion-preview-exact) + 'mouse-face 'completion-preview-highlight + 'keymap completion-preview--mouse-map) (+ beg base) end sorted (substring string 0 base) exit-fn)))))) @@ -255,7 +293,9 @@ completion-preview--show ;; The previous preview is still applicable, update it. (overlay-put (completion-preview--make-overlay cur (propertize (substring cand (- cur beg)) - 'face face)) + 'face face + 'mouse-face 'completion-preview-highlight + 'keymap completion-preview--mouse-map)) 'completion-preview-end cur) ;; The previous preview is no longer applicable, hide it. (completion-preview-active-mode -1)))) @@ -318,10 +358,24 @@ completion-preview-next-candidate (let ((aft (propertize (substring str (- pos beg)) 'face (if (< 1 len) 'completion-preview - 'completion-preview-exact)))) + 'completion-preview-exact) + 'mouse-face 'completion-preview-highlight + 'keymap completion-preview--mouse-map))) (add-text-properties 0 1 '(cursor 1) aft) (overlay-put completion-preview--overlay 'completion-preview-index new) - (overlay-put completion-preview--overlay 'after-string aft))))) + (overlay-put completion-preview--overlay 'after-string aft)) + (when completion-preview-message-format + (message (format-spec completion-preview-message-format + `((?i . ,(1+ new)) (?n . ,len)))))))) + +(defun completion-preview--active-p (_symbol buffer) + "Check if the completion preview is currently shown in BUFFER." + (buffer-local-value 'completion-preview-active-mode buffer)) + +(dolist (cmd '(completion-preview-insert + completion-preview-prev-candidate + completion-preview-next-candidate)) + (put cmd 'completion-predicate #'completion-preview--active-p)) ;;;###autoload (define-minor-mode completion-preview-mode -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 02 07:55:45 2023 Received: (at 67479-done) by debbugs.gnu.org; 2 Dec 2023 12:55:45 +0000 Received: from localhost ([127.0.0.1]:56867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9PX7-0006Nv-BK for submit@debbugs.gnu.org; Sat, 02 Dec 2023 07:55:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9PX6-0006Ni-1K for 67479-done@debbugs.gnu.org; Sat, 02 Dec 2023 07:55:44 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r9PWr-0005on-AO; Sat, 02 Dec 2023 07:55:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=mJ48d5zwLxcGt8e9G5YhXJ8RQRTpFOwaehiVQo7KG9s=; b=JPDrvQ/GaK8S 13gbUg8bC1d83p7PckfsNZk5G08cvA885G6+JIYlEROhFn82IeqXVUKHAcliNnATvMk7d9GBFEaPs 1nbXNr2ZHYCCLgtAwT3R2vJ+1UOjxeqGdr6jEI7qLmS3sx2oGAdDnkLDBzd7zyBDesL5IyoHArJEA r0gGvSo8KrsEHpO3TDjKESeRxAexYuKADkZbY/UO0bdpbwSNqC8rzEzTivYBIE7SCcZlDM/iCeykR 7VuEeg2xGs1i53cX82MyELjgPdbwRdjVkBZdqysYNJglShG5vNSsmywuwDdAKM03UnVhXMu2nNjQ4 adazYqbVsV6cukNmFSW4Iw==; Date: Sat, 02 Dec 2023 14:55:08 +0200 Message-Id: <83edg4932r.fsf@gnu.org> From: Eli Zaretskii To: Eshel Yaron In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#67479: [PATCH] Facilitate using Completion Preview with the mouse References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67479-done Cc: 67479-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Mon, 27 Nov 2023 08:41:56 +0100 > From: Eshel Yaron via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > This patch makes Completion Preview mode more convenient, and useful, > when you're working with one hand on a mouse or similar device. Thanks, installed on master, and closing the bug. From unknown Sat Jun 21 03:22:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 31 Dec 2023 12:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator