grab-and-drag.el provides a command and a minor mode which allow users to scroll the window in the arbitrary direction by mouse dragging, like “Grab and Drag” firefox extension. It’s probably useful for a touch panel based computer.
The code is rather X-dependent and is tested on GNU Emacs 22 and 23.
First, save this file as grab-and-drag.el and byte-compile in a directory that is listed in load-path.
Put the following in your .emacs file:
(require 'grab-and-drag) (grab-and-drag-mode 1)
Then, start Emacs and grab-and-drag-mode is activated.
On low spec machine like ARM-based tablet, changing the pointer shape might be extremely slow so the slow response to clicking is annoying. In that case, we can reduce the response time by disabling the change of the pointer shape as:
(setq grab-and-drag-pointer-shape nil)
nBy default settings, you can do “Grab and Drag” using a command
‘grab-and-drag’ by mouse dragging with the left button. That means grab-and-drag-mode overrides the binding of
‘down-mouse-1’ event, which is usually bound to
‘mouse-drag-region’ command. Even Though grab-and-drag-mode overrides the original binding, you can still use it by holding down the button for 1 second without moving the pointer.
If you release the mouse button while moving the pointer, the additional action is performed according to the dragging time and direction. The mouse dragging longer than 500 milliseconds causes an inertial scrolling vertically. Otherwise the quick dragging is recognized as a flick gesture, which causes a scrolling by screenful in that direction.
To move to the next/previous Web page by horizontal flick gesture, add the following to .emacs file:
(add-hook 'w3m-mode-hook (lambda () (make-local-variable 'grab-and-drag-gesture-left-command) (make-local-variable 'grab-and-drag-gesture-right-command) (setq grab-and-drag-gesture-left-command 'w3m-view-next-page) (setq grab-and-drag-gesture-right-command 'w3m-view-previous-page)))
To get the time line automatically when vertical scrolling reaches the ends of buffer, add the following to .emacs file:
(add-hook 'twittering-mode-hook (lambda () (add-hook 'grab-and-drag-beginning-of-buffer-hook 'beginning-of-buffer nil t) (add-hook 'grab-and-drag-end-of-buffer-hook 'twittering-goto-next-status nil t)))