]> code.delx.au - gnu-emacs/blobdiff - lisp/msb.el
Update copyright years, update license to GPLv3 or later.
[gnu-emacs] / lisp / msb.el
index 95cbfc85df49809444a744afca959c65e4caeabc..8dfe31c99d2ba0f5a315b041e6504cca301d2cf0 100644 (file)
@@ -1,7 +1,7 @@
 ;;; msb.el --- customizable buffer-selection with multiple menus
 
 ;; Copyright (C) 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Lars Lindberg <lars.lindberg@home.se>
 ;; Maintainer: FSF
@@ -13,7 +13,7 @@
 
 ;; 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 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -230,7 +230,7 @@ the test is surrounded by calls to `save-excursion' and
 `save-match-data'.
 
 The categories are sorted by MENU-SORT-KEY.  Smaller keys are on top.
-nil means don't display this menu.
+A value of nil means don't display this menu.
 
 MENU-TITLE is really a format.  If you add %d in it, the %d is
 replaced with the number of items in that menu.
@@ -474,12 +474,20 @@ See the function `mouse-select-buffer' and the variable
 `msb-menu-cond' for more information about how the menus are split."
   (interactive "e")
   (let ((old-window (selected-window))
-       (window (posn-window (event-start event))))
+       (window (posn-window (event-start event)))
+       early-release)
     (unless (framep window) (select-window window))
+    ;; This `sit-for' magically makes the menu stay up if the mouse
+    ;; button is released within 0.1 second.
+    (setq early-release (not (sit-for 0.1 t)))
     (let ((buffer (mouse-select-buffer event)))
       (if buffer
          (switch-to-buffer buffer)
-       (select-window old-window))))
+       (select-window old-window)))
+    ;; If the above `sit-for' was interrupted by a mouse-up, avoid
+    ;; generating a drag event.
+    (if (and early-release (memq 'down (event-modifiers last-input-event)))
+       (discard-input)))
   nil)
 
 ;;;
@@ -990,9 +998,6 @@ variable `msb-menu-cond'."
        ;; adjust position
        (setq posX (- posX (funcall msb-horizontal-shift-function))
              position (list (list posX posY) posWind))))
-    ;; This `sit-for' magically makes the menu stay up if the mouse
-    ;; button is released within 0.1 second.
-    (sit-for 0 100)
     ;; Popup the menu
     (setq choice (x-popup-menu position msb--last-buffer-menu))
     (cond
@@ -1002,7 +1007,7 @@ variable `msb-menu-cond'."
       (mouse-select-buffer event))
      ((and (numberp (car choice))
           (null (cdr choice)))
-      (let ((msb--last-buffer-menu (nthcdr 3 (assq (car choice)
+      (let ((msb--last-buffer-menu (nthcdr 2 (assq (car choice)
                                                   msb--last-buffer-menu))))
        (mouse-select-buffer event)))
      ((while (numberp (car choice))