Hot answers tagged

11

tldr; Add (setq mouse-drag-and-drop-region t) in you init file. Restart or C-c d R to reload if you're using Doom-Emacs. I just find out (SURPRISINGLY) that Emacs as text drag and drop. And this since version 22.1 released in 2007. This is actually a feature I didn't even dare to google to see if it's available. Even Sublime Text can't (currently in Linux)


10

Just found this, did not tried it: (set-mouse-color "red")


9

Here is a solution: (defun mouse-start-rectangle (start-event) (interactive "e") (deactivate-mark) (mouse-set-point start-event) (rectangle-mark-mode +1) (let ((drag-event)) (track-mouse (while (progn (setq drag-event (read-event)) (mouse-movement-p drag-event)) (mouse-set-point drag-event))))) (...


9

It's actually a bit complicated. When you double-click mouse-1 there are multiple actions. <down-mouse-1> occurs first, when you press the button. Then mouse-1 occurs, when you release the button. <down-mouse-1> is bound to command mouse-drag-region, and that command calls mouse-drag-track. That function counts the mouse-button clicks and keeps ...


7

Sounds like you are being bitten by the fact that one command is bound to mouse-2, another command is bound to down-mouse-2, and the two commands do not play well together. Do C-h k and then click mouse-2 on text (e.g. mistaake). The help should tell you what mouse-2 and down-mouse-2 are bound to. If I'm right in my guess, you can try doing one of these ...


7

You can view a considerable amount of information about buttons (and other text properties and overlays) by placing point on them and using what-cursor-position with a prefix arg, that is, C-u C-x =. The help page this brings up has links describing the button information. As an example, take the [back] buttons in *Help*. C-u C-x = with point on that button ...


7

Since Emacs 26.1, the buffer can be scrolled by individual pixels instead of just lines which can be used to smoothly scroll over images using the mouse wheel. To achieve this I have used the following configuration: ;;; Scrolling. ;; Good speed and allow scrolling through large images (pixel-scroll). ;; Note: Scroll lags when point must be moved but ...


6

You should be able to clear the secondary selection by evaluating: (delete-overlay mouse-secondary-overlay) If you never want to get the secondary selection I believe you can just unbind the default mouse events: (global-unset-key [M-mouse-1]) (global-unset-key [M-drag-mouse-1]) (global-unset-key [M-down-mouse-1]) (global-unset-key [M-mouse-3]) (global-...


6

I removed the mouse face as a whole in the agenda: (add-hook 'org-agenda-finalize-hook (lambda () (remove-text-properties (point-min) (point-max) '(mouse-face t))))


6

@Drew has explained some of the complexity associated with events bound to mouse actions. As for your ultimate goal of marking the word at point using the keyboard, you might be interested in expand-region. expand-region allows you to manipulate the region by semantic units. For example, when no region is active, calling er/expand-region (typically bound to ...


6

Function org-open-at-point (bound to C-c C-o) does precisely that I think. Its docstring (obtained through M-x describe-function) includes: (org-open-at-point &optional ARG REFERENCE-BUFFER) Open link, timestamp, footnote or tags at point. When point is on a link, follow it. Normally, files will be opened by an appropriate application. ...


5

The following advice achieves the behavior I want: (defadvice mouse-set-point (around cv/mouse-set-point (event) activate) (let ((event-name (car event)) (event-target-window (posn-window (event-start event)))) (if (and (eql 'down-mouse-1 event-name) (eql event-target-window (selected-window))) ad-do-it (select-...


5

You can use the mouse-face property. For example, the following snippet will make "f" look like a button when you hover the mouse pointer over it: (setq mode-line-format (list (propertize (concat "[" (propertize "f" 'mouse-face 'mode-line-highlight) "]:add file") 'local-map (make-mode-line-mouse-map 'mouse-1 'aria2-add-file)) " "))


5

Often, navigating to a location and pressing some key will have the same effect as clicking at that location. There's no built-in mechanism that ensures this, it's just that modes are typically written that way. You can generate mouse events (click, double/triple/… click, button down/up, drag, motion). All mouse events have the form (TYPE POSITION . EXTRA-...


5

First, you are apparently confusing the mouse pointer with the text cursor (aka cursor). It seems that you mostly talking about the latter, but referring to it as the "cursor". Second, insertion of a character is always between characters (or before the first or after the last character). This is necessarily so, by definition. Even if it were to behave and ...


5

If mouse reporting is on, then Shift+click is still interpreted by the terminal and not passed to the application. Thus, if a right-click pastes outside Emacs, and a straight right-click is passed through to Emacs, then Shift+right-click should paste in Emacs. Passthrough of Shift+click can be disabled, check that it's enabled. This applies to PuTTY and ...


5

shift in this case is a symbol, not a function. Note that the variable is given a quoted list, so nothing inside is evaluated. From the documentation of this variable (which you can access via describe-variable), you can give different amounts of scrolling for different (keyboard) modifiers. In this case, the normal scroll is 2 lines, or 1 if SHIFT is ...


4

It turns out it was evil-mode that did that! The answer can be found here: https://stackoverflow.com/questions/17127009/how-to-disable-emacs-evil-selection-auto-copies-to-clipboard/23254728#23254728 This is the code snippet that solved it: ; Override the default x-select-text function because it doesn't ; respect x-select-enable-clipboard on OS X. (defun x-...


4

Here's one way. You need to bind the command to a mouse event. But if you use a mouse-button click then you will likely need to bind the event for the other part of the click (e.g. down) to ignore. This is just an example - you might not want to waste C-mouse1 on such a command. The main function (command, actually) is describe-char. It describes the ...


4

You want to look at C-h v mouse-1-click-follows-link RET, I think.


4

After some more googling and reading of the manual, I have found a solution that works for me, by adding to the file ~/.emacs.d/init.el the following line: (define-key key-translation-map (kbd "<s-mouse-1>") (kbd "<mouse-2>")) In this way, I can generate mouse-2 events by pressing Command when clicking with the trackpad. key-translation-map is ...


4

You could also tell flyspell to use mouse-3 which seems more appropriate for a context menu: (eval-after-load "flyspell" '(progn (define-key flyspell-mouse-map [down-mouse-3] #'flyspell-correct-word) (define-key flyspell-mouse-map [mouse-3] #'undefined))) Answer stolen from here


4

According to your example you don't need the function with-eval-after-load. In Spacemacs it works simple like that: (defun dotspacemacs/user-config () "…" ;; … ;; dummy silence definition (defun silence () (interactive)) ;; don't jump the cursor around in the window on clicking (define-key evil-motion-state-map [down-mouse-1] 'silence) ;; ...


4

Put this in your init file: (setq disabled-command-function 'ignore) By default, disabling a command means that you get that prompt when you try to use it. But you can override this design by setting variable disabled-command-function to a function other than its default value, disabled-command-function. You can see the code for disabling and enabling in ...


3

You say that you never want to use the secondary selection. In that case, just bind the keys that are bound to secondary-selection commands by default to commands that you find more useful. Or unbind them, by binding them to nil. These are those keys: M-mouse-1 (mouse-start-secondary, by default) M-drag-mouse-1 (mouse-set-secondary, by default) M-down-...


3

Yes. (defun dired-follow-link-with-mouse (event) "Follow the link in the dired directory heading, causing a new dired buffer to be opened." (interactive (list last-nonmenu-event)) (run-hooks 'mouse-leave-buffer-hook) (with-current-buffer (window-buffer (posn-window (event-start event))) (let ((path (get-text-property (posn-point (event-start ...


3

Two-and-a-half answers: Artur Malabarba's init.el code. The blog post has useful comments. Victor Deryagin's init.el code from which Malabarba derived his. My third "answer" probably only applies to touchpads, but since most folks who have the need to turn off "the mouse" are actually using laptops and are accidentally touching their touchpad, I'll throw ...


3

You can do it: (defun select-char-at-click (event) "Select char at EVENT position. EVENT should be a mouse-click event." (interactive "e") (run-hooks 'mouse-leave-buffer-hook) ; Give Isearch etc. a chance to turn off. (let ((pos (cadr (event-start event)))) (unless (>= pos (point-max)) (push-mark pos) (goto-char (1+ (mark))))) (...


3

I realize you asked specifically about org-mode, but this might be of interest to others reading this. A general variable exists: mouse-highlight. Setting it to nil disables highlighting of clickable text in all modes, keeping intact the click function. It is documented in the emacs manual.


3

Bind mouse-1 to the command you want: (define-key dired-mode-map [mouse-1] 'dired-find-file) Or bind it to a command that is like dired-mouse-find-file-other-window but uses the same window. (defun dired-mouse-find-file (event) "In Dired, visit the file or directory name you click on." (interactive "e") (let (window pos file) (save-excursion ...


Only top voted, non community-wiki answers of a minimum length are eligible