;;; mouse-drag.el --- use mouse-2 to do a new style of scrolling
-;; Copyright (C) 1996, 1997, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2001-2012 Free Software Foundation, Inc.
;; Author: John Heidemann <johnh@ISI.EDU>
;; Keywords: mouse
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; for ``one-click text copy and move''.
;;
;; To use mouse-drag, place the following in your .emacs file:
-;; (require 'mouse-drag)
-;; -and either-
+;; -either-
;; (global-set-key [down-mouse-2] 'mouse-drag-throw)
;; -or-
;; (global-set-key [down-mouse-2] 'mouse-drag-drag)
mouse-drag-electric-col-scrolling
(save-excursion ;; on a long line?
(let
- ((beg (progn (beginning-of-line) (point)))
+ ((beg (line-beginning-position))
(end (progn (end-of-line) (point))))
(if (> (- end beg) (window-width))
(setq truncate-lines t)
(if (< mouse-delta 0) -1 1)
(if mouse-throw-with-scroll-bar 1 -1)))
-
+;;;###autoload
(defun mouse-drag-throw (start-event)
"\"Throw\" the page according to a mouse drag.
you'll like it. It's easier to observe than to explain.
If the mouse is clicked and released in the same place of time we
-assume that the user didn't want to scdebugroll but wanted to whatever
+assume that the user didn't want to scroll but wanted to whatever
mouse-2 used to do, so we pass it through.
Throw scrolling was inspired (but is not identical to) the \"hand\"
(start-row (cdr (posn-col-row start-posn)))
(start-col (car (posn-col-row start-posn)))
(old-selected-window (selected-window))
- event end row mouse-delta scroll-delta
+ event end row scroll-delta
have-scrolled
- window-last-row
- col mouse-col-delta window-last-col
+ col
(scroll-col-delta 0)
- adjusted-mouse-col-delta
- adjusted-mouse-delta
;; be conservative about allowing horizontal scrolling
(col-scrolling-p (mouse-drag-should-do-col-scrolling)))
(select-window start-window)
;; Now restore the old window.
(select-window old-selected-window)))
+;;;###autoload
(defun mouse-drag-drag (start-event)
"\"Drag\" the page according to a mouse drag.
(start-row (cdr (posn-col-row start-posn)))
(start-col (car (posn-col-row start-posn)))
(old-selected-window (selected-window))
- event end row mouse-delta scroll-delta
+ event end row scroll-delta
have-scrolled
window-last-row
- col mouse-col-delta window-last-col
+ col window-last-col
(scroll-col-delta 0)
;; be conservative about allowing horizontal scrolling
(col-scrolling-p (mouse-drag-should-do-col-scrolling)))
(provide 'mouse-drag)
-;; arch-tag: e47354ff-82f5-42c4-b3dc-88dd9c04b770
;;; mouse-drag.el ends here