riscy / shx-for-emacs

An Emacs shell-mode (and comint-mode) extension that enables displaying small plots and graphics and lets users write shell commands in Emacs Lisp.
GNU General Public License v3.0
218 stars 10 forks source link

Open file via mouse click #21

Open fbob opened 4 years ago

fbob commented 4 years ago

This shx-mode is so useful, thanks ! Just a newbie question, could it be possible to open files via (ctrl+) mouse-click ? It is sometimes much quicker to do so.

riscy commented 4 years ago

Thanks so much for saying so! :)

There is a similar (or at least related) issue about opening files at https://github.com/riscy/shx-for-emacs/issues/20, which I'll mark here for reference.

A quick option would be to add to your .emacs:

(require 'shx)
;; ...
(define-key shx-mode-map [C-mouse-1] #'ffap-at-mouse)
;; shadow C-down-mouse-1 with empty behavior to avoid some errors:
(define-key shx-mode-map [C-down-mouse-1] (lambda (e) (interactive "e")))

or you could quickly just run these in a shx session to try it out:

:ev (define-key shx-mode-map [C-mouse-1] #'ffap-at-mouse)
:ev (define-key shx-mode-map [C-down-mouse-1] (lambda (e) (interactive "e")))

But this solution seems to be a little hacky since -- at least for me on macOS -- it requires shadowing C-down-mouse-1 to avoid error messages.

I'll come back to this as there might be a better solution.

fbob commented 4 years ago

Perfect, great addition, I like it a lot ! THANKS :)