< - doesn't require Visual Studio to build it, just Windows SDK 7.1 SP1 is enough.
You can get emacs to display Explorer’s context menu in dired, exactly as you would be able to do when using RMB in Explorer.
This is an example of how it can look:
To get this working, add the following functions to your .emacs:
(defun w32-context-menu (filename) (start-process-shell-command "context" "*context*" "context" filename))
(defun w32-context-menu-dired-get-filename (event) (interactive "e") ;; moves point to clicked row (mouse-set-point event) (w32-context-menu (concat "\"" (dired-get-filename) "\"")))
Add a new key binding for dired. This is from my-dired-init which is hooked to dired-load-hook:
;; Bind RMB (define-key dired-mode-map [mouse-3] 'w32-context-menu-dired-get-filename)
At last, an external program (licensed under the GPL), context.exe is needed to get this working. The program must be placed somewhere in the system path. You can dowload it together with the equally nice propsfor.exe (same thing but opens the property dialog instead) from here:
I don’t need the propsfor tool as I can as well use the Properties dub menu on the context menu., but a similar hack could be done for those who want direct access to that dialog.
When not in dired, I use this:
(defun w32-context-menu-current-buffer () (interactive) (w32-context-menu (concat "\"" buffer-file-name "\"")))
(global-set-key "\C-cc" 'w32-context-menu-current-buffer)
I couldn’t get the solution above to work on 64-bit Vista or Windows 7 so I decided to code up a small utility of my own.
The resulting project can be found on Github http://github.com/bkz/w32context
I couldn’t find the mentioned w32context.exe at github.com/bkz/w32context. I use ShellContextMenu.exe from the Eclipse plugin Navigator Extensions: Its download nax_220.127.116.11201311435.zip contains a nested Jar (Zip) file plugins/com.googlecode.eclipse.navigatorext_18.104.22.168201311435.jar with ShellContextMenu.exe in it.
However, ShellContextMenu.exe does not understand the forward slashes returned by function buffer-file-name. So i put cygwin’s cygpath around it. Using a Stack Overflow answer how to call an external command, i ended up with this function:
(defun external-command-context-menu() "runs external command ShellContextMenu on the current file" (interactive) (shell-command (format "bash -c \"ShellContextMenu %s '$(cygpath -w -- %s)'\"" '0 (shell-quote-argument (buffer-file-name)))))
Here is another program with the same idea: https://github.com/vkalviss/WinContextMenu
Few extra features:
- it includes binaries for both x86 and x64 platforms
- supports multiple files selection
- supports emacs navigation keys in the menu (C-n, C-p, C-g, etc)