]> git.eshelyaron.com Git - emacs.git/commitdiff
New command 'completions-apply'
authorEshel Yaron <me@eshelyaron.com>
Thu, 4 Apr 2024 10:01:40 +0000 (12:01 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 4 Apr 2024 10:27:24 +0000 (12:27 +0200)
lisp/mouse.el
lisp/simple.el

index cef88dede8a4f10bf9bce2e3abb3d89d710b35c5..fb072394ad0bf2533e1c3f6831a153c0e941ecc3 100644 (file)
@@ -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.
index ce7ce88669b0b6feec9fcd326f3228a3718fa8e6..9b40ea9832792c0dbb54b3e464009119af7e0223 100644 (file)
@@ -9910,10 +9910,35 @@ makes it easier to edit it."
 \f
 ;; 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
   "<mouse-2>" #'choose-completion
+  "C-<mouse-1>" #'completions-apply
   "<up>"      #'previous-line-completion
   "<down>"    #'next-line-completion
   "<left>"    #'previous-completion