From: Eshel Yaron Date: Thu, 4 Apr 2024 10:01:40 +0000 (+0200) Subject: New command 'completions-apply' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5da5234e16ea65a0cedb34e9adcba171be38bec3;p=emacs.git New command 'completions-apply' --- diff --git a/lisp/mouse.el b/lisp/mouse.el index cef88dede8a..fb072394ad0 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -660,11 +660,7 @@ Some context functions add menu items below the separator." (define-key map [mouse-3] nil) (define-key map [down-mouse-3] context-menu-entry) (define-key map [menu] #'context-menu-open) - (if (featurep 'w32) - (define-key map [apps] #'context-menu-open)) - (when (featurep 'ns) - (define-key map [C-mouse-1] nil) - (define-key map [C-down-mouse-1] context-menu-entry)) + (if (featurep 'w32) (define-key map [apps] #'context-menu-open)) map) "Context Menu mode map.") @@ -3635,7 +3631,7 @@ is copied instead of being cut." ;; By binding these to down-going events, we let the user use the up-going ;; event to make the selection, saving a click. -(global-set-key [C-down-mouse-1] #'mouse-buffer-menu) +;; (global-set-key [C-down-mouse-1] #'mouse-buffer-menu) (if (not (eq system-type 'ms-dos)) (global-set-key [S-down-mouse-1] #'mouse-appearance-menu)) ;; C-down-mouse-2 is bound in facemenu.el. diff --git a/lisp/simple.el b/lisp/simple.el index ce7ce88669b..9b40ea98327 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9910,10 +9910,35 @@ makes it easier to edit it." ;; Define the major mode for lists of completions. +(defun completions-apply (e) + (interactive "e") + (with-current-buffer (window-buffer (posn-window (event-end e))) + (let ((str (get-text-property (posn-point (event-start e)) 'completion--string)) + (prf (car completion-base-affixes)) + (act (car completions-action))) + (with-current-buffer completion-reference-buffer + (when-let ((adjust-fn (alist-get 'adjust-base-function + (completion-metadata + (concat prf str) + minibuffer-completion-table + minibuffer-completion-predicate)))) + (setq prf (funcall adjust-fn prf))) + (funcall act (concat prf str))) + (save-excursion + (goto-char (point-min)) + (when-let ((pm (text-property-search-forward + 'completion--string str t))) + (goto-char (prop-match-beginning pm)) + (setq pm (text-property-search-forward 'cursor-face)) + (let ((inhibit-read-only t)) + (add-face-text-property (prop-match-beginning pm) (point) + 'completions-used-input))))))) + (defvar-keymap completion-list-mode-map :doc "Local map for completion list buffers." "RET" #'choose-completion "" #'choose-completion + "C-" #'completions-apply "" #'previous-line-completion "" #'next-line-completion "" #'previous-completion